diff --git a/test_autocti/extract/two_d/serial/test_serial_eper.py b/test_autocti/extract/two_d/serial/test_serial_eper.py index aa82999c..790a24cd 100644 --- a/test_autocti/extract/two_d/serial/test_serial_eper.py +++ b/test_autocti/extract/two_d/serial/test_serial_eper.py @@ -1,6 +1,8 @@ import numpy as np +import pytest import autocti as ac +from autocti import exc def test__region_list_from__array_2d_list_from(serial_array, serial_masked_array): @@ -61,12 +63,23 @@ def test__region_list_from__array_2d_list_from(serial_array, serial_masked_array assert (array_2d_list[0] == np.array([[5.0], [5.0], [5.0]])).all() assert (array_2d_list[1] == np.array([[9.0], [9.0], [9.0]])).all() - array_2d_list = extract.array_2d_list_from( - array=serial_array, settings=ac.SettingsExtract(pixels=(2, 3)) - ) - - assert (array_2d_list[0] == np.array([[6.0], [6.0], [6.0]])).all() - assert (array_2d_list[1] == np.array([[10.0], [10.0], [10.0]])).all() + # `pixels=(2, 3)` asks for the third column of each trailing region. For the + # second region (its trailing region starts at column 8) that is columns + # 10-11 of a 10-column array: a window entirely past the edge, which extracts + # to a zero-width (3, 0) structure. PyAutoArray rejects that outright, so the + # whole call raises rather than returning an empty extraction. + # + # This case previously asserted `array_2d_list[1] == [[10.0], [10.0], [10.0]]` + # and "passed" while checking nothing: comparing an empty array against + # anything is vacuously True, and 10.0 is not a value this fixture even + # contains. The behaviour is pinned here instead of left silent. + # + # A *partially* overlapping window still clips rather than raising — the + # `pixels=(0, 3)` case below asserts exactly that for the same region. + with pytest.raises(exc.MaskException): + extract.array_2d_list_from( + array=serial_array, settings=ac.SettingsExtract(pixels=(2, 3)) + ) array_2d_list = extract.array_2d_list_from( array=serial_array, settings=ac.SettingsExtract(pixels=(0, 3))