Skip to content

Commit

Permalink
(chore): add basic nd tests (#35)
Browse files Browse the repository at this point in the history
* (chore): add basic 3d tests

* (refactor): use `pytest_generate_tests`
  • Loading branch information
ilan-gold authored Nov 14, 2024
1 parent 7aeff55 commit 639f77b
Show file tree
Hide file tree
Showing 2 changed files with 174 additions and 135 deletions.
115 changes: 61 additions & 54 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,76 +66,83 @@ def array_fixture(request: pytest.FixtureRequest) -> npt.NDArray[Any]:
# tests that also fail with zarr-python's default codec pipeline
zarr_python_default_codec_pipeline_failures = [
# ellipsis weirdness, need to report
"test_roundtrip[oindex-contiguous_in_chunk_array-ellipsis]",
"test_roundtrip[oindex-discontinuous_in_chunk_array-ellipsis]",
"test_roundtrip[vindex-contiguous_in_chunk_array-ellipsis]",
"test_roundtrip[vindex-discontinuous_in_chunk_array-ellipsis]",
"test_roundtrip[oindex-across_chunks_indices_array-ellipsis]",
"test_roundtrip[vindex-ellipsis-across_chunks_indices_array]",
"test_roundtrip[vindex-across_chunks_indices_array-ellipsis]",
"test_roundtrip[vindex-ellipsis-contiguous_in_chunk_array]",
"test_roundtrip[vindex-ellipsis-discontinuous_in_chunk_array]",
"test_roundtrip_read_only_zarrs[oindex-contiguous_in_chunk_array-ellipsis]",
"test_roundtrip_read_only_zarrs[oindex-discontinuous_in_chunk_array-ellipsis]",
"test_roundtrip_read_only_zarrs[vindex-contiguous_in_chunk_array-ellipsis]",
"test_roundtrip_read_only_zarrs[vindex-discontinuous_in_chunk_array-ellipsis]",
"test_roundtrip_read_only_zarrs[oindex-across_chunks_indices_array-ellipsis]",
"test_roundtrip_read_only_zarrs[vindex-ellipsis-across_chunks_indices_array]",
"test_roundtrip_read_only_zarrs[vindex-across_chunks_indices_array-ellipsis]",
"test_roundtrip_read_only_zarrs[vindex-ellipsis-contiguous_in_chunk_array]",
"test_roundtrip_read_only_zarrs[vindex-ellipsis-discontinuous_in_chunk_array]",
"test_roundtrip[oindex-2d-contiguous_in_chunk_array-ellipsis]",
"test_roundtrip[oindex-2d-discontinuous_in_chunk_array-ellipsis]",
"test_roundtrip[vindex-2d-contiguous_in_chunk_array-ellipsis]",
"test_roundtrip[vindex-2d-discontinuous_in_chunk_array-ellipsis]",
"test_roundtrip[oindex-2d-across_chunks_indices_array-ellipsis]",
"test_roundtrip[vindex-2d-ellipsis-across_chunks_indices_array]",
"test_roundtrip[vindex-2d-across_chunks_indices_array-ellipsis]",
"test_roundtrip[vindex-2d-ellipsis-contiguous_in_chunk_array]",
"test_roundtrip[vindex-2d-ellipsis-discontinuous_in_chunk_array]",
"test_roundtrip_read_only_zarrs[oindex-2d-contiguous_in_chunk_array-ellipsis]",
"test_roundtrip_read_only_zarrs[oindex-2d-discontinuous_in_chunk_array-ellipsis]",
"test_roundtrip_read_only_zarrs[vindex-2d-contiguous_in_chunk_array-ellipsis]",
"test_roundtrip_read_only_zarrs[vindex-2d-discontinuous_in_chunk_array-ellipsis]",
"test_roundtrip_read_only_zarrs[oindex-2d-across_chunks_indices_array-ellipsis]",
"test_roundtrip_read_only_zarrs[vindex-2d-ellipsis-across_chunks_indices_array]",
"test_roundtrip_read_only_zarrs[vindex-2d-across_chunks_indices_array-ellipsis]",
"test_roundtrip_read_only_zarrs[vindex-2d-ellipsis-contiguous_in_chunk_array]",
"test_roundtrip_read_only_zarrs[vindex-2d-ellipsis-discontinuous_in_chunk_array]",
# need to investigate this one - it seems to fail with the default pipeline
"test_roundtrip_read_only_zarrs[vindex-contiguous_in_chunk_array-contiguous_in_chunk_array]",
"test_roundtrip_read_only_zarrs[vindex-2d-contiguous_in_chunk_array-contiguous_in_chunk_array]",
]

zarrs_python_no_discontinuous_writes = [
"test_roundtrip[oindex-discontinuous_in_chunk_array-slice_in_chunk]",
"test_roundtrip[oindex-discontinuous_in_chunk_array-slice_across_chunks]",
"test_roundtrip[oindex-discontinuous_in_chunk_array-fill_slice]",
"test_roundtrip[oindex-discontinuous_in_chunk_array-int]",
"test_roundtrip[oindex-slice_in_chunk-discontinuous_in_chunk_array]",
"test_roundtrip[oindex-slice_across_chunks-discontinuous_in_chunk_array]",
"test_roundtrip[oindex-fill_slice-discontinuous_in_chunk_array]",
"test_roundtrip[oindex-int-discontinuous_in_chunk_array]",
"test_roundtrip[oindex-ellipsis-discontinuous_in_chunk_array]",
"test_roundtrip[vindex-discontinuous_in_chunk_array-slice_in_chunk]",
"test_roundtrip[vindex-discontinuous_in_chunk_array-slice_across_chunks]",
"test_roundtrip[vindex-discontinuous_in_chunk_array-fill_slice]",
"test_roundtrip[vindex-discontinuous_in_chunk_array-int]",
"test_roundtrip[vindex-slice_in_chunk-discontinuous_in_chunk_array]",
"test_roundtrip[vindex-slice_across_chunks-discontinuous_in_chunk_array]",
"test_roundtrip[vindex-fill_slice-discontinuous_in_chunk_array]",
"test_roundtrip[vindex-int-discontinuous_in_chunk_array]",
"test_roundtrip[oindex-discontinuous_in_chunk_array-contiguous_in_chunk_array]",
"test_roundtrip[oindex-contiguous_in_chunk_array-discontinuous_in_chunk_array]",
"test_roundtrip[oindex-across_chunks_indices_array-discontinuous_in_chunk_array]",
"test_roundtrip[oindex-discontinuous_in_chunk_array-discontinuous_in_chunk_array]",
"test_roundtrip[vindex-contiguous_in_chunk_array-discontinuous_in_chunk_array]",
"test_roundtrip[vindex-discontinuous_in_chunk_array-discontinuous_in_chunk_array]",
"test_roundtrip[oindex-discontinuous_in_chunk_array-across_chunks_indices_array]",
"test_roundtrip[vindex-discontinuous_in_chunk_array-contiguous_in_chunk_array]",
"test_roundtrip[oindex-2d-discontinuous_in_chunk_array-slice_in_chunk]",
"test_roundtrip[oindex-2d-discontinuous_in_chunk_array-slice_across_chunks]",
"test_roundtrip[oindex-2d-discontinuous_in_chunk_array-full_slice]",
"test_roundtrip[oindex-2d-discontinuous_in_chunk_array-int]",
"test_roundtrip[oindex-2d-slice_in_chunk-discontinuous_in_chunk_array]",
"test_roundtrip[oindex-2d-slice_across_chunks-discontinuous_in_chunk_array]",
"test_roundtrip[oindex-2d-full_slice-discontinuous_in_chunk_array]",
"test_roundtrip[oindex-2d-int-discontinuous_in_chunk_array]",
"test_roundtrip[oindex-2d-ellipsis-discontinuous_in_chunk_array]",
"test_roundtrip[vindex-2d-discontinuous_in_chunk_array-slice_in_chunk]",
"test_roundtrip[vindex-2d-discontinuous_in_chunk_array-slice_across_chunks]",
"test_roundtrip[vindex-2d-discontinuous_in_chunk_array-full_slice]",
"test_roundtrip[vindex-2d-discontinuous_in_chunk_array-int]",
"test_roundtrip[vindex-2d-slice_in_chunk-discontinuous_in_chunk_array]",
"test_roundtrip[vindex-2d-slice_across_chunks-discontinuous_in_chunk_array]",
"test_roundtrip[vindex-2d-full_slice-discontinuous_in_chunk_array]",
"test_roundtrip[vindex-2d-int-discontinuous_in_chunk_array]",
"test_roundtrip[oindex-2d-discontinuous_in_chunk_array-contiguous_in_chunk_array]",
"test_roundtrip[oindex-2d-contiguous_in_chunk_array-discontinuous_in_chunk_array]",
"test_roundtrip[oindex-2d-across_chunks_indices_array-discontinuous_in_chunk_array]",
"test_roundtrip[oindex-2d-discontinuous_in_chunk_array-discontinuous_in_chunk_array]",
"test_roundtrip[vindex-2d-contiguous_in_chunk_array-discontinuous_in_chunk_array]",
"test_roundtrip[vindex-2d-discontinuous_in_chunk_array-discontinuous_in_chunk_array]",
"test_roundtrip[oindex-2d-discontinuous_in_chunk_array-across_chunks_indices_array]",
"test_roundtrip[vindex-2d-discontinuous_in_chunk_array-contiguous_in_chunk_array]",
"test_roundtrip[oindex-1d-discontinuous_in_chunk_array]",
"test_roundtrip[vindex-1d-discontinuous_in_chunk_array]",
]

# vindexing with two contiguous arrays would be converted to two slices but
# in numpy indexing actually requires dropping a dimension, which in turn boils
# down to integer indexing, which we can't do i.e., [np.array(1, 2), np.array(1, 2)] -> [slice(1, 2), slice(1, 2)]
# is not a correct conversion, and thus we don't support the write operation
zarrs_python_no_collapsed_dim = [
"test_roundtrip[vindex-contiguous_in_chunk_array-contiguous_in_chunk_array]"
"test_roundtrip[vindex-2d-contiguous_in_chunk_array-contiguous_in_chunk_array]"
]


def pytest_collection_modifyitems(
config: pytest.Config, items: Iterable[pytest.Item]
) -> None:
xfail_marker = pytest.mark.xfail(
reason="This test fails with the zarr-python default codec pipeline."
)
for item in items:
if (
item.name
in zarr_python_default_codec_pipeline_failures
+ zarrs_python_no_discontinuous_writes
+ zarrs_python_no_collapsed_dim
):
if item.name in zarr_python_default_codec_pipeline_failures:
xfail_marker = pytest.mark.xfail(
reason="This test fails with the zarr-python default codec pipeline."
)
item.add_marker(xfail_marker)
if item.name in zarrs_python_no_discontinuous_writes:
xfail_marker = pytest.mark.xfail(
reason="zarrs discontinuous writes are not supported."
)
item.add_marker(xfail_marker)
if item.name in zarrs_python_no_collapsed_dim:
xfail_marker = pytest.mark.xfail(
reason="zarrs vindexing with multiple contiguous arrays is not supported."
)
item.add_marker(xfail_marker)
Loading

0 comments on commit 639f77b

Please sign in to comment.