Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(chore): add ellipsis indexing tests #25

Merged
merged 1 commit into from
Nov 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions tests/test_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,27 @@ def test_roundtrip_orthogonal_indexing_1d_axis(
arr.oindex[2, indexer] = stored_value
res = arr.oindex[2, indexer]
assert np.all(res == stored_value), res


def test_roundtrip_ellipsis_indexing_2d(arr: zarr.Array):
stored_value = np.arange(arr.size).reshape(arr.shape)
arr[...] = stored_value
res = arr[...]
assert np.all(res == stored_value), res


def test_roundtrip_ellipsis_indexing_1d(arr: zarr.Array):
stored_value = np.array([1, 2, 3, 4])
arr[2, ...] = stored_value
res = arr[2, ...]
assert np.all(res == stored_value), res


def test_roundtrip_ellipsis_indexing_1d_invalid(arr: zarr.Array):
stored_value = np.array([1, 2, 3])
with pytest.raises(
BaseException # TODO: ValueError, but this raises pyo3_runtime.PanicException
):
Comment on lines +124 to +126
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I am not sure there's much else we can do about this at the moment without some trickery that I also can't think of at the moment.

# zarrs-python error: ValueError: operands could not be broadcast together with shapes (4,) (3,)
# numpy error: ValueError: could not broadcast input array from shape (3,) into shape (4,)
arr[2, ...] = stored_value