-
Notifications
You must be signed in to change notification settings - Fork 32
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
Support NumPy 2.0 #550
Support NumPy 2.0 #550
Conversation
81fdd1f
to
4c9f6b5
Compare
The trick of converting diff --git a/src/galois/_polys/_dense.py b/src/galois/_polys/_dense.py
index b1b3e28..4f45d78 100644
--- a/src/galois/_polys/_dense.py
+++ b/src/galois/_polys/_dense.py
@@ -487,7 +487,7 @@ class roots_jit(Function):
# Test if 0 is a root
if nonzero_degrees[-1] != 0:
roots.append(0)
- powers.append(-1)
+ powers.append(np.iinfo(nonzero_coeffs.dtype).max)
# Test if 1 is a root
_sum = 0 With this patch in addition to your 3 commits all tests pass again with NumPy 2.0 🙂 |
Sorry, I forgot to include in the diff one more needed change to pass all tests. Here it is: diff --git a/src/galois/_fields/_array.py b/src/galois/_fields/_array.py
index 5cf847d..2ff32fa 100644
--- a/src/galois/_fields/_array.py
+++ b/src/galois/_fields/_array.py
@@ -988,7 +988,7 @@ class FieldArray(Array, metaclass=FieldArrayMeta):
if x.ndim == 0:
order = 1 if x == 0 else field.characteristic
else:
- order = field.characteristic * np.ones(x.shape, dtype=np.int64)
+ order = field.characteristic * np.ones(x.shape, dtype=x.dtype)
order[np.where(x == 0)] = 1
return order |
If it's easier for you, I have made both changes available in this branch. I guess you can cherry-pick those commits directly here: |
NumPy 2.0 raises an OverflowError instead of casting to dtype np.object_ as in previous versions. This can happen here if field.charactersitic is to large to fit in a np.int64.
Thanks for the fixes @iyanmv. I modified them slightly (found a bug in my code in one, made your solution more general in the other). Can you test |
That branch works well on Arch Linux 👌 |
Probably should merge into
release/0.4.x
.