Skip to content

Commit

Permalink
(chore): split ellipsis index
Browse files Browse the repository at this point in the history
  • Loading branch information
ilan-gold committed Oct 25, 2024
1 parent 8edffaf commit 6aff0f2
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 8 deletions.
22 changes: 21 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,30 @@ def backing_h5ad(tmp_path):
),
]
)
def ellipsis_index_with_equivalent(request) -> tuple[EllipsisType | slice]:
def ellipsis_index_with_equivalent(
request,
) -> tuple[tuple[EllipsisType | slice], tuple[slice, slice]]:
return request.param


@pytest.fixture
def ellipsis_index(
ellipsis_index_with_equivalent: tuple[
tuple[EllipsisType | slice], tuple[slice, slice]
],
) -> tuple[EllipsisType | slice]:
return ellipsis_index_with_equivalent[0]


@pytest.fixture
def equivalent_ellipsis_index(
ellipsis_index_with_equivalent: tuple[
tuple[EllipsisType | slice], tuple[slice, slice]
],
) -> tuple[slice, slice]:
return ellipsis_index_with_equivalent[1]


#####################
# Dask tokenization #
#####################
Expand Down
8 changes: 4 additions & 4 deletions tests/test_backed_sparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,13 @@ def test_backed_indexing(

def test_backed_ellipsis_indexing(
ondisk_equivalent_adata: tuple[AnnData, AnnData, AnnData, AnnData],
ellipsis_index_with_equivalent: tuple[EllipsisType | slice, ...],
ellipsis_index: tuple[EllipsisType | slice],
equivalent_ellipsis_index: tuple[slice],
):
ellipsis_index, equivalent_index = ellipsis_index_with_equivalent
csr_mem, csr_disk, csc_disk, _ = ondisk_equivalent_adata

assert_equal(csr_mem.X[equivalent_index], csr_disk.X[ellipsis_index])
assert_equal(csr_mem.X[equivalent_index], csc_disk.X[ellipsis_index])
assert_equal(csr_mem.X[equivalent_ellipsis_index], csr_disk.X[ellipsis_index])
assert_equal(csr_mem.X[equivalent_ellipsis_index], csc_disk.X[ellipsis_index])


def make_randomized_mask(size: int) -> np.ndarray:
Expand Down
7 changes: 4 additions & 3 deletions tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -791,12 +791,13 @@ def test_dataframe_view_index_setting():


def test_ellipsis_index(
ellipsis_index_with_equivalent: tuple[slice | EllipsisType, ...], matrix_type
ellipsis_index: tuple[EllipsisType | slice],
equivalent_ellipsis_index: tuple[slice],
matrix_type,
):
ellipsis_index, equivalent_index = ellipsis_index_with_equivalent
adata = gen_adata((10, 10), X_type=matrix_type, **GEN_ADATA_DASK_ARGS)
subset_ellipsis = adata[ellipsis_index]
subset = adata[equivalent_index]
subset = adata[equivalent_ellipsis_index]
assert_equal(subset_ellipsis, subset)


Expand Down

0 comments on commit 6aff0f2

Please sign in to comment.