scientific-python / pytest-doctestplus

Pytest plugin providing advanced doctest features
Other
97 stars 38 forks source link

Move FLOAT_CMP upstream and/or combine with numpy/scipy? #55

Open mhvk opened 5 years ago

mhvk commented 5 years ago

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's refguide [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

drdavella commented 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.

hameerabbasi commented 5 years ago

This is something that would be very useful. I can look into it, definitely. 😄

nstarman commented 2 years ago

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?

pllim commented 1 year ago

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

mhvk commented 1 year ago

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.