Skip to content

remove insertion of vlen-string codec for v2 metadata creation #3100

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
May 28, 2025
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
3 changes: 3 additions & 0 deletions changes/3100.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
For Zarr format 2, allow fixed-length string arrays to be created without automatically inserting a
``Vlen-UT8`` codec in the array of filters. Fixed-length string arrays do not need this codec. This
change fixes a regression where fixed-length string arrays created with Zarr Python 3 could not be read with Zarr Python 2.18.
8 changes: 0 additions & 8 deletions src/zarr/core/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -768,14 +768,6 @@ def _create_metadata_v2(

dtype = parse_dtype(dtype, zarr_format=2)

# inject VLenUTF8 for str dtype if not already present
if np.issubdtype(dtype, np.str_):
filters = filters or []
from numcodecs.vlen import VLenUTF8

if not any(isinstance(x, VLenUTF8) or x["id"] == "vlen-utf8" for x in filters):
filters = list(filters) + [VLenUTF8()]

return ArrayV2Metadata(
shape=shape,
dtype=np.dtype(dtype),
Expand Down
2 changes: 1 addition & 1 deletion tests/test_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -1245,7 +1245,7 @@ async def test_invalid_v3_arguments(
zarr.create(store=store, dtype="uint8", shape=(10,), zarr_format=3, **kwargs)

@staticmethod
@pytest.mark.parametrize("dtype", ["uint8", "float32", "str"])
@pytest.mark.parametrize("dtype", ["uint8", "float32", "str", "U10", "S10", ">M8[10s]"])
@pytest.mark.parametrize(
"compressors",
[
Expand Down