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

Use numpy.testing.assert_allclose over assert np.(all|is)close #582

Merged
merged 6 commits into from
Oct 20, 2023

Conversation

janosh
Copy link
Member

@janosh janosh commented Oct 20, 2023

For much better error messages

AssertionError:
Not equal to tolerance rtol=1e-07, atol=0.05

Mismatched elements: 5 / 5 (100%)
Max absolute difference: 20.93780092
Max relative difference: 0.00351895
 x: array([ 5076.241999,  5402.944837,  6781.803129,  8742.033493,
       10939.957742])
 y: array([ 5058.441588,  5385.880586,  6765.198542,  8723.785881,
       10919.019941])

vs previously

AssertionError: assert False

Related PR materialsproject/pymatgen#3253.

for much better error messages

AssertionError:
Not equal to tolerance rtol=1e-07, atol=0.05

Mismatched elements: 5 / 5 (100%)
Max absolute difference: 20.93780092
Max relative difference: 0.00351895
 x: array([ 5076.241999,  5402.944837,  6781.803129,  8742.033493,
       10939.957742])
 y: array([ 5058.441588,  5385.880586,  6765.198542,  8723.785881,
       10919.019941])

vs previously

AssertionError: assert False

also remove unused float precision
@janosh janosh added testing Test all the things dx Developer experience labels Oct 20, 2023
@janosh janosh enabled auto-merge October 20, 2023 15:12
@codecov
Copy link

codecov bot commented Oct 20, 2023

Codecov Report

Merging #582 (725cb50) into main (a77db3c) will not change coverage.
The diff coverage is 0.00%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #582   +/-   ##
=======================================
  Coverage   75.49%   75.49%           
=======================================
  Files          80       80           
  Lines        6725     6725           
  Branches      992      992           
=======================================
  Hits         5077     5077           
  Misses       1342     1342           
  Partials      306      306           
Files Coverage Δ
src/atomate2/cli/dev.py 0.00% <ø> (ø)
src/atomate2/cp2k/schemas/calc_types/utils.py 50.00% <0.00%> (ø)

E           Not equal to tolerance rtol=1e-07, atol=0
E
E           Mismatched elements: 1 / 5 (20%)
E           Max absolute difference: 0.00014774
E           Max relative difference: 2.12726453e-07
E            x: array([5776.149837, 5617.747275, 4725.502643, 3043.818312,  694.490931])
E            y: array([5776.14995 , 5617.747378, 4725.502694, 3043.818276,  694.490784])

assert_allclose(
            responses[job.jobs[-1].uuid][1].output.free_energies,
            [
                5776.1499503440455,
                5617.747377776762,
                4725.502693639196,
                3043.818276263367,
                694.4907835517783,
            ],
        )
@janosh janosh merged commit 478b444 into main Oct 20, 2023
6 of 7 checks passed
@janosh janosh deleted the testing-np-assert-allclose branch October 20, 2023 18:34
@utf utf added the house-keeping Formatting and code quality tweaks label Oct 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dx Developer experience house-keeping Formatting and code quality tweaks testing Test all the things
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants