Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions changes/3532.misc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Accept `"bytes"` as an alias for `"variable_length_bytes"` when parsing `JSON`-encoded Zarr V3
data types.
2 changes: 1 addition & 1 deletion src/zarr/core/dtype/npy/bytes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1046,7 +1046,7 @@ def _check_json_v3(cls, data: DTypeJSON) -> TypeGuard[Literal["variable_length_b
True if the input is a valid representation of this class in Zarr V3, False otherwise.
"""

return data == cls._zarr_v3_name
return data in (cls._zarr_v3_name, "bytes")

@classmethod
def _from_json_v2(cls, data: DTypeJSON) -> Self:
Expand Down
7 changes: 7 additions & 0 deletions tests/test_dtype/test_npy/test_bytes.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,13 @@ class TestVariableLengthBytes(BaseTestZDType):
item_size_params = (VariableLengthBytes(),)


def test_vlen_bytes_alias() -> None:
"""Test that "bytes" is an accepted alias for "variable_length_bytes" in JSON metadata"""
a = VariableLengthBytes.from_json("bytes", zarr_format=3)
b = VariableLengthBytes.from_json("variable_length_bytes", zarr_format=3)
assert a == b


@pytest.mark.parametrize(
"zdtype", [NullTerminatedBytes(length=10), RawBytes(length=10), VariableLengthBytes()]
)
Expand Down