Skip to content

Commit

Permalink
Refactor 32 bit overflow testing.
Browse files Browse the repository at this point in the history
  • Loading branch information
truth-quark committed Oct 8, 2024
1 parent 951e03d commit 08bbca4
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions test/test_um2netcdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -1084,6 +1084,9 @@ def test_convert_32_bit_safe(ua_plev_cube):
([-3000000000], operator.lt, np.iinfo(np.int32).min)])
def test_convert_32_bit_overflow_warning(ua_plev_cube, array, _operator, bound):
# ensure overflow covered for large positive & negative int64s
msg = f"Over/underflow impossible with {array[0]} {_operator} {bound}"
assert _operator(array[0], bound), msg

ua_plev_cube.data = np.array(array, dtype=np.int64)

with pytest.warns(RuntimeWarning) as record:
Expand All @@ -1093,9 +1096,6 @@ def test_convert_32_bit_overflow_warning(ua_plev_cube, array, _operator, bound):
msg = f"No overflow warning with {array} {_operator} {bound}"
pytest.fail(msg)

if _operator:
assert _operator(array[0], bound)

assert ua_plev_cube.data.dtype == np.int32


Expand Down

0 comments on commit 08bbca4

Please sign in to comment.