Skip to content

Commit 543099a

Browse files
committed
improve test_creation_from_other_zarr_format
1 parent c7393a4 commit 543099a

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

src/zarr/core/array.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3857,12 +3857,12 @@ async def from_array(
38573857
zarr_format = data.metadata.zarr_format
38583858
if filters == "keep":
38593859
if zarr_format == data.metadata.zarr_format:
3860-
filters = data.filters
3860+
filters = data.filters or None
38613861
else:
38623862
filters = "auto"
38633863
if compressors == "keep":
38643864
if zarr_format == data.metadata.zarr_format:
3865-
compressors = data.compressors
3865+
compressors = data.compressors or None
38663866
else:
38673867
compressors = "auto"
38683868
if serializer == "keep":

tests/test_array.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1275,12 +1275,14 @@ async def test_creation_from_other_zarr_format(
12751275
src_format: ZarrFormat,
12761276
new_format: ZarrFormat,
12771277
) -> None:
1278-
src = zarr.create(
1279-
(50, 50),
1280-
chunks=(10, 10),
1281-
store=store,
1282-
zarr_format=src_format,
1283-
)
1278+
kwargs = {}
1279+
# set dimension_separator to non default
1280+
if src_format == 2:
1281+
kwargs["dimension_separator"] = "/"
1282+
else:
1283+
kwargs["chunk_key_encoding"] = ("default", ".")
1284+
1285+
src = zarr.create((50, 50), chunks=(10, 10), store=store, zarr_format=src_format, **kwargs)
12841286
src[:] = np.arange(50 * 50).reshape((50, 50))
12851287
result = zarr.from_array(
12861288
src,
@@ -1291,6 +1293,8 @@ async def test_creation_from_other_zarr_format(
12911293
assert result.fill_value == src.fill_value
12921294
assert result.dtype == src.dtype
12931295
assert result.chunks == src.chunks
1296+
if src_format == new_format:
1297+
assert result.metadata == src.metadata
12941298

12951299

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

0 commit comments

Comments
 (0)