You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We use a lot of dicts and these often need to compared via assert in the unit tests. These comparisons should be almost equal as there will be small changes to float values due to reading/writing to/from file. This should be handled by pytest.approx but we also have nan values which seem to make this function fail.
I have written some code to compare key values directly, I should probably wrap this in a function for neatness:
from numpy.testing import assert_almost_equal
for x in test_dict.keys():
test_val = test_dict[x]
expect_val = expect_dict[x]
if type(expect_val) == str:
assert test_val == expect_val
else:
assert_almost_equal(test_val, expect_val)
The text was updated successfully, but these errors were encountered:
We use a lot of dicts and these often need to compared via assert in the unit tests. These comparisons should be almost equal as there will be small changes to float values due to reading/writing to/from file. This should be handled by
pytest.approx
but we also have nan values which seem to make this function fail.I have written some code to compare key values directly, I should probably wrap this in a function for neatness:
The text was updated successfully, but these errors were encountered: