Skip to content

Commit de2c36e

Browse files
committed
rename compression to compressors, and make the docstring for create_array more clear on what filters and compressors mean
1 parent 023c16b commit de2c36e

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

src/zarr/core/array.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3484,7 +3484,7 @@ async def create_array(
34843484
chunks: ChunkCoords | Literal["auto"] = "auto",
34853485
shards: ChunkCoords | Literal["auto"] | None = None,
34863486
filters: FiltersParam = "auto",
3487-
compression: CompressionParam = "auto",
3487+
compressors: CompressionParam = "auto",
34883488
fill_value: Any | None = 0,
34893489
order: MemoryOrder | None = "C",
34903490
zarr_format: ZarrFormat | None = 3,
@@ -3514,9 +3514,19 @@ async def create_array(
35143514
shards : ChunkCoords, optional
35153515
Shard shape of the array. The default value of ``None`` results in no sharding at all.
35163516
filters : Iterable[Codec], optional
3517-
List of filters to apply to the array.
3518-
compression : Iterable[Codec], optional
3519-
List of compressors to apply to the array.
3517+
Iterable of filters to apply to each chunk of the array, in order, before serializing that
3518+
chunk to bytes.
3519+
For Zarr v3, a "filter" is a transformation that takes an array and returns an array,
3520+
and these values must be instances of ``ArrayArrayCodec``, or dict representations
3521+
of ``ArrayArrayCodec``.
3522+
For Zarr v2, a "filter" can be any numcodecs codec; you should ensure that the
3523+
the order if your filters is consistent with the behavior of each filter.
3524+
compressors : Iterable[Codec], optional
3525+
List of compressors to apply to the array. Compressors are applied in order, and after any
3526+
filters are applied (if any are specified).
3527+
For Zarr v3, a "compressor" is a transformation that takes a string of bytes and
3528+
returns another string of bytes.
3529+
For Zarr v2, a "compressor" can be any numcodecs codec.
35203530
fill_value : Any, optional
35213531
Fill value for the array.
35223532
order : {"C", "F"}, optional
@@ -3579,7 +3589,7 @@ async def create_array(
35793589
)
35803590
filters = cast(Iterable[numcodecs.abc.Codec] | Literal["auto"], filters)
35813591
filters_parsed, compressor_parsed = _parse_chunk_encoding_v2(
3582-
compression=compression, filters=filters, dtype=dtype_parsed
3592+
compression=compressors, filters=filters, dtype=dtype_parsed
35833593
)
35843594
if dimension_names is not None:
35853595
raise ValueError("Zarr v2 arrays do not support dimension names.")
@@ -3604,7 +3614,7 @@ async def create_array(
36043614
)
36053615
else:
36063616
array_array, array_bytes, bytes_bytes = _parse_chunk_encoding_v3(
3607-
compression=compression, filters=filters, dtype=dtype_parsed
3617+
compression=compressors, filters=filters, dtype=dtype_parsed
36083618
)
36093619
sub_codecs = (*array_array, array_bytes, *bytes_bytes)
36103620
codecs_out: tuple[Codec, ...]

src/zarr/core/group.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1067,7 +1067,7 @@ async def create_array(
10671067
chunks=chunk_shape,
10681068
shards=shard_shape,
10691069
filters=filters,
1070-
compression=compression,
1070+
compressors=compression,
10711071
fill_value=fill_value,
10721072
order=order,
10731073
zarr_format=self.metadata.zarr_format,

0 commit comments

Comments
 (0)