Open mhvk opened 5 years ago
I'd be in favor, especially given the fact that we recently discovered some issues with the way that FLOAT_CMP
interacts with other doctest flags. See #54.
This is something that would be very useful. I can look into it, definitely. 😄
Pytest has added NUMBER
(see https://docs.pytest.org/en/6.2.x/doctest.html?highlight=doctest#using-doctest-options). Maybe FLOAT_CMP
can just be a thin redirect to that?
I think we decided that NUMBER
isn't as flexible as we need it to be (we support atol and rtol here, but it does not).
Superseded by #199
Let's keep this open for the moment, since perhaps NUMBER
is really good enough: its atol
is just set by the last digit, so adjustable in that sense.
As noted originally in https://github.com/astropy/astropy/issues/6554, numpy was thinking about their own version of something like
FLOAT_CMP
and ended up adapting scipy'srefguide
[1] for its docstring testing. It includes float comparisons and "numbers may vary". We should check whether we can also use this, to make the ecosystem a bit more uniform. In this respect, probably good to remember that this was put also to python-ideas by @kdavies4 with Coghlan concluding it was a good idea [2]. (See also https://github.com/numpy/numpy/issues/9415#issuecomment-315331351)[1] https://github.com/scipy/scipy/blob/master/tools/refguide_check.py [2] https://mail.python.org/pipermail/python-ideas/2014-August/028559.html