From 37ffb7438d734f98ab85d0380ee4a9103b05499d Mon Sep 17 00:00:00 2001 From: James Nightingale Date: Sun, 23 Aug 2026 22:39:01 +0000 Subject: [PATCH] fix(test): replace a vacuous serial-EPER assertion that now fails on main MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `test__region_list_from__array_2d_list_from` fails on main across all three legs: autoarray.exc.MaskException: shape_native[1] must be a positive number of pixels; got 0. The full shape_native input was (3, 0) lib-tests.yml clones PyAutoArray main, and PyAutoArray#440 (f2f7a4f, 2026-08-09) added the zero-length shape_native guard to Mask2D.__init__. This repo's last main run was 2026-08-07, so the break sat dormant until the next push. The guard did not break a working test — it exposed one that never checked anything. `serial_array` is 3x10 (columns 0-9). For region (0, 3, 5, 8), `pixels=(2, 3)` resolves to columns 10-11: a window entirely past the edge, extracting to a zero-width (3, 0) structure. The assertion it fed was assert (array_2d_list[1] == np.array([[10.0], [10.0], [10.0]])).all() and an empty-array comparison is vacuously True for ANY expected value (confirmed: `(np.zeros((3,0)) == [[10.],[10.],[10.]]).all()` is True, and so is the same comparison against 999.0). 10.0 is not even a value the fixture contains. The case now asserts what actually happens — a fully out-of-range window raises — so the edge case stays covered instead of silently passing. A partially overlapping window still clips, which the `pixels=(0, 3)` case immediately below already asserts. Test-only: no library behaviour is changed, and nothing here decides whether a fully out-of-range window SHOULD raise or should clip to empty. That question is left open deliberately. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01Q7kFdoYcD6wnTifNXV5T98 --- .../extract/two_d/serial/test_serial_eper.py | 25 ++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) 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))