From 08b2b2357a1baff5eea4935a30242b4ab296f721 Mon Sep 17 00:00:00 2001 From: Phil Schaf Date: Thu, 19 Dec 2024 13:56:33 +0100 Subject: [PATCH] Fix backed-sparse tests --- tests/test_backed_sparse.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/tests/test_backed_sparse.py b/tests/test_backed_sparse.py index 03155d0a3..069a4cd3d 100644 --- a/tests/test_backed_sparse.py +++ b/tests/test_backed_sparse.py @@ -7,7 +7,9 @@ import h5py import numpy as np import pytest +import scipy import zarr +from packaging.version import Version from scipy import sparse import anndata as ad @@ -32,7 +34,6 @@ Idx = slice | int | NDArray[np.integer] | NDArray[np.bool_] - subset_func2 = subset_func @@ -615,6 +616,13 @@ def test_backed_sizeof( assert csr_mem.__sizeof__() > csc_disk.__sizeof__() +sparray_scipy_bug_marks = ( + [pytest.mark.xfail(reason="scipy bug causes view to be allocated")] + if CAN_USE_SPARSE_ARRAY and Version(scipy.__version__) < Version("1.4.1") + else [] +) + + @pytest.mark.parametrize( "group_fn", [ @@ -622,10 +630,14 @@ def test_backed_sizeof( pytest.param(lambda p: h5py.File(p / "test.h5", mode="a"), id="h5py"), ], ) -@pytest.mark.parametrize("sparse_class", [sparse.csr_matrix, sparse.csr_array]) +@pytest.mark.parametrize( + "sparse_class", + [ + sparse.csr_matrix, + pytest.param(sparse.csr_array, marks=[*sparray_scipy_bug_marks]), + ], +) def test_append_overflow_check(group_fn, sparse_class, tmpdir): - if CAN_USE_SPARSE_ARRAY and issubclass(sparse_class, SpArray): - pytest.skip("scipy bug causes view to be allocated") group = group_fn(tmpdir) typemax_int32 = np.iinfo(np.int32).max orig_mtx = sparse_class(np.ones((1, 1), dtype=bool))