Skip to content

Commit

Permalink
Fix backed-sparse tests
Browse files Browse the repository at this point in the history
  • Loading branch information
flying-sheep committed Dec 19, 2024
1 parent 775bc0e commit 08b2b23
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions tests/test_backed_sparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -32,7 +34,6 @@

Idx = slice | int | NDArray[np.integer] | NDArray[np.bool_]


subset_func2 = subset_func


Expand Down Expand Up @@ -615,17 +616,28 @@ 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",
[
pytest.param(lambda _: zarr.group(), id="zarr"),
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))
Expand Down

0 comments on commit 08b2b23

Please sign in to comment.