Skip to content

Commit e06f954

Browse files
committed
[TEST] Better examples and names.
1 parent fa63ec3 commit e06f954

File tree

1 file changed

+27
-32
lines changed

1 file changed

+27
-32
lines changed

tests/ndarray/test_transpose.py

Lines changed: 27 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -22,43 +22,44 @@ def dtype_fixture(request):
2222
params=[
2323
((10,), (5,), None),
2424
((31,), (14,), (9,)),
25+
((9,), (4,), (3,)),
2526
]
2627
)
27-
def shape_1d_chunks_blocks(request):
28+
def shape_chunks_blocks_1d(request):
2829
return request.param
2930

3031

3132
@pytest.fixture(
3233
params=[
33-
((3, 3), (2, 2), (1, 1)),
34+
((4, 4), (3, 3), (2, 2)),
3435
((12, 11), (7, 5), (6, 2)),
35-
((1, 5), (1, 4), (1, 3)),
36+
((6, 5), (5, 4), (4, 3)),
3637
pytest.param(((51, 603), (22, 99), (13, 29)), marks=pytest.mark.heavy),
3738
]
3839
)
39-
def shape_2d_chunks_blocks(request):
40+
def shape_chunks_blocks_2d(request):
4041
return request.param
4142

4243

4344
@pytest.fixture(
4445
params=[
4546
((4, 5, 2), (3, 4, 2), (3, 2, 1)),
4647
((12, 10, 10), (11, 9, 7), (9, 7, 3)),
47-
pytest.param(((37, 63, 55), (12, 5, 41), (10, 5, 11)), marks=pytest.mark.heavy),
48+
pytest.param(((37, 63, 55), (12, 30, 41), (10, 5, 11)), marks=pytest.mark.heavy),
4849
]
4950
)
50-
def shape_3d_chunks_blocks(request):
51+
def shape_chunks_blocks_3d(request):
5152
return request.param
5253

5354

5455
@pytest.fixture(
5556
params=[
56-
((3, 3, 5, 7), (2, 3, 2, 4), (1, 1, 1, 4)),
57+
((3, 3, 5, 7), (2, 3, 2, 4), (1, 2, 1, 4)),
5758
((4, 6, 5, 2), (3, 3, 4, 2), (3, 2, 2, 1)),
5859
pytest.param(((10, 10, 10, 11), (7, 8, 9, 11), (6, 7, 8, 5)), marks=pytest.mark.heavy),
5960
]
6061
)
61-
def shape_4d_chunks_blocks(request):
62+
def shape_chunks_blocks_4d(request):
6263
return request.param
6364

6465

@@ -79,14 +80,13 @@ def shape_4d_chunks_blocks(request):
7980
},
8081
)
8182
def test_scalars(scalar):
82-
at = blosc2.permute_dims(scalar)
83-
nat = np.transpose(scalar)
84-
85-
np.testing.assert_allclose(at, nat)
83+
scalar_t = blosc2.permute_dims(scalar)
84+
np_scalar_t = np.transpose(scalar)
85+
np.testing.assert_allclose(scalar_t, np_scalar_t)
8686

8787

88-
def test_1d_transpose(shape_1d_chunks_blocks, dtype_fixture):
89-
shape, chunks, blocks = shape_1d_chunks_blocks
88+
def test_1d_permute_dims(shape_chunks_blocks_1d, dtype_fixture):
89+
shape, chunks, blocks = shape_chunks_blocks_1d
9090
a = blosc2.linspace(0, 1, shape=shape, chunks=chunks, blocks=blocks, dtype=dtype_fixture)
9191
at = blosc2.permute_dims(a)
9292

@@ -100,8 +100,8 @@ def test_1d_transpose(shape_1d_chunks_blocks, dtype_fixture):
100100
"axes",
101101
list(permutations([0, 1])),
102102
)
103-
def test_2d_transpose(shape_2d_chunks_blocks, dtype_fixture, axes):
104-
shape, chunks, blocks = shape_2d_chunks_blocks
103+
def test_2d_permute_dims(shape_chunks_blocks_2d, dtype_fixture, axes):
104+
shape, chunks, blocks = shape_chunks_blocks_2d
105105
a = blosc2.linspace(0, 1, shape=shape, chunks=chunks, blocks=blocks, dtype=dtype_fixture)
106106
at = blosc2.permute_dims(a, axes=axes)
107107

@@ -115,8 +115,8 @@ def test_2d_transpose(shape_2d_chunks_blocks, dtype_fixture, axes):
115115
"axes",
116116
list(permutations([0, 1, 2])),
117117
)
118-
def test_3d_transpose(shape_3d_chunks_blocks, dtype_fixture, axes):
119-
shape, chunks, blocks = shape_3d_chunks_blocks
118+
def test_3d_permute_dims(shape_chunks_blocks_3d, dtype_fixture, axes):
119+
shape, chunks, blocks = shape_chunks_blocks_3d
120120
a = blosc2.linspace(0, 1, shape=shape, chunks=chunks, blocks=blocks, dtype=dtype_fixture)
121121
at = blosc2.permute_dims(a, axes=axes)
122122

@@ -130,8 +130,8 @@ def test_3d_transpose(shape_3d_chunks_blocks, dtype_fixture, axes):
130130
"axes",
131131
list(permutations([0, 1, 2, 3])),
132132
)
133-
def test_4d_transpose(shape_4d_chunks_blocks, dtype_fixture, axes):
134-
shape, chunks, blocks = shape_4d_chunks_blocks
133+
def test_4d_permute_dims(shape_chunks_blocks_4d, dtype_fixture, axes):
134+
shape, chunks, blocks = shape_chunks_blocks_4d
135135
a = blosc2.linspace(0, 1, shape=shape, chunks=chunks, blocks=blocks, dtype=dtype_fixture)
136136
at = blosc2.permute_dims(a, axes=axes)
137137

@@ -150,8 +150,8 @@ def test_4d_transpose(shape_4d_chunks_blocks, dtype_fixture, axes):
150150
"dtype",
151151
{np.complex64, np.complex128},
152152
)
153-
def test_complex(shape_3d_chunks_blocks, dtype, axes):
154-
shape, chunks, blocks = shape_3d_chunks_blocks
153+
def test_complex(shape_chunks_blocks_3d, dtype, axes):
154+
shape, chunks, blocks = shape_chunks_blocks_3d
155155
real_part = blosc2.linspace(0, 1, shape=shape, chunks=chunks, blocks=blocks, dtype=dtype)
156156
imag_part = blosc2.linspace(1, 0, shape=shape, chunks=chunks, blocks=blocks, dtype=dtype)
157157
complex_matrix = real_part + 3j * imag_part
@@ -176,8 +176,8 @@ def test_complex(shape_3d_chunks_blocks, dtype, axes):
176176
(0, -4, 1),
177177
],
178178
)
179-
def test_invalid_axes_raises(shape_3d_chunks_blocks, axes):
180-
shape, chunks, blocks = shape_3d_chunks_blocks
179+
def test_invalid_axes_raises(shape_chunks_blocks_3d, axes):
180+
shape, chunks, blocks = shape_chunks_blocks_3d
181181
a = blosc2.linspace(0, 1, shape=shape, chunks=chunks, blocks=blocks)
182182

183183
with pytest.raises(ValueError, match="not a valid permutation"):
@@ -186,11 +186,7 @@ def test_invalid_axes_raises(shape_3d_chunks_blocks, axes):
186186

187187
@pytest.mark.parametrize(
188188
"shape",
189-
[
190-
(2, 3),
191-
(4, 5, 6),
192-
(2, 4, 8, 5),
193-
],
189+
[(2, 3), (4, 5, 6), (2, 4, 8, 5), (7, 3, 9, 9, 5)],
194190
)
195191
def test_matrix_transpose(shape):
196192
arr = blosc2.linspace(0, 1, shape=shape)
@@ -223,13 +219,12 @@ def test_disk():
223219
nc = np.transpose(na)
224220

225221
np.testing.assert_allclose(c, nc, rtol=1e-6)
226-
227222
blosc2.remove_urlpath("a_test.b2nd")
228223
blosc2.remove_urlpath("c_test.b2nd")
229224

230225

231-
def test_transpose(shape_2d_chunks_blocks, dtype_fixture):
232-
shape, chunks, blocks = shape_2d_chunks_blocks
226+
def test_transpose(shape_chunks_blocks_2d, dtype_fixture):
227+
shape, chunks, blocks = shape_chunks_blocks_2d
233228
a = blosc2.linspace(0, 1, shape=shape, chunks=chunks, blocks=blocks, dtype=dtype_fixture)
234229
with pytest.warns(DeprecationWarning):
235230
at = blosc2.transpose(a)

0 commit comments

Comments
 (0)