|
1 | 1 | import numpy as np |
| 2 | +import pytest |
2 | 3 |
|
3 | 4 | import autocti as ac |
| 5 | +from autocti import exc |
4 | 6 |
|
5 | 7 |
|
6 | 8 | 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 |
61 | 63 | assert (array_2d_list[0] == np.array([[5.0], [5.0], [5.0]])).all() |
62 | 64 | assert (array_2d_list[1] == np.array([[9.0], [9.0], [9.0]])).all() |
63 | 65 |
|
64 | | - array_2d_list = extract.array_2d_list_from( |
65 | | - array=serial_array, settings=ac.SettingsExtract(pixels=(2, 3)) |
66 | | - ) |
67 | | - |
68 | | - assert (array_2d_list[0] == np.array([[6.0], [6.0], [6.0]])).all() |
69 | | - assert (array_2d_list[1] == np.array([[10.0], [10.0], [10.0]])).all() |
| 66 | + # `pixels=(2, 3)` asks for the third column of each trailing region. For the |
| 67 | + # second region (its trailing region starts at column 8) that is columns |
| 68 | + # 10-11 of a 10-column array: a window entirely past the edge, which extracts |
| 69 | + # to a zero-width (3, 0) structure. PyAutoArray rejects that outright, so the |
| 70 | + # whole call raises rather than returning an empty extraction. |
| 71 | + # |
| 72 | + # This case previously asserted `array_2d_list[1] == [[10.0], [10.0], [10.0]]` |
| 73 | + # and "passed" while checking nothing: comparing an empty array against |
| 74 | + # anything is vacuously True, and 10.0 is not a value this fixture even |
| 75 | + # contains. The behaviour is pinned here instead of left silent. |
| 76 | + # |
| 77 | + # A *partially* overlapping window still clips rather than raising — the |
| 78 | + # `pixels=(0, 3)` case below asserts exactly that for the same region. |
| 79 | + with pytest.raises(exc.MaskException): |
| 80 | + extract.array_2d_list_from( |
| 81 | + array=serial_array, settings=ac.SettingsExtract(pixels=(2, 3)) |
| 82 | + ) |
70 | 83 |
|
71 | 84 | array_2d_list = extract.array_2d_list_from( |
72 | 85 | array=serial_array, settings=ac.SettingsExtract(pixels=(0, 3)) |
|
0 commit comments