|
83 | 83 | OUT_ORNTS = [np.array(ornt) for ornt in OUT_ORNTS]
|
84 | 84 |
|
85 | 85 |
|
| 86 | +_LABELS = ['RL', 'AP', 'SI'] |
| 87 | +ALL_AXCODES = [(_LABELS[i0][j0], _LABELS[i1][j1], _LABELS[i2][j2]) |
| 88 | + for i0 in range(3) for i1 in range(3) for i2 in range(3) |
| 89 | + if i0 != i1 != i2 != i0 |
| 90 | + for j0 in range(2) for j1 in range(2) for j2 in range(2)] |
| 91 | + |
| 92 | +ALL_ORNTS = [[[i0, j0], [i1, j1], [i2, j2]] |
| 93 | + for i0 in range(3) for i1 in range(3) for i2 in range(3) |
| 94 | + if i0 != i1 != i2 != i0 |
| 95 | + for j0 in [1, -1] for j1 in [1, -1] for j2 in [1, -1]] |
| 96 | + |
| 97 | + |
86 | 98 | def same_transform(taff, ornt, shape):
|
87 | 99 | # Applying transformations implied by `ornt` to a made-up array
|
88 | 100 | # ``arr`` of shape `shape`, results in ``t_arr``. When the point
|
@@ -125,6 +137,10 @@ def test_apply():
|
125 | 137 | apply_orientation,
|
126 | 138 | a,
|
127 | 139 | [[0, 1], [np.nan, np.nan], [2, 1]])
|
| 140 | + shape = np.array(a.shape) |
| 141 | + for ornt in ALL_ORNTS: |
| 142 | + t_arr = apply_orientation(a, ornt) |
| 143 | + assert_array_equal(a.shape, np.array(t_arr.shape)[np.array(ornt)[:, 0]]) |
128 | 144 |
|
129 | 145 |
|
130 | 146 | def test_flip_axis():
|
@@ -282,6 +298,9 @@ def test_ornt2axcodes():
|
282 | 298 | # As do directions not in range
|
283 | 299 | assert_raises(ValueError, ornt2axcodes, [[0, 0]])
|
284 | 300 |
|
| 301 | + for axcodes, ornt in zip(ALL_AXCODES, ALL_ORNTS): |
| 302 | + assert_equal(ornt2axcodes(ornt), axcodes) |
| 303 | + |
285 | 304 |
|
286 | 305 | def test_axcodes2ornt():
|
287 | 306 | # Go from axcodes back to orientations
|
@@ -340,6 +359,9 @@ def test_axcodes2ornt():
|
340 | 359 | assert_raises(ValueError, axcodes2ornt, 'blD', ('SD', 'BF', 'lD'))
|
341 | 360 | assert_raises(ValueError, axcodes2ornt, 'blD', ('SD', 'SF', 'lD'))
|
342 | 361 |
|
| 362 | + for axcodes, ornt in zip(ALL_AXCODES, ALL_ORNTS): |
| 363 | + assert_array_equal(axcodes2ornt(axcodes), ornt) |
| 364 | + |
343 | 365 |
|
344 | 366 | def test_aff2axcodes():
|
345 | 367 | assert_equal(aff2axcodes(np.eye(4)), tuple('RAS'))
|
|
0 commit comments