Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix numpy doctest local #177

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

floesche
Copy link
Contributor

This PR potentially improves the numpy>=2.0 compatibility

  • I replaced two references to np.float_ as a dtype (and the minimum numpy version 1.16 seems to support both)
  • NEP51 changes the representation of scalars (e.g. np.float64(1.074), which fails the doctest when compared to 1.074). While numpy<2.0 is still an accepted dependency, I change the representation back to python scalars to pass the tests.
  • As opposed to Fix numpy doctest #176, this PR configures the number representation within each test. The comment for each test shows the potential expected results, once numpy>=2.0 is the minimum requirement.

This problem came up in #175 and is an alternative solution to #176.

replace np.float_ with np.float64. The minimum numpy version 1.16 has
both as aliases, the newer version numpy>=2.0 don't support np.float_
anymore.
[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.
instead of setting an environment-specific number representation within
numpy, this commit sets the number representation per test case and with
a suggestion on how to change it once numpy>=2.0 is the minimal
requirement.
@floesche floesche mentioned this pull request Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant