Skip to content

Commit

Permalink
Fix testing type annotations.
Browse files Browse the repository at this point in the history
  • Loading branch information
Shyue Ping Ong committed Nov 22, 2022
1 parent 0eb1e3d commit 3d2a5e1
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions pymatgen/util/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def get_mp_structure(cls, mpid: str) -> Structure:
return m.get_structure_by_material_id(mpid)

@staticmethod
def assertArrayAlmostEqual(actual, desired, decimal=7, err_msg="", verbose=True) -> bool:
def assertArrayAlmostEqual(actual, desired, decimal=7, err_msg="", verbose=True):
"""
Tests if two arrays are almost equal to a tolerance. The CamelCase
naming is so that it is consistent with standard unittest methods.
Expand All @@ -96,25 +96,24 @@ def assertDictsAlmostEqual(actual, desired, decimal=7, err_msg="", verbose=True)
if not pass_test:
return False
elif isinstance(v, (list, tuple)):
pass_test = nptu.assert_almost_equal(v, v2, decimal, err_msg, verbose)
if not pass_test:
return False
nptu.assert_almost_equal(v, v2, decimal, err_msg, verbose)
return True
elif isinstance(v, (int, float)):
PymatgenTest().assertAlmostEqual(v, v2) # pylint: disable=E1120
else:
assert v == v2
return True

@staticmethod
def assertArrayEqual(actual, desired, err_msg="", verbose=True) -> bool:
def assertArrayEqual(actual, desired, err_msg="", verbose=True):
"""
Tests if two arrays are equal. The CamelCase naming is so that it is
consistent with standard unittest methods.
"""
return nptu.assert_equal(actual, desired, err_msg=err_msg, verbose=verbose)

@staticmethod
def assertStrContentEqual(actual, desired, err_msg="", verbose=True) -> bool:
def assertStrContentEqual(actual, desired, err_msg="", verbose=True):
"""
Tests if two strings are equal, ignoring things like trailing spaces, etc.
"""
Expand Down

0 comments on commit 3d2a5e1

Please sign in to comment.