Skip to content

Commit 3deceab

Browse files
committed
[TEST] Added new tests
1 parent 5778167 commit 3deceab

2 files changed

Lines changed: 14 additions & 19 deletions

File tree

src/blosc2/ndarray.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3762,7 +3762,7 @@ def transpose(x, **kwargs: Any) -> NDArray:
37623762
Parameters
37633763
----------
37643764
x: `NDArray`
3765-
The input matrix.
3765+
The input array.
37663766
kwargs: Any, optional
37673767
Keyword arguments that are supported by the :func:`empty` constructor.
37683768
@@ -3776,7 +3776,7 @@ def transpose(x, **kwargs: Any) -> NDArray:
37763776
`numpy.transpose <https://numpy.org/doc/2.2/reference/generated/numpy.transpose.html>`_
37773777
"""
37783778

3779-
# Validate arguments are not scalars
3779+
# If arguments are dimension < 2 they are returned
37803780
if np.isscalar(x) or x.ndim < 2:
37813781
return x
37823782

tests/ndarray/test_transpose.py

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,25 @@
44
import blosc2
55

66

7-
@pytest.mark.parametrize(
8-
("shape", "chunks", "blocks"),
9-
{
7+
@pytest.fixture(
8+
params=[
109
((3, 3), (2, 2), (1, 1)),
1110
((12, 11), (7, 5), (6, 2)),
1211
((1, 5), (1, 4), (1, 3)),
13-
((201, 1903), None, None),
12+
((51, 603), (22, 99), (13, 29)),
1413
((10,), (5,), None),
15-
},
14+
]
1615
)
16+
def shape_chunks_blocks(request):
17+
return request.param
18+
19+
1720
@pytest.mark.parametrize(
1821
"dtype",
1922
{np.int32, np.int64, np.float32, np.float64},
2023
)
21-
def test_transpose(shape, chunks, blocks, dtype):
24+
def test_transpose(shape_chunks_blocks, dtype):
25+
shape, chunks, blocks = shape_chunks_blocks
2226
a = blosc2.linspace(0, 1, shape=shape, chunks=chunks, blocks=blocks, dtype=dtype)
2327
at = blosc2.transpose(a)
2428

@@ -28,21 +32,12 @@ def test_transpose(shape, chunks, blocks, dtype):
2832
np.testing.assert_allclose(at, nat)
2933

3034

31-
@pytest.mark.parametrize(
32-
("shape", "chunks", "blocks"),
33-
{
34-
((3, 3), (2, 2), (1, 1)),
35-
((12, 11), (7, 5), (6, 2)),
36-
((1, 5), (1, 4), (1, 3)),
37-
((201, 1903), None, None),
38-
((10,), (5,), None),
39-
},
40-
)
4135
@pytest.mark.parametrize(
4236
"dtype",
4337
{np.complex64, np.complex128},
4438
)
45-
def test_complex(shape, chunks, blocks, dtype):
39+
def test_complex(shape_chunks_blocks, dtype):
40+
shape, chunks, blocks = shape_chunks_blocks
4641
real_part = blosc2.linspace(0, 1, shape=shape, chunks=chunks, blocks=blocks, dtype=dtype)
4742
imag_part = blosc2.linspace(0, 1, shape=shape, chunks=chunks, blocks=blocks, dtype=dtype)
4843
complex_matrix = real_part + 1j * imag_part

0 commit comments

Comments
 (0)