Skip to content

Commit

Permalink
fixing numerical round off errors in test
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanGilardoni committed Nov 28, 2024
1 parent fa4ec90 commit aae8a82
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tests/test_loss_and_minimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ def assertEqualObjs(self, obj1, obj2):

if isinstance(obj1, np.ndarray) or isinstance(obj1, jnp.ndarray):
if obj1.shape == (1,): obj1 = obj1[0]
elif obj1.shape == (): obj1 = np.array([obj1])[0]
if isinstance(obj2, np.ndarray) or isinstance(obj2, jnp.ndarray):
if obj2.shape == (1,): obj2 = obj2[0]
elif obj2.shape == (): obj2 = np.array([obj2])[0]

if isinstance(obj1, dict) and isinstance(obj2, dict):
self.assertSetEqual(set(obj1.keys()), set(obj2.keys()))
Expand Down
2 changes: 2 additions & 0 deletions tests/test_mdrefinement.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ def assertEqualObjs(self, obj1, obj2, tol = 1e-4, if_relative = False):

if isinstance(obj1, np.ndarray) or isinstance(obj1, jnp.ndarray):
if obj1.shape == (1,): obj1 = obj1[0]
elif obj1.shape == (): obj1 = np.array([obj1])[0]
if isinstance(obj2, np.ndarray) or isinstance(obj2, jnp.ndarray):
if obj2.shape == (1,): obj2 = obj2[0]
elif obj2.shape == (): obj2 = np.array([obj2])[0]

if isinstance(obj1, dict) and isinstance(obj2, dict):
self.assertSetEqual(set(obj1.keys()), set(obj2.keys()))
Expand Down

0 comments on commit aae8a82

Please sign in to comment.