From e2e1f9d8427aaf469c7583f75533e76fe1805179 Mon Sep 17 00:00:00 2001 From: Davis Vann Bennett Date: Tue, 27 May 2025 10:50:05 +0200 Subject: [PATCH 1/5] remove insertion of vlen-string codec for v2 metadata creation --- src/zarr/core/array.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/zarr/core/array.py b/src/zarr/core/array.py index 62af644f7d..b4e8ac0ff6 100644 --- a/src/zarr/core/array.py +++ b/src/zarr/core/array.py @@ -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), From 33cccc16b2a549989e10e23237c4900b8d4cd68a Mon Sep 17 00:00:00 2001 From: Davis Vann Bennett Date: Tue, 27 May 2025 11:00:12 +0200 Subject: [PATCH 2/5] changelog --- changes/3100.bugfix.rst | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 changes/3100.bugfix.rst diff --git a/changes/3100.bugfix.rst b/changes/3100.bugfix.rst new file mode 100644 index 0000000000..b3cc817dae --- /dev/null +++ b/changes/3100.bugfix.rst @@ -0,0 +1,3 @@ +Zarr V2: 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 regressions against Zarr Python 2.18. \ No newline at end of file From 0597c32fb2213094cbdc9cede29dc30a6fbb65dc Mon Sep 17 00:00:00 2001 From: Davis Bennett Date: Tue, 27 May 2025 17:06:10 +0200 Subject: [PATCH 3/5] Update changes/3100.bugfix.rst Co-authored-by: David Stansby --- changes/3100.bugfix.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changes/3100.bugfix.rst b/changes/3100.bugfix.rst index b3cc817dae..90a5d19ec3 100644 --- a/changes/3100.bugfix.rst +++ b/changes/3100.bugfix.rst @@ -1,3 +1,3 @@ -Zarr V2: allow fixed-length string arrays to be created without automatically inserting a +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 regressions against Zarr Python 2.18. \ No newline at end of file From c2c2f404334c8d85835b9211dd25b91fca0273ab Mon Sep 17 00:00:00 2001 From: Davis Bennett Date: Tue, 27 May 2025 17:08:14 +0200 Subject: [PATCH 4/5] Update changes/3100.bugfix.rst Co-authored-by: David Stansby --- changes/3100.bugfix.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changes/3100.bugfix.rst b/changes/3100.bugfix.rst index 90a5d19ec3..11f06628c0 100644 --- a/changes/3100.bugfix.rst +++ b/changes/3100.bugfix.rst @@ -1,3 +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 regressions against Zarr Python 2.18. \ No newline at end of file +change fixes a regression where fixed-length string arrays created with Zarr Python 3 could not be read with Zarr Python 2.18. \ No newline at end of file From 7908f546b1305711400c98901a28bc82a9f85ca8 Mon Sep 17 00:00:00 2001 From: Davis Vann Bennett Date: Wed, 28 May 2025 17:33:44 +0200 Subject: [PATCH 5/5] add dtype strings to test_v2_chunk_encoding --- tests/test_array.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_array.py b/tests/test_array.py index a6bcd17c4b..3fc7b3938c 100644 --- a/tests/test_array.py +++ b/tests/test_array.py @@ -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", [