Skip to content

Breaking: Overhaul class PymatgenTest#3014

Merged
janosh merged 8 commits into
masterfrom
class-PymatgenTest-overhaul
May 25, 2023
Merged

Breaking: Overhaul class PymatgenTest#3014
janosh merged 8 commits into
masterfrom
class-PymatgenTest-overhaul

Conversation

@janosh

@janosh janosh commented May 25, 2023

Copy link
Copy Markdown
Member

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

janosh commented May 25, 2023

Copy link
Copy Markdown
Member Author

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