Skip to content

Commit

Permalink
Ensure integer dtypes are returned from log()
Browse files Browse the repository at this point in the history
  • Loading branch information
mhostetter committed Jun 22, 2024
1 parent b2e7155 commit 0ae8b87
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/galois/_domains/_ufunc.py
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,8 @@ def __call__(self, ufunc, method, inputs, kwargs, meta):
inputs = list(inputs) + [int(self.field.primitive_element)]
inputs, kwargs = self._view_inputs_as_ndarray(inputs, kwargs)
output = getattr(self.ufunc, method)(*inputs, **kwargs)
if output.dtype == np.object_:
output = output.astype(int)
return output


Expand Down
2 changes: 2 additions & 0 deletions src/galois/_fields/_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -1730,6 +1730,8 @@ def log(self, base: ElementLike | ArrayLike | None = None) -> int | np.ndarray:

if np.isscalar(output):
output = int(output)
if output.dtype == np.object_:
output = output.astype(int)

return output

Expand Down

0 comments on commit 0ae8b87

Please sign in to comment.