Skip to content

Commit

Permalink
Keep existing repr() results, with numpy>=2.0
Browse files Browse the repository at this point in the history
In various __repr__() implementations, replace 'list(ndarray)' with
'ndarray.tolist()', in order to avoid inclusion of type information (like
'np.int64(1)') by the latest numpy version.

This also fixes test_clifford.TestPrettyRepr and test_transformations
pytest-s, as they rely on hardcoded results from IPython.lib.pretty.

Note: numpy>=2.0 is allowed by numba>=0.60.
  • Loading branch information
trundev committed Nov 21, 2024
1 parent 9528a38 commit 480ec7f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions clifford/_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ def vee(aval, bval):
def __repr__(self):
return "{}({!r}, ids={!r}, order={!r}, names={!r})".format(
type(self).__name__,
list(self.sig), self._basis_vector_ids, self._basis_blade_order, self.names
self.sig.tolist(), self._basis_vector_ids, self._basis_blade_order, self.names
)

def _repr_pretty_(self, p, cycle):
Expand All @@ -489,7 +489,7 @@ def _repr_pretty_(self, p, cycle):
prefix = '{}('.format(type(self).__name__)

with p.group(len(prefix), prefix, ')'):
p.text('{},'.format(list(self.sig)))
p.text('{},'.format(self.sig.tolist()))
p.breakable()
p.text('ids=')
p.pretty(self._basis_vector_ids)
Expand Down
2 changes: 1 addition & 1 deletion clifford/_multivector.py
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ def _repr_pretty_(self, p, cycle):
p.pretty(self.layout)
p.text(",")
p.breakable()
p.text(repr(list(self.value)))
p.text(repr(self.value.tolist()))
if self.value.dtype != np.float64:
p.text(",")
p.breakable()
Expand Down

0 comments on commit 480ec7f

Please sign in to comment.