From a624cba5de47be8c4c0d579adee6ca978dbaf3da Mon Sep 17 00:00:00 2001 From: Brad Keryan Date: Tue, 18 Jun 2024 11:57:27 -0500 Subject: [PATCH] tests: Fix tests that relied on NumPy 1.x integer promotion (#601) --- tests/component/test_stream_readers_ai.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/component/test_stream_readers_ai.py b/tests/component/test_stream_readers_ai.py index 275b1f40c..682cd24a7 100644 --- a/tests/component/test_stream_readers_ai.py +++ b/tests/component/test_stream_readers_ai.py @@ -212,7 +212,8 @@ def test___analog_unscaled_reader___read_uint16___returns_valid_samples( expected_vals = [ _get_voltage_code_offset_for_chan(chan_index) for chan_index in range(num_channels) ] - assert data == pytest.approx(expected_vals, abs=VOLTAGE_CODE_EPSILON) + # Promote to larger signed type to avoid overflow w/NumPy 2.0+. + assert data.astype(numpy.int32) == pytest.approx(expected_vals, abs=VOLTAGE_CODE_EPSILON) def test___analog_unscaled_reader___read_uint16___raises_error_with_correct_dtype( @@ -278,7 +279,8 @@ def test___analog_unscaled_reader___read_uint32___returns_valid_samples( expected_vals = [ _get_voltage_code_offset_for_chan(chan_index) for chan_index in range(num_channels) ] - assert data == pytest.approx(expected_vals, abs=VOLTAGE_CODE_EPSILON) + # Promote to larger signed type to avoid overflow w/NumPy 2.0+. + assert data.astype(numpy.int64) == pytest.approx(expected_vals, abs=VOLTAGE_CODE_EPSILON) def test___analog_unscaled_reader___read_uint32___raises_error_with_correct_dtype(