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

Allow per-example atol, rtol; support Ellipsis in numeric values #147

Open
ev-br opened this issue Apr 5, 2024 · 0 comments
Open

Allow per-example atol, rtol; support Ellipsis in numeric values #147

ev-br opened this issue Apr 5, 2024 · 0 comments
Labels
enhancement New features w.r.t. the original refguide-check

Comments

@ev-br
Copy link
Member

ev-br commented Apr 5, 2024

Consider the following doctest example

>>> np.sqrt(2)
1.4...

Under doctest.ELLIPSIS this means that ... matches any string --- essentially this defines the tolerance for this particular example.

We do have doctest.ELLIPSIS on by default, and it works fine --- but it curiously breaks down under numpy 2.0 scalar representation:

>>> import numpy as np
>>> np.sqrt(2)
np.float64(1.4142135623730951)

Normally, 1.4142 would evaluate to np.allclose to np.float64(1.4142135) --- but the ellipsis breaks it because the vanilla doctest does not understand np.float64 and our machinery does not understand ....

The solution is to probably

  • detect the trailing ellipsis in want, i.e. if want.edswith('...')
  • chop it off
  • adjust the atol, rtol to the number of sig figs (DTChecker._do_check should get explicit atol, rtol arguments defaulting to self.atol, self.rtol).
@ev-br ev-br added the enhancement New features w.r.t. the original refguide-check label Apr 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New features w.r.t. the original refguide-check
Projects
None yet
Development

No branches or pull requests

1 participant