From 4921897b3f54a9e42e41914ff0d06bfdb6f981f8 Mon Sep 17 00:00:00 2001 From: mhostetter Date: Mon, 1 Jul 2024 17:18:53 -0400 Subject: [PATCH] Use max dtype for integer dtype, either `np.int64` or `np.object_` 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. --- src/galois/_fields/_array.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/galois/_fields/_array.py b/src/galois/_fields/_array.py index 9f1173f32..2895a4563 100644 --- a/src/galois/_fields/_array.py +++ b/src/galois/_fields/_array.py @@ -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