Skip to content

Commit

Permalink
workaround for doctest comparison of np dtypes
Browse files Browse the repository at this point in the history
[NEP51](https://numpy.org/neps/nep-0051-scalar-representation.html#backward-compatibility)
changes the representation of scalars. While the long term strategy
should be a comparison with the new form of representation, the
discussion in [issue
24470](numpy/numpy#24470) seems to suggest to
use an intermediate step while both, numpy-1 and numpy-2 are supported.
  • Loading branch information
floesche committed Dec 11, 2024
1 parent f44dad8 commit bd0e2dc
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions navis/morpho/mmetrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@
# Set up logging
logger = config.get_logger(__name__)

# Set up numpy number representation, see NEP51
# Once numpy<=2 is dropped from requirements, the doctest comparissons
# should become `np.float64(1.074)` instead of `1.074`
if int(np.version.version.split('.')[0])>=2:
np.set_printoptions(legacy="1.25")

__all__ = sorted(
[
"strahler_index",
Expand Down

0 comments on commit bd0e2dc

Please sign in to comment.