-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Problem mit Approx #5737
Comments
I don't follow. You expect a value to be 0 ± 1.0e-12 but it is -1.758637679927233e-11 which is far smaller (i.e. further away from 0). |
I know and i don't want it. I expected a value 0 ± 1e-5 (see code line), but pytest ignores my decision and uses 1e-12 |
I think the problem is that you specified a relative tolerance instead of an absolute tolerance, and anything relative to 0 is still 0. Try this instead:
The logic behind all of this is explained here: https://docs.pytest.org/en/latest/reference.html#pytest-approx |
Great! Now it works like expected. Thanks for your quick help. 👍 |
Hey guy,
I have a little problem with the function approx. I use it alot in a project, but in one situation it looks like the code by this guy.
Here is the spesific file, the line of code at 853:
assert constr_value[0] == pytest.approx(0, 1e-5)
The error:
I'm using the pytest version 4.3.1 from Anaconda3 and win 10 and these are my packages.
The text was updated successfully, but these errors were encountered: