Skip to content

Commit

Permalink
Use max dtype for integer dtype, either np.int64 or np.object_
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mhostetter committed Jul 1, 2024
1 parent ccda082 commit 4921897
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/galois/_fields/_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -989,7 +989,7 @@ def additive_order(self) -> int | np.ndarray:
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=field.dtypes[-1])
order[np.where(x == 0)] = 1

return order
Expand Down

0 comments on commit 4921897

Please sign in to comment.