Skip to content

Commit

Permalink
Tests: use NumPy to validate lists too; increase precision to 9 decim…
Browse files Browse the repository at this point in the history
…als.
  • Loading branch information
PMeira committed Dec 13, 2023
1 parent a9c9105 commit 18957cb
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions tests/test_opendssdirect.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,11 @@ def _assert_dict_equal(d1, d2, outer_key=None):
v2 = d2[key]
if isinstance(v1, dict):
_assert_dict_equal_lkeys(v1, v2, outer_key=key)
elif isinstance(v1, np.ndarray):
np.testing.assert_array_almost_equal(v1, v2, err_msg=f'{outer_key}.{key}')
elif isinstance(v1, np.ndarray) or (
isinstance(v1, (list, tuple)) and
(len(v1) > 0) and isinstance(v1[0], (float, int))
):
np.testing.assert_array_almost_equal(v1, v2, decimal=9, err_msg=f'{outer_key}.{key}')
else:
assert (v1 == v2), (outer_key, key, v1, v2)

Expand Down

0 comments on commit 18957cb

Please sign in to comment.