Skip to content

Commit

Permalink
tests: Fix tests that relied on NumPy 1.x integer promotion (#601)
Browse files Browse the repository at this point in the history
  • Loading branch information
bkeryan authored Jun 18, 2024
1 parent 4917248 commit a624cba
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions tests/component/test_stream_readers_ai.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit a624cba

Please sign in to comment.