Skip to content

Commit 5e27651

Browse files
committed
[TEST] New test for urlpaths.
1 parent 1354fff commit 5e27651

1 file changed

Lines changed: 27 additions & 12 deletions

File tree

tests/ndarray/test_matmul.py

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@
2626
def test_matmul(ashape, achunks, ablocks, bshape, bchunks, bblocks, dtype):
2727
a = blosc2.linspace(0, 10, dtype=dtype, shape=ashape, chunks=achunks, blocks=ablocks)
2828
b = blosc2.linspace(0, 10, dtype=dtype, shape=bshape, chunks=bchunks, blocks=bblocks)
29-
blosc2_res = blosc2.matmul(a, b)
29+
c = blosc2.matmul(a, b)
3030

3131
na = a[:]
3232
nb = b[:]
33-
np_res = np.matmul(na, nb)
33+
nc = np.matmul(na, nb)
3434

35-
np.testing.assert_allclose(blosc2_res, np_res, rtol=1e-6)
35+
np.testing.assert_allclose(c, nc, rtol=1e-6)
3636

3737

3838
@pytest.mark.parametrize(
@@ -51,7 +51,7 @@ def test_matmul(ashape, achunks, ablocks, bshape, bchunks, bblocks, dtype):
5151
((5,), (4,), (2,)),
5252
},
5353
)
54-
def test_matmul_shapes(ashape, achunks, ablocks, bshape, bchunks, bblocks):
54+
def test_shapes(ashape, achunks, ablocks, bshape, bchunks, bblocks):
5555
a = blosc2.linspace(0, 10, shape=ashape, chunks=achunks, blocks=ablocks)
5656
b = blosc2.linspace(0, 10, shape=bshape, chunks=bchunks, blocks=bblocks)
5757

@@ -76,7 +76,7 @@ def test_matmul_shapes(ashape, achunks, ablocks, bshape, bchunks, bblocks):
7676
np.complex128(1 + 2j), # NumPy complex128
7777
},
7878
)
79-
def test_matmul_scalars(scalar):
79+
def test_scalars(scalar):
8080
vector = blosc2.asarray(np.array([1, 2, 3]))
8181

8282
with pytest.raises(ValueError):
@@ -93,18 +93,17 @@ def test_matmul_scalars(scalar):
9393
"ashape",
9494
[
9595
(12, 10, 10),
96-
(7, 5, 5),
9796
(3, 3, 3),
9897
],
9998
)
10099
@pytest.mark.parametrize(
101100
"bshape",
102101
[
103102
(10, 10, 10, 11),
104-
(3, 2, 9),
103+
(3, 2),
105104
],
106105
)
107-
def test_matmul_dims(ashape, bshape):
106+
def test_dims(ashape, bshape):
108107
a = blosc2.linspace(0, 10, shape=ashape)
109108
b = blosc2.linspace(0, 1, shape=bshape)
110109

@@ -130,13 +129,29 @@ def test_matmul_dims(ashape, bshape):
130129
((10, 12), (2, 4), (1, 2), np.complex128),
131130
},
132131
)
133-
def test_matmul_especial_cases(ashape, achunks, ablocks, adtype, bshape, bchunks, bblocks, bdtype):
132+
def test_special_cases(ashape, achunks, ablocks, adtype, bshape, bchunks, bblocks, bdtype):
134133
a = blosc2.linspace(0, 10, dtype=adtype, shape=ashape, chunks=achunks, blocks=ablocks)
135134
b = blosc2.linspace(0, 10, dtype=bdtype, shape=bshape, chunks=bchunks, blocks=bblocks)
136-
blosc2_res = blosc2.matmul(a, b)
135+
c = blosc2.matmul(a, b)
137136

138137
na = a[:]
139138
nb = b[:]
140-
np_res = np.matmul(na, nb)
139+
nc = np.matmul(na, nb)
141140

142-
np.testing.assert_allclose(blosc2_res, np_res, rtol=1e-6)
141+
np.testing.assert_allclose(c, nc, rtol=1e-6)
142+
143+
144+
def test_disk():
145+
a = blosc2.linspace(0, 1, shape=(3, 4), urlpath="a_test.b2nd", mode="w")
146+
b = blosc2.linspace(0, 1, shape=(4, 2), urlpath="b_test.b2nd", mode="w")
147+
c = blosc2.matmul(a, b, urlpath="c_test.b2nd", mode="w")
148+
149+
na = a[:]
150+
nb = b[:]
151+
nc = np.matmul(na, nb)
152+
153+
np.testing.assert_allclose(c, nc, rtol=1e-6)
154+
155+
blosc2.remove_urlpath("a_test.b2nd")
156+
blosc2.remove_urlpath("b_test.b2nd")
157+
blosc2.remove_urlpath("c_test.b2nd")

0 commit comments

Comments
 (0)