Skip to content

Commit 1643983

Browse files
committed
rename array_bytes_codec to serializer
1 parent e3f1f33 commit 1643983

File tree

6 files changed

+21
-21
lines changed

6 files changed

+21
-21
lines changed

src/zarr/api/synchronous.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
from zarr.abc.codec import Codec
2020
from zarr.api.asynchronous import ArrayLike, PathLike
2121
from zarr.core.array import (
22-
ArrayBytesCodecParam,
2322
CompressorsParam,
2423
FiltersParam,
24+
SerializerParam,
2525
ShardsParam,
2626
)
2727
from zarr.core.array_spec import ArrayConfig, ArrayConfigParams
@@ -748,7 +748,7 @@ def create_array(
748748
shards: ShardsParam | None = None,
749749
filters: FiltersParam | None = "auto",
750750
compressors: CompressorsParam = "auto",
751-
array_bytes_codec: ArrayBytesCodecParam = "auto",
751+
serializer: SerializerParam = "auto",
752752
fill_value: Any | None = None,
753753
order: MemoryOrder | None = None,
754754
zarr_format: ZarrFormat | None = 3,
@@ -814,10 +814,10 @@ def create_array(
814814
These defaults can be changed by modifying the value of ``array.v2_default_compressor``
815815
in :mod:`zarr.core.config`.
816816
Use ``None`` to omit the default compressor.
817-
array_bytes_codec : dict[str, JSON] | ArrayBytesCodec, optional
817+
serializer : dict[str, JSON] | ArrayBytesCodec, optional
818818
Array-to-bytes codec to use for encoding the array data.
819819
Zarr v3 only. Zarr v2 arrays use implicit array-to-bytes conversion.
820-
If no ``array_bytes_codec`` is provided, the `zarr.codecs.BytesCodec` codec will be used.
820+
If no ``serializer`` is provided, the `zarr.codecs.BytesCodec` codec will be used.
821821
fill_value : Any, optional
822822
Fill value for the array.
823823
order : {"C", "F"}, optional
@@ -875,7 +875,7 @@ def create_array(
875875
shards=shards,
876876
filters=filters,
877877
compressors=compressors,
878-
array_bytes_codec=array_bytes_codec,
878+
serializer=serializer,
879879
fill_value=fill_value,
880880
order=order,
881881
zarr_format=zarr_format,

src/zarr/core/array.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3643,7 +3643,7 @@ def _get_default_codecs(
36433643
| Literal["auto"]
36443644
| None
36453645
)
3646-
ArrayBytesCodecParam: TypeAlias = dict[str, JSON] | ArrayBytesCodec | Literal["auto"]
3646+
SerializerParam: TypeAlias = dict[str, JSON] | ArrayBytesCodec | Literal["auto"]
36473647

36483648

36493649
class ShardsConfigParam(TypedDict):
@@ -3664,7 +3664,7 @@ async def create_array(
36643664
shards: ShardsParam | None = None,
36653665
filters: FiltersParam | None = "auto",
36663666
compressors: CompressorsParam = "auto",
3667-
array_bytes_codec: ArrayBytesCodecParam = "auto",
3667+
serializer: SerializerParam = "auto",
36683668
fill_value: Any | None = None,
36693669
order: MemoryOrder | None = None,
36703670
zarr_format: ZarrFormat | None = 3,
@@ -3730,10 +3730,10 @@ async def create_array(
37303730
These defaults can be changed by modifying the value of ``array.v2_default_compressor``
37313731
in :mod:`zarr.core.config`.
37323732
Use ``None`` to omit the default compressor.
3733-
array_bytes_codec : dict[str, JSON] | ArrayBytesCodec, optional
3733+
serializer : dict[str, JSON] | ArrayBytesCodec, optional
37343734
Array-to-bytes codec to use for encoding the array data.
37353735
Zarr v3 only. Zarr v2 arrays use implicit array-to-bytes conversion.
3736-
If no ``array_bytes_codec`` is provided, the `zarr.codecs.BytesCodec` codec will be used.
3736+
If no ``serializer`` is provided, the `zarr.codecs.BytesCodec` codec will be used.
37373737
fill_value : Any, optional
37383738
Fill value for the array.
37393739
order : {"C", "F"}, optional
@@ -3808,8 +3808,8 @@ async def create_array(
38083808
)
38093809

38103810
raise ValueError(msg)
3811-
if array_bytes_codec != "auto":
3812-
raise ValueError("Zarr v2 arrays do not support `array_bytes_codec`.")
3811+
if serializer != "auto":
3812+
raise ValueError("Zarr v2 arrays do not support `serializer`.")
38133813

38143814
filters_parsed, compressor_parsed = _parse_chunk_encoding_v2(
38153815
compressor=compressors, filters=filters, dtype=np.dtype(dtype)
@@ -3840,7 +3840,7 @@ async def create_array(
38403840
array_array, array_bytes, bytes_bytes = _parse_chunk_encoding_v3(
38413841
compressors=compressors,
38423842
filters=filters,
3843-
array_bytes_codec=array_bytes_codec,
3843+
serializer=serializer,
38443844
dtype=dtype_parsed,
38453845
)
38463846
sub_codecs = cast(tuple[Codec, ...], (*array_array, array_bytes, *bytes_bytes))
@@ -4017,7 +4017,7 @@ def _parse_chunk_encoding_v3(
40174017
*,
40184018
compressors: CompressorsParam | None,
40194019
filters: FiltersParam | None,
4020-
array_bytes_codec: ArrayBytesCodecParam,
4020+
serializer: SerializerParam,
40214021
dtype: np.dtype[Any],
40224022
) -> tuple[tuple[ArrayArrayCodec, ...], ArrayBytesCodec, tuple[BytesBytesCodec, ...]]:
40234023
"""
@@ -4058,9 +4058,9 @@ def _parse_chunk_encoding_v3(
40584058
maybe_array_array = cast(Iterable[Codec | dict[str, JSON]], filters)
40594059
out_array_array = tuple(_parse_array_array_codec(c) for c in maybe_array_array)
40604060

4061-
if array_bytes_codec == "auto":
4061+
if serializer == "auto":
40624062
out_array_bytes = default_array_bytes
40634063
else:
4064-
out_array_bytes = _parse_array_bytes_codec(array_bytes_codec)
4064+
out_array_bytes = _parse_array_bytes_codec(serializer)
40654065

40664066
return out_array_array, out_array_bytes, out_bytes_bytes

tests/test_array.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ def test_vlen_errors() -> None:
461461
match="For string dtype, ArrayBytesCodec must be `VLenUTF8Codec`, got `BytesCodec`.",
462462
):
463463
zarr.create_array(
464-
MemoryStore(), shape=(5,), chunks=(5,), dtype="<U4", array_bytes_codec=BytesCodec()
464+
MemoryStore(), shape=(5,), chunks=(5,), dtype="<U4", serializer=BytesCodec()
465465
)
466466

467467

@@ -1084,7 +1084,7 @@ async def test_create_array_v3_chunk_encoding(
10841084
compressors=compressors,
10851085
)
10861086
aa_codecs_expected, _, bb_codecs_expected = _parse_chunk_encoding_v3(
1087-
filters=filters, compressors=compressors, array_bytes_codec="auto", dtype=np.dtype(dtype)
1087+
filters=filters, compressors=compressors, serializer="auto", dtype=np.dtype(dtype)
10881088
)
10891089
# TODO: find a better way to get the filters / compressors from the array.
10901090
assert arr.codec_pipeline.array_array_codecs == aa_codecs_expected # type: ignore[attr-defined]

tests/test_codecs/test_codecs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ def test_invalid_metadata_create_array(store: Store) -> None:
372372
chunks=(16, 16),
373373
dtype=np.dtype("uint8"),
374374
fill_value=0,
375-
array_bytes_codec=ShardingCodec(chunk_shape=(8, 8)),
375+
serializer=ShardingCodec(chunk_shape=(8, 8)),
376376
compressors=[
377377
GzipCodec(),
378378
],

tests/test_codecs/test_endian.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ async def test_endian(store: Store, endian: Literal["big", "little"]) -> None:
2424
dtype=data.dtype,
2525
fill_value=0,
2626
chunk_key_encoding={"name": "v2", "separator": "."},
27-
array_bytes_codec=BytesCodec(endian=endian),
27+
serializer=BytesCodec(endian=endian),
2828
)
2929

3030
await _AsyncArrayProxy(a)[:, :].set(data)
@@ -50,7 +50,7 @@ async def test_endian_write(
5050
dtype="uint16",
5151
fill_value=0,
5252
chunk_key_encoding={"name": "v2", "separator": "."},
53-
array_bytes_codec=BytesCodec(endian=dtype_store_endian),
53+
serializer=BytesCodec(endian=dtype_store_endian),
5454
)
5555

5656
await _AsyncArrayProxy(a)[:, :].set(data)

tests/test_codecs/test_sharding.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ def test_nested_sharding_create_array(
280280
chunks=(32, 32, 32),
281281
dtype=data.dtype,
282282
fill_value=0,
283-
array_bytes_codec=ShardingCodec(
283+
serializer=ShardingCodec(
284284
chunk_shape=(32, 32, 32),
285285
codecs=[ShardingCodec(chunk_shape=(16, 16, 16), index_location=inner_index_location)],
286286
index_location=outer_index_location,

0 commit comments

Comments
 (0)