Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

where argument doesn't work with np.reciprocal #501

Closed
jimpo opened this issue Aug 14, 2023 · 3 comments
Closed

where argument doesn't work with np.reciprocal #501

jimpo opened this issue Aug 14, 2023 · 3 comments

Comments

@jimpo
Copy link

jimpo commented Aug 14, 2023

Python: 3.11.6, galois version 0.3.5, numpy version 1.24

This code produces an error:

F = GF(2**8)

x = F([1, 1, 3])
x_invertible = x != 0
y = np.reciprocal(x, where=x_invertible)

Exception

self = <galois._domains._calculate.reciprocal_itoh_tsujii object at 0x7f020ad67d90>
ufunc = <ufunc 'reciprocal'>, method = '__call__'
inputs = [array([1, 1, 3], dtype=uint8)]
kwargs = {'casting': 'unsafe', 'where': array([ True,  True,  True])}
meta = {'dtype': dtype('uint8'), 'field_operands': [0], 'non_field_operands': [], 'operands': [0], ...}

    def __call__(self, ufunc, method, inputs, kwargs, meta):
        self._verify_unary_method_not_reduction(ufunc, method)
        inputs, kwargs = self._view_inputs_as_ndarray(inputs, kwargs)
>       output = getattr(self.ufunc, method)(*inputs, **kwargs)
E       ValueError: Only one of the iterator flags READWRITE, READONLY, and WRITEONLY may be specified for an operand

../.venv/lib/python3.11/site-packages/galois/_domains/_ufunc.py:413: ValueError
@mhostetter
Copy link
Owner

Thanks for the report. I believe Numba doesn't support exotic keyword arguments, like where, to numba.vectorize()'d functions. If that's the case, there's nothing we can do.

Perhaps we should add better error reporting. I had this idea a long time ago in #34, but never completely implemented it.

@jimpo
Copy link
Author

jimpo commented Aug 14, 2023

Thanks for the fast reply! That makes sense, as a workaround I used

np.reciprocal.at(x, np.nonzero(x))

@mhostetter
Copy link
Owner

I think I'm going to close this. where support is needed from Numba before it will be exposed in this library. Once Numba adds it, users will have access to it from galois.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants