Skip to content

Commit

Permalink
fix: compatibility with zarr-python 3.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
LDeakin committed Feb 15, 2025
1 parent 28f8058 commit 7bdb516
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ dependencies = [
'donfig',
'pytest',
'universal_pathlib>=0.2.0',
"zarr",
"zarr>=3.0.3",
]

[project.optional-dependencies]
Expand Down
8 changes: 4 additions & 4 deletions python/zarrs/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ async def encode(
async def read(
self,
batch_info: Iterable[
tuple[ByteGetter, ArraySpec, SelectorTuple, SelectorTuple]
tuple[ByteGetter, ArraySpec, SelectorTuple, SelectorTuple, bool]
],
out: NDBuffer, # type: ignore
drop_axes: tuple[int, ...] = (), # FIXME: unused
Expand Down Expand Up @@ -191,7 +191,7 @@ async def read(
async def write(
self,
batch_info: Iterable[
tuple[ByteSetter, ArraySpec, SelectorTuple, SelectorTuple]
tuple[ByteSetter, ArraySpec, SelectorTuple, SelectorTuple, bool]
],
value: NDBuffer, # type: ignore
drop_axes: tuple[int, ...] = (),
Expand Down Expand Up @@ -229,13 +229,13 @@ async def write(
def _raise_error_on_unsupported_batch_dtype(
self,
batch_info: Iterable[
tuple[ByteSetter, ArraySpec, SelectorTuple, SelectorTuple]
tuple[ByteSetter, ArraySpec, SelectorTuple, SelectorTuple, bool]
],
):
# https://github.com/LDeakin/zarrs/blob/0532fe983b7b42b59dbf84e50a2fe5e6f7bad4ce/zarrs_metadata/src/v2_to_v3.rs#L289-L293 for VSUMm
# Further, our pipeline does not support variable-length objects due to limitations on decode_into, so object is also out
if any(
info.dtype.kind in {"V", "S", "U", "M", "m", "O"}
for (_, info, _, _) in batch_info
for (_, info, _, _, _) in batch_info
):
raise UnsupportedDataTypeError()
10 changes: 8 additions & 2 deletions python/zarrs/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,20 @@ def get_implicit_fill_value(dtype: np.dtype, fill_value: Any) -> Any:

def make_chunk_info_for_rust_with_indices(
batch_info: Iterable[
tuple[ByteGetter | ByteSetter, ArraySpec, SelectorTuple, SelectorTuple]
tuple[ByteGetter | ByteSetter, ArraySpec, SelectorTuple, SelectorTuple, bool]
],
drop_axes: tuple[int, ...],
shape: tuple[int, ...],
) -> list[WithSubset]:
shape = shape if shape else (1,) # constant array
chunk_info_with_indices: list[WithSubset] = []
for byte_getter, chunk_spec, chunk_selection, out_selection in batch_info:
for (
byte_getter,
chunk_spec,
chunk_selection,
out_selection,
_is_complete,
) in batch_info:
if chunk_spec.fill_value is None:
chunk_spec = ArraySpec(
chunk_spec.shape,
Expand Down

0 comments on commit 7bdb516

Please sign in to comment.