Skip to content

Commit 4af0024

Browse files
committed
Fix tests for numpy 1.26
1 parent 0dacf9f commit 4af0024

2 files changed

Lines changed: 21 additions & 5 deletions

File tree

tests/ndarray/test_lazyexpr.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1786,7 +1786,10 @@ def test_lazyexpr_2args():
17861786
["bool", "int32", "int64", "float32", "float64", "complex128"],
17871787
)
17881788
def test_simpleproxy(xp, dtype):
1789-
dtype_ = getattr(xp, dtype) if hasattr(xp, dtype) else np.dtype(dtype)
1789+
try:
1790+
dtype_ = getattr(xp, dtype)
1791+
except AttributeError:
1792+
dtype_ = np.dtype(dtype)
17901793
if dtype == "bool":
17911794
blosc_matrix = blosc2.asarray([True, False, False], dtype=np.dtype(dtype), chunks=(2,))
17921795
foreign_matrix = xp.zeros((3,), dtype=dtype_)

tests/ndarray/test_linalg.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -828,10 +828,13 @@ def test_diagonal(shape, chunkshape, offset):
828828
)
829829
@pytest.mark.parametrize(
830830
"dtype",
831-
["bool", "int32", "int64", "float32", "float64", "complex128"],
831+
["int32", "int64", "float32", "float64", "complex128"],
832832
)
833-
def test_linalgproxy(xp, dtype):
834-
dtype_ = getattr(xp, dtype) if hasattr(xp, dtype) else np.dtype(dtype)
833+
def test_linalgproxy(xp, dtype): # noqa : C901
834+
try:
835+
dtype_ = getattr(xp, dtype)
836+
except AttributeError:
837+
dtype_ = np.dtype(dtype)
835838
for name in linalg_funcs:
836839
if name == "transpose":
837840
continue # deprecated
@@ -853,7 +856,17 @@ def test_linalgproxy(xp, dtype):
853856
# Check this works
854857
argspec = inspect.getfullargspec(func)
855858
num_args = len(argspec.args)
856-
npfunc = blosc2.linalg.nptranspose if name == "permute_dims" else getattr(np, name)
859+
# handle numpy 1.26
860+
if name == "permute_dims":
861+
npfunc = blosc2.linalg.nptranspose
862+
elif name == "concat" and not hasattr(np, "concat"):
863+
npfunc = np.concatenate
864+
elif name == "matrix_transpose":
865+
npfunc = blosc2.linalg.nptranspose
866+
elif name == "vecdot":
867+
npfunc = blosc2.linalg.npvecdot
868+
else:
869+
npfunc = getattr(np, name)
857870
if num_args > 2 or name in ("outer", "matmul"):
858871
try:
859872
lexpr = func(blosc_matrix, foreign_matrix)

0 commit comments

Comments
 (0)