scipy / scipy_doctest

Floating-point aware doctesting
BSD 3-Clause "New" or "Revised" License
5 stars 4 forks source link

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

Open ev-br opened 4 months ago

ev-br commented 4 months ago

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