Skip to content

Commit

Permalink
Add comments & fix formatting.
Browse files Browse the repository at this point in the history
  • Loading branch information
truth-quark committed Oct 8, 2024
1 parent 4b9f06b commit 951e03d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion test/test_um2netcdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -1071,6 +1071,7 @@ def test_fix_pressure_levels_reverse_pressure():
# NB: skip float64 to float32 overflow as float32 min/max is huge: -/+ 3.40e+38

def test_convert_32_bit_safe(ua_plev_cube):
# simple baseline test of down conversion int64 to int32 without warnings
data = [1e6, 200, 100, 10, 1, 0, -10]
ua_plev_cube.data = np.array(data, dtype=np.int64)
um2nc.convert_32_bit(ua_plev_cube)
Expand All @@ -1082,13 +1083,15 @@ def test_convert_32_bit_safe(ua_plev_cube):
[([3000000000], operator.gt, np.iinfo(np.int32).max),
([-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
ua_plev_cube.data = np.array(array, dtype=np.int64)

with pytest.warns(RuntimeWarning) as record:
um2nc.convert_32_bit(ua_plev_cube)

if not record:
pytest.fail(f"No overflow warning emitted with {array} {_operator} {bound}")
msg = f"No overflow warning with {array} {_operator} {bound}"
pytest.fail(msg)

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

0 comments on commit 951e03d

Please sign in to comment.