Skip to content

Commit ae1832d

Browse files
committed
handle singleton compressor / filters input
1 parent 669ad72 commit ae1832d

File tree

4 files changed

+17
-8
lines changed

4 files changed

+17
-8
lines changed

src/zarr/core/array.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import json
44
import warnings
55
from asyncio import gather
6-
from collections.abc import Iterable
6+
from collections.abc import Iterable, Mapping
77
from dataclasses import dataclass, field
88
from itertools import starmap
99
from logging import getLogger
@@ -3594,7 +3594,10 @@ async def create_array(
35943594
config=config_parsed,
35953595
)
35963596
else:
3597-
sub_codecs = _parse_chunk_encoding_v3(compression=compression, filters=filters, dtype=dtype)
3597+
array_array, array_bytes, bytes_bytes = _parse_chunk_encoding_v3(
3598+
compression=compression, filters=filters, dtype=dtype_parsed
3599+
)
3600+
sub_codecs = (*array_array, array_bytes, *bytes_bytes)
35983601
codecs_out: tuple[Codec, ...]
35993602
if shard_shape_parsed is not None:
36003603
sharding_codec = ShardingCodec(chunk_shape=chunk_shape_parsed, codecs=sub_codecs)
@@ -3750,10 +3753,16 @@ def _parse_chunk_encoding_v3(
37503753
if compression == "auto":
37513754
out_bytes_bytes = default_bytes_bytes
37523755
else:
3753-
out_bytes_bytes = tuple(compression)
3756+
if isinstance(compression, Mapping | Codec):
3757+
out_bytes_bytes = (compression,)
3758+
else:
3759+
out_bytes_bytes = tuple(compression)
37543760
if filters == "auto":
37553761
out_array_array = default_array_array
37563762
else:
3757-
out_array_array = tuple(filters)
3763+
if isinstance(filters, Mapping | Codec):
3764+
out_array_array = (filters,)
3765+
else:
3766+
out_array_array = tuple(filters)
37583767

37593768
return out_array_array, default_array_bytes, out_bytes_bytes

src/zarr/core/group.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1064,8 +1064,8 @@ async def create_array(
10641064
name=name,
10651065
shape=shape,
10661066
dtype=dtype,
1067-
chunk_shape=chunk_shape,
1068-
shard_shape=shard_shape,
1067+
chunks=chunk_shape,
1068+
shards=shard_shape,
10691069
filters=filters,
10701070
compression=compression,
10711071
fill_value=fill_value,

tests/test_store/test_zip.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def test_api_integration(self, store: ZipStore) -> None:
6969

7070
data = np.arange(10000, dtype=np.uint16).reshape(100, 100)
7171
z = root.create_array(
72-
shape=data.shape, chunks=(10, 10), name="foo", dtype=np.uint16, fill_value=99
72+
shape=data.shape, chunk_shape=(10, 10), name="foo", dtype=np.uint16, fill_value=99
7373
)
7474
z[:] = data
7575

tests/test_v2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ async def test_v2_encode_decode(dtype):
8888
g.create_array(
8989
name="foo",
9090
shape=(3,),
91-
chunks=(3,),
91+
chunk_shape=(3,),
9292
dtype=dtype,
9393
fill_value=b"X",
9494
)

0 commit comments

Comments
 (0)