Skip to content

Commit

Permalink
fix(doctest): use legacy numpy scalar printing
Browse files Browse the repository at this point in the history
  • Loading branch information
ljgray committed Sep 26, 2024
1 parent db040a9 commit e056d39
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions caput/memh5.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@
else:
zarr_available = True

# This needs to be set for doctests to pass on numpy 2.0. In numpy 2.0+,
# the repr of a numpy scalar include the type information - i.e. a numpy
# scalar is printed as 'np.float64(3.0)' rather than just '3.0'.
# https://numpy.org/doc/stable/release/2.0.0-notes.html#representation-of-numpy-scalars-changed
np.set_printoptions(legacy="1.25")

# Basic Classes
# -------------

Expand Down
6 changes: 6 additions & 0 deletions caput/mpiarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,12 @@

logger = logging.getLogger(__name__)

# This needs to be set for doctests to pass on numpy 2.0. In numpy 2.0+,
# the repr of a numpy scalar include the type information - i.e. a numpy
# scalar is printed as 'np.float64(3.0)' rather than just '3.0'.
# https://numpy.org/doc/stable/release/2.0.0-notes.html#representation-of-numpy-scalars-changed
np.set_printoptions(legacy="1.25")


class _global_resolver:
# Private class implementing the global sampling for MPIArray
Expand Down

0 comments on commit e056d39

Please sign in to comment.