Skip to content

Commit

Permalink
improve test_creation_from_other_zarr_format
Browse files Browse the repository at this point in the history
  • Loading branch information
brokkoli71 committed Jan 15, 2025
1 parent c7393a4 commit 543099a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/zarr/core/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -3857,12 +3857,12 @@ async def from_array(
zarr_format = data.metadata.zarr_format
if filters == "keep":
if zarr_format == data.metadata.zarr_format:
filters = data.filters
filters = data.filters or None
else:
filters = "auto"
if compressors == "keep":
if zarr_format == data.metadata.zarr_format:
compressors = data.compressors
compressors = data.compressors or None
else:
compressors = "auto"
if serializer == "keep":
Expand Down
16 changes: 10 additions & 6 deletions tests/test_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -1275,12 +1275,14 @@ async def test_creation_from_other_zarr_format(
src_format: ZarrFormat,
new_format: ZarrFormat,
) -> None:
src = zarr.create(
(50, 50),
chunks=(10, 10),
store=store,
zarr_format=src_format,
)
kwargs = {}
# set dimension_separator to non default
if src_format == 2:
kwargs["dimension_separator"] = "/"
else:
kwargs["chunk_key_encoding"] = ("default", ".")

src = zarr.create((50, 50), chunks=(10, 10), store=store, zarr_format=src_format, **kwargs)
src[:] = np.arange(50 * 50).reshape((50, 50))
result = zarr.from_array(
src,
Expand All @@ -1291,6 +1293,8 @@ async def test_creation_from_other_zarr_format(
assert result.fill_value == src.fill_value
assert result.dtype == src.dtype
assert result.chunks == src.chunks
if src_format == new_format:
assert result.metadata == src.metadata


@pytest.mark.parametrize("store", ["local", "memory", "zip"], indirect=True)
Expand Down

0 comments on commit 543099a

Please sign in to comment.