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
BUG: numpy.test() fails at test_linear_interpolation_formula_symmetric #22073
Comments
Did you install NumPy from a wheel/conda or did you build it yourself? |
I installed it via a wheel: numpy-1.23.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
Huh. I can reproduce on 1.23.1 by updating hypothesis to 6.53.0 and adding this decorator to the test. |
The test is checking that linear interpolation is equivalent when flipped around and seems to be off by one eps:
|
Test setup: numpy 1.23.1 | Python 3.10.6 | macOS 12.4 The test run passes with hypothesis==6.48.0: The test failure appears with the hypothesis==6.48.1 upgrade. They seem to have changed the float testing strategy: HypothesisWorks/hypothesis#2701 The new strategy uncovered a float precision related mismatch as mentioned above by @mattip
The lerp function:
For the failing test case (t = 0.5) it's effectively:
The real calculation vs. the double precision calculation:
The double precision error accumulates enough to flip the last bit on the symmetric run:
This does not seem like a bug to me in _lerp, but something natural for floating point comparisons, so my suggested fix would be to replace the assert with assert_allclose in the unit test:
|
This is also failing for the wheel builds. EDIT: But not on windows. That suggests different rounding strategies. |
@palbarta indeed changing to |
The lerp test compared the output of the original and the symmetric functions by using basic assertion. Double precision errors could accumulate in a way that the 2 outputs mismatch by epsilon. For more information on the precision issue, see numpy#22073 Fix: use assert_allclose instead for float comparison.
@mattip PR submitted |
The lerp test compared the output of the original and the symmetric functions by using basic assertion. Double precision errors could accumulate in a way that the 2 outputs mismatch by epsilon. For more information on the precision issue, see numpy#22073 Fix: use assert_allclose instead for float comparison.
@InessaPawson Thank you for taking my fix, it was my pleasure. |
Describe the issue:
When I run
numpy.test()
a failure is encountered intest_linear_interpolation_formula_symmetric
. I don't know if this is actually a bug, but I thought I should add this as an issue. I've run the test twice now and it gives the same result.I've searched for this on GitHub, Stack Overflow and Google, but got no results.
OS is Linux Mint 19.3 Cinnamon.
Reproduce the code example:
Error message:
NumPy/Python version information:
1.23.1 3.8.0 (default, Dec 9 2021, 17:53:27)
[GCC 8.4.0]
The text was updated successfully, but these errors were encountered: