From 2d60e1597b8d2a32b56f983ae3f463f6e8312dcf Mon Sep 17 00:00:00 2001 From: mhostetter Date: Sat, 22 Jun 2024 14:27:28 -0400 Subject: [PATCH] Fix `np.mod()` in NumPy v2 --- src/galois/_domains/_ufunc.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/galois/_domains/_ufunc.py b/src/galois/_domains/_ufunc.py index 72168b6da..e89d2456e 100644 --- a/src/galois/_domains/_ufunc.py +++ b/src/galois/_domains/_ufunc.py @@ -394,7 +394,11 @@ def __call__(self, ufunc, method, inputs, kwargs, meta): self._verify_operands_in_field_or_int(ufunc, inputs, meta) inputs, kwargs = self._view_inputs_as_ndarray(inputs, kwargs) i = meta["non_field_operands"][0] # Scalar multiplicand - inputs[i] = np.mod(inputs[i], self.field.characteristic) + if meta["dtype"] == np.object_: + # Need to explicitly cast to np.object_ in NumPy v2.0 or the integer will overflow + inputs[i] = np.mod(inputs[i], self.field.characteristic, dtype=np.object_) + else: + inputs[i] = np.mod(inputs[i], self.field.characteristic) inputs, kwargs = self._view_inputs_as_ndarray(inputs, kwargs) output = getattr(self.ufunc, method)(*inputs, **kwargs) output = self._view_output_as_field(output, self.field, meta["dtype"])