Skip to content

Commit 74d31ef

Browse files
committed
compression -> compressors, shard_shape -> shards, chunk_shape -> chunks
1 parent de2c36e commit 74d31ef

File tree

4 files changed

+49
-51
lines changed

4 files changed

+49
-51
lines changed

src/zarr/core/group.py

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,10 +1001,10 @@ async def create_array(
10011001
*,
10021002
shape: ShapeLike,
10031003
dtype: npt.DTypeLike,
1004-
chunk_shape: ChunkCoords | Literal["auto"] = "auto",
1005-
shard_shape: ChunkCoords | Literal["auto"] | None = None,
1004+
chunks: ChunkCoords | Literal["auto"] = "auto",
1005+
shards: ChunkCoords | Literal["auto"] | None = None,
10061006
filters: Iterable[dict[str, JSON] | Codec] = (),
1007-
compression: Iterable[dict[str, JSON] | Codec] = (),
1007+
compressors: Iterable[dict[str, JSON] | Codec] = (),
10081008
fill_value: Any | None = 0,
10091009
order: MemoryOrder | None = "C",
10101010
attributes: dict[str, JSON] | None = None,
@@ -1028,9 +1028,9 @@ async def create_array(
10281028
Shape of the array.
10291029
dtype : npt.DTypeLike
10301030
Data type of the array.
1031-
chunk_shape : ChunkCoords | Literal["auto"], default is "auto".
1031+
chunks : ChunkCoords | Literal["auto"], default is "auto".
10321032
Chunk shape of the array.
1033-
shard_shape : ChunkCoords, optional
1033+
shards : ChunkCoords, optional
10341034
Shard shape of the array. The default value of ``None`` results in no sharding at all.
10351035
filters : Iterable[Codec], optional
10361036
List of filters to apply to the array.
@@ -1064,10 +1064,10 @@ async def create_array(
10641064
name=name,
10651065
shape=shape,
10661066
dtype=dtype,
1067-
chunks=chunk_shape,
1068-
shards=shard_shape,
1067+
chunks=chunks,
1068+
shards=shards,
10691069
filters=filters,
1070-
compressors=compression,
1070+
compressors=compressors,
10711071
fill_value=fill_value,
10721072
order=order,
10731073
zarr_format=self.metadata.zarr_format,
@@ -1725,8 +1725,8 @@ def __getitem__(self, path: str) -> Array | Group:
17251725
--------
17261726
>>> import zarr
17271727
>>> group = Group.from_store(zarr.storage.MemoryStore()
1728-
>>> group.create_array(name="subarray", shape=(10,), chunk_shape=(10,))
1729-
>>> group.create_group(name="subgroup").create_array(name="subarray", shape=(10,), chunk_shape=(10,))
1728+
>>> group.create_array(name="subarray", shape=(10,), chunks=(10,))
1729+
>>> group.create_group(name="subgroup").create_array(name="subarray", shape=(10,), chunks=(10,))
17301730
>>> group["subarray"]
17311731
<Array memory://132270269438272/subarray shape=(10,) dtype=float64>
17321732
>>> group["subgroup"]
@@ -1760,7 +1760,7 @@ def get(self, path: str, default: DefaultT | None = None) -> Array | Group | Def
17601760
--------
17611761
>>> import zarr
17621762
>>> group = Group.from_store(zarr.storage.MemoryStore()
1763-
>>> group.create_array(name="subarray", shape=(10,), chunk_shape=(10,))
1763+
>>> group.create_array(name="subarray", shape=(10,), chunks=(10,))
17641764
>>> group.create_group(name="subgroup")
17651765
>>> group.get("subarray")
17661766
<Array memory://132270269438272/subarray shape=(10,) dtype=float64>
@@ -1786,7 +1786,7 @@ def __delitem__(self, key: str) -> None:
17861786
--------
17871787
>>> import zarr
17881788
>>> group = Group.from_store(zarr.storage.MemoryStore()
1789-
>>> group.create_array(name="subarray", shape=(10,), chunk_shape=(10,))
1789+
>>> group.create_array(name="subarray", shape=(10,), chunks=(10,))
17901790
>>> del group["subarray"]
17911791
>>> "subarray" in group
17921792
False
@@ -1801,8 +1801,8 @@ def __iter__(self) -> Iterator[str]:
18011801
>>> g1 = zarr.group()
18021802
>>> g2 = g1.create_group('foo')
18031803
>>> g3 = g1.create_group('bar')
1804-
>>> d1 = g1.create_array('baz', shape=(10,), chunk_shape=(10,))
1805-
>>> d2 = g1.create_array('quux', shape=(10,), chunk_shape=(10,))
1804+
>>> d1 = g1.create_array('baz', shape=(10,), chunks=(10,))
1805+
>>> d2 = g1.create_array('quux', shape=(10,), chunks=(10,))
18061806
>>> for name in g1:
18071807
... print(name)
18081808
baz
@@ -1993,8 +1993,8 @@ def keys(self) -> Generator[str, None]:
19931993
>>> g1 = zarr.group()
19941994
>>> g2 = g1.create_group('foo')
19951995
>>> g3 = g1.create_group('bar')
1996-
>>> d1 = g1.create_array('baz', shape=(10,), chunk_shape=(10,))
1997-
>>> d2 = g1.create_array('quux', shape=(10,), chunk_shape=(10,))
1996+
>>> d1 = g1.create_array('baz', shape=(10,), chunks=(10,))
1997+
>>> d2 = g1.create_array('quux', shape=(10,), chunks=(10,))
19981998
>>> for name in g1.keys():
19991999
... print(name)
20002000
baz
@@ -2012,7 +2012,7 @@ def __contains__(self, member: str) -> bool:
20122012
>>> import zarr
20132013
>>> g1 = zarr.group()
20142014
>>> g2 = g1.create_group('foo')
2015-
>>> d1 = g1.create_array('bar', shape=(10,), chunk_shape=(10,))
2015+
>>> d1 = g1.create_array('bar', shape=(10,), chunks=(10,))
20162016
>>> 'foo' in g1
20172017
True
20182018
>>> 'bar' in g1
@@ -2075,7 +2075,7 @@ def arrays(self) -> Generator[tuple[str, Array], None]:
20752075
--------
20762076
>>> import zarr
20772077
>>> group = zarr.group()
2078-
>>> group.create_array("subarray", shape=(10,), chunk_shape=(10,))
2078+
>>> group.create_array("subarray", shape=(10,), chunks=(10,))
20792079
>>> for name, subarray in group.arrays():
20802080
... print(name, subarray)
20812081
subarray <Array memory://140198565357056/subarray shape=(10,) dtype=float64>
@@ -2090,7 +2090,7 @@ def array_keys(self) -> Generator[str, None]:
20902090
--------
20912091
>>> import zarr
20922092
>>> group = zarr.group()
2093-
>>> group.create_array("subarray", shape=(10,), chunk_shape=(10,))
2093+
>>> group.create_array("subarray", shape=(10,), chunks=(10,))
20942094
>>> for name in group.array_keys():
20952095
... print(name)
20962096
subarray
@@ -2106,7 +2106,7 @@ def array_values(self) -> Generator[Array, None]:
21062106
--------
21072107
>>> import zarr
21082108
>>> group = zarr.group()
2109-
>>> group.create_array("subarray", shape=(10,), chunk_shape=(10,))
2109+
>>> group.create_array("subarray", shape=(10,), chunks=(10,))
21102110
>>> for subarray in group.array_values():
21112111
... print(subarray)
21122112
<Array memory://140198565357056/subarray shape=(10,) dtype=float64>
@@ -2196,10 +2196,10 @@ def create_array(
21962196
*,
21972197
shape: ShapeLike,
21982198
dtype: npt.DTypeLike,
2199-
chunk_shape: ChunkCoords | Literal["auto"] = "auto",
2200-
shard_shape: ChunkCoords | None = None,
2199+
chunks: ChunkCoords | Literal["auto"] = "auto",
2200+
shards: ChunkCoords | None = None,
22012201
filters: Iterable[dict[str, JSON] | Codec] | Literal["auto"] = "auto",
2202-
compression: Iterable[dict[str, JSON] | Codec] | Codec | Literal["auto"] = "auto",
2202+
compressors: Iterable[dict[str, JSON] | Codec] | Codec | Literal["auto"] = "auto",
22032203
fill_value: Any | None = 0,
22042204
order: MemoryOrder | None = "C",
22052205
attributes: dict[str, JSON] | None = None,
@@ -2216,16 +2216,16 @@ def create_array(
22162216
22172217
Parameters
22182218
----------
2219-
path : str
2219+
name : str
22202220
The name of the array relative to the group. If ``path`` is ``None``, the array will be located
22212221
at the root of the store.
22222222
shape : ChunkCoords
22232223
Shape of the array.
22242224
dtype : npt.DTypeLike
22252225
Data type of the array.
2226-
chunk_shape : ChunkCoords | Literal["auto"], default is "auto"
2226+
chunks : ChunkCoords | Literal["auto"], default is "auto"
22272227
Chunk shape of the array.
2228-
shard_shape : ChunkCoords, optional
2228+
shards : ChunkCoords, optional
22292229
Shard shape of the array. The default value of ``None`` results in no sharding at all.
22302230
filters : Iterable[Codec], optional
22312231
List of filters to apply to the array.
@@ -2260,12 +2260,12 @@ def create_array(
22602260
name=name,
22612261
shape=shape,
22622262
dtype=dtype,
2263-
chunk_shape=chunk_shape,
2264-
shard_shape=shard_shape,
2263+
chunks=chunks,
2264+
shards=shards,
22652265
fill_value=fill_value,
22662266
attributes=attributes,
22672267
chunk_key_encoding=chunk_key_encoding,
2268-
compression=compression,
2268+
compressors=compressors,
22692269
dimension_names=dimension_names,
22702270
order=order,
22712271
filters=filters,
@@ -2530,10 +2530,10 @@ def array(
25302530
*,
25312531
shape: ShapeLike,
25322532
dtype: npt.DTypeLike,
2533-
chunk_shape: ChunkCoords | Literal["auto"] = "auto",
2534-
shard_shape: ChunkCoords | Literal["auto"] | None = None,
2533+
chunks: ChunkCoords | Literal["auto"] = "auto",
2534+
shards: ChunkCoords | Literal["auto"] | None = None,
25352535
filters: Iterable[dict[str, JSON] | Codec] = (),
2536-
compression: Iterable[dict[str, JSON] | Codec] = (),
2536+
compressors: Iterable[dict[str, JSON] | Codec] = (),
25372537
fill_value: Any | None = 0,
25382538
order: MemoryOrder | None = "C",
25392539
attributes: dict[str, JSON] | None = None,
@@ -2550,16 +2550,16 @@ def array(
25502550
25512551
Parameters
25522552
----------
2553-
path : str
2553+
name : str
25542554
The name of the array relative to the group. If ``path`` is ``None``, the array will be located
25552555
at the root of the store.
25562556
shape : ChunkCoords
25572557
Shape of the array.
25582558
dtype : npt.DTypeLike
25592559
Data type of the array.
2560-
chunk_shape : ChunkCoords
2560+
chunks : ChunkCoords
25612561
Chunk shape of the array.
2562-
shard_shape : ChunkCoords, optional
2562+
shards : ChunkCoords, optional
25632563
Shard shape of the array. The default value of ``None`` results in no sharding at all.
25642564
filters : Iterable[Codec], optional
25652565
List of filters to apply to the array.
@@ -2594,12 +2594,12 @@ def array(
25942594
name=name,
25952595
shape=shape,
25962596
dtype=dtype,
2597-
chunk_shape=chunk_shape,
2598-
shard_shape=shard_shape,
2597+
chunks=chunks,
2598+
shards=shards,
25992599
fill_value=fill_value,
26002600
attributes=attributes,
26012601
chunk_key_encoding=chunk_key_encoding,
2602-
compression=compression,
2602+
compressors=compressors,
26032603
dimension_names=dimension_names,
26042604
order=order,
26052605
filters=filters,

tests/test_api.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,11 +1125,11 @@ async def test_create_array_v3(store: MemoryStore) -> None:
11251125
store=store,
11261126
dtype="uint8",
11271127
shape=(10,),
1128-
shard_shape=(4,),
1129-
chunk_shape=(4,),
1128+
shards=(4,),
1129+
chunks=(4,),
11301130
zarr_format=3,
11311131
filters=(TransposeCodec(order=(0,)),),
1132-
compression=ZstdCodec(level=3),
1132+
compressors=ZstdCodec(level=3),
11331133
)
11341134

11351135

@@ -1143,9 +1143,9 @@ async def test_create_array_v2(store: MemoryStore) -> None:
11431143
store=store,
11441144
dtype=dtype,
11451145
shape=(10,),
1146-
shard_shape=None,
1147-
chunk_shape=(4,),
1146+
shards=None,
1147+
chunks=(4,),
11481148
zarr_format=2,
11491149
filters=(Delta(dtype=dtype),),
1150-
compression=Zstd(level=3),
1150+
compressors=Zstd(level=3),
11511151
)

tests/test_array.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -925,6 +925,6 @@ def test_auto_partition_auto_shards(
925925
expected_shards += (cs,)
926926

927927
auto_shards, _ = _auto_partition(
928-
array_shape=array_shape, chunk_shape=chunk_shape, shard_shape="auto", dtype=dtype
928+
array_shape=array_shape, chunks=chunk_shape, shards="auto", dtype=dtype
929929
)
930930
assert auto_shards == expected_shards

tests/test_group.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -874,9 +874,7 @@ async def test_asyncgroup_getitem(store: Store, zarr_format: ZarrFormat) -> None
874874
agroup = await AsyncGroup.from_store(store=store, zarr_format=zarr_format)
875875

876876
array_name = "sub_array"
877-
sub_array = await agroup.create_array(
878-
name=array_name, shape=(10,), dtype="uint8", chunk_shape=(2,)
879-
)
877+
sub_array = await agroup.create_array(name=array_name, shape=(10,), dtype="uint8", chunks=(2,))
880878
assert await agroup.getitem(array_name) == sub_array
881879

882880
sub_group_path = "sub_group"
@@ -898,7 +896,7 @@ async def test_asyncgroup_delitem(store: Store, zarr_format: ZarrFormat) -> None
898896
name=array_name,
899897
shape=(10,),
900898
dtype="uint8",
901-
chunk_shape=(2,),
899+
chunks=(2,),
902900
attributes={"foo": 100},
903901
)
904902
await agroup.delitem(array_name)
@@ -964,7 +962,7 @@ async def test_asyncgroup_create_array(
964962
name=sub_node_path,
965963
shape=shape,
966964
dtype=dtype,
967-
chunk_shape=chunk_shape,
965+
chunks=chunk_shape,
968966
attributes=attributes,
969967
)
970968
assert isinstance(subnode, AsyncArray)
@@ -1105,7 +1103,7 @@ async def test_require_group(store: LocalStore | MemoryStore, zarr_format: ZarrF
11051103
assert foo_group.attrs == {}
11061104

11071105
_ = await foo_group.create_array(
1108-
"bar", shape=(10,), dtype="uint8", chunk_shape=(2,), attributes={"foo": 100}
1106+
"bar", shape=(10,), dtype="uint8", chunks=(2,), attributes={"foo": 100}
11091107
)
11101108

11111109
# test that overwriting a group w/ children fails

0 commit comments

Comments
 (0)