Skip to content

Commit feb4aa2

Browse files
d-v-bdstansby
andauthored
remove insertion of vlen-string codec for v2 metadata creation (#3100)
* remove insertion of vlen-string codec for v2 metadata creation * changelog * Update changes/3100.bugfix.rst Co-authored-by: David Stansby <[email protected]> * Update changes/3100.bugfix.rst Co-authored-by: David Stansby <[email protected]> * add dtype strings to test_v2_chunk_encoding --------- Co-authored-by: David Stansby <[email protected]>
1 parent ada3b22 commit feb4aa2

File tree

3 files changed

+4
-9
lines changed

3 files changed

+4
-9
lines changed

changes/3100.bugfix.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
For Zarr format 2, allow fixed-length string arrays to be created without automatically inserting a
2+
``Vlen-UT8`` codec in the array of filters. Fixed-length string arrays do not need this codec. This
3+
change fixes a regression where fixed-length string arrays created with Zarr Python 3 could not be read with Zarr Python 2.18.

src/zarr/core/array.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -768,14 +768,6 @@ def _create_metadata_v2(
768768

769769
dtype = parse_dtype(dtype, zarr_format=2)
770770

771-
# inject VLenUTF8 for str dtype if not already present
772-
if np.issubdtype(dtype, np.str_):
773-
filters = filters or []
774-
from numcodecs.vlen import VLenUTF8
775-
776-
if not any(isinstance(x, VLenUTF8) or x["id"] == "vlen-utf8" for x in filters):
777-
filters = list(filters) + [VLenUTF8()]
778-
779771
return ArrayV2Metadata(
780772
shape=shape,
781773
dtype=np.dtype(dtype),

tests/test_array.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1245,7 +1245,7 @@ async def test_invalid_v3_arguments(
12451245
zarr.create(store=store, dtype="uint8", shape=(10,), zarr_format=3, **kwargs)
12461246

12471247
@staticmethod
1248-
@pytest.mark.parametrize("dtype", ["uint8", "float32", "str"])
1248+
@pytest.mark.parametrize("dtype", ["uint8", "float32", "str", "U10", "S10", ">M8[10s]"])
12491249
@pytest.mark.parametrize(
12501250
"compressors",
12511251
[

0 commit comments

Comments
 (0)