Skip to content

Commit

Permalink
TestCase's assertAllClose and assertAlmostEqual now report the …
Browse files Browse the repository at this point in the history
…provided error message. (keras-team#20248)
  • Loading branch information
hertschuh committed Sep 11, 2024
1 parent b91dade commit a23c2bb
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions keras/src/testing/test_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def assertAllClose(self, x1, x2, atol=1e-6, rtol=1e-6, msg=None):
x1 = backend.convert_to_numpy(x1)
if not isinstance(x2, np.ndarray):
x2 = backend.convert_to_numpy(x2)
np.testing.assert_allclose(x1, x2, atol=atol, rtol=rtol)
np.testing.assert_allclose(x1, x2, atol=atol, rtol=rtol, err_msg=msg)

def assertNotAllClose(self, x1, x2, atol=1e-6, rtol=1e-6, msg=None):
try:
Expand All @@ -62,7 +62,7 @@ def assertAlmostEqual(self, x1, x2, decimal=3, msg=None):
x1 = backend.convert_to_numpy(x1)
if not isinstance(x2, np.ndarray):
x2 = backend.convert_to_numpy(x2)
np.testing.assert_almost_equal(x1, x2, decimal=decimal)
np.testing.assert_almost_equal(x1, x2, decimal=decimal, err_msg=msg)

def assertAllEqual(self, x1, x2, msg=None):
self.assertEqual(len(x1), len(x2), msg=msg)
Expand Down

0 comments on commit a23c2bb

Please sign in to comment.