Open
Description
With the following file, I would have expected the doctest to pass thanks to floating point comparison but it doesn't.
def test():
"""
>>> 1/3
0.33
>>> ['a', 1/3, 'c']
['a', 0.33, 'c']
>>> ('a', 1/3, 'c')
('a', 0.33, 'c')
>>> [('a', 1/3), ('b', 1)] # fails
[('a', 0.33), ('b', 1)]
>>> {'a': 1/3} # fails
{'a': 0.33}
"""
Output is:
❯ python -m scipy_doctest /tmp/test-doctest.py
test-doctest.test
-----------------
File "/tmp/test-doctest.py", line 12, in test-doctest.test
Failed example:
[('a', 1/3), ('b', 1)] # fails
Expected:
[('a', 0.33), ('b', 1)]
Got:
[('a', 0.3333333333333333), ('b', 1)]
test-doctest.test
-----------------
File "/tmp/test-doctest.py", line 15, in test-doctest.test
Failed example:
{'a': 1/3} # fails
Expected:
{'a': 0.33}
Got:
{'a': 0.3333333333333333}
1 item had failures:
2 of 5 in test-doctest.test
***Test Failed*** 2 failures.
This was seen noticed in scikit-learn. For now the easy work-around is to use ...
i.e. something like:
>>> {'a': 1/3}
{'a': 0.33...}