Skip to content

Breaking: Overhaul class PymatgenTest #3014

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

Merged
merged 8 commits into from
May 25, 2023
Merged

Conversation

janosh
Copy link
Member

@janosh janosh commented May 25, 2023

Drop unused PymatgenTest methods, rename existing ones from camel to snake case and replace assert_almost_equal with assert_allclose as recommended by numpy docs.

8ad0792 breaking: drop internally unused PymatgenTest.get_mp_structure()
8681792 breaking: drop internally unused PymatgenTest.assertDictsAlmostEqual()
62e9afc replace all PymatgenTest.assertArrayEqual with numpy.testing.assert_array_equal
9a1dfc1 remove PymatgenTest.assertArrayEqual() method
1462805 replace numpy.testing.assert_almost_equal() with numpy.testing.assert_allclose()
8a0e76e refactor import: from numpy.testing import assert_array_almost_equal
91013e1 breaking: snake_case assertStrContentEqual to assert_str_content_equal
729a5df breaking: snake_case assertMSONable to assert_msonable

Many of the commits here are breaking but since PymatgenTest is only for internal use, it shouldn't matter.

janosh added 8 commits May 25, 2023 09:21
but could break external code (though no one else should be using Pymatgen test routines)
use pytest.approx() instead which handles all iterable types incl. dict
…_allclose()

involves renaming PymatgenTest.(assertArrayAlmostEqual -> assert_all_close)

numpy docs recommend assert_allclose() over assert_almost_equal()
and PymatgenTest.assertArrayAlmostEqual() is just a wrapper for assert_almost_equal()
https://numpy.org/doc/stable/reference/generated/numpy.testing.assert_almost_equal.html
@janosh janosh added tests Issues with or changes to the pymatgen test suite breaking Breaking change labels May 25, 2023
@janosh
Copy link
Member Author

janosh commented May 25, 2023

One thing left to do:

# TODO (janosh): replace assert_array_almost_equal decimal kwarg with assert_allclose() atol and rtol kwargs

@janosh janosh enabled auto-merge (squash) May 25, 2023 19:08
@janosh janosh merged commit 72bd76c into master May 25, 2023
@janosh janosh deleted the class-PymatgenTest-overhaul branch May 25, 2023 19:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking Breaking change tests Issues with or changes to the pymatgen test suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant