Skip to content
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

test_load_data checks for floating point equality #23

Closed
pmeier opened this issue Oct 3, 2021 · 1 comment
Closed

test_load_data checks for floating point equality #23

pmeier opened this issue Oct 3, 2021 · 1 comment

Comments

@pmeier
Copy link

pmeier commented Oct 3, 2021

assert orig_data.loc[0, "formation_energy_per_atom"] == -0.7374389025000001
assert reload_data.loc[0, "formation_energy_per_atom"] == -0.7374389025000001

In general, we should never check floating point values for equality. Especially the last six digits look insignificant where the 1 is most likely an artifact of the imperfect floating point representation. Maybe pytest.approx would be a better fit here?

@a-ws-m
Copy link
Owner

a-ws-m commented Oct 14, 2021

Thanks for the advice! I didn't know about pytest.approx.

@a-ws-m a-ws-m closed this as completed Oct 14, 2021
a-ws-m added a commit that referenced this issue Oct 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants