Skip to content

Commit 518ebef

Browse files
authored
(fix): check for T data type kind to fall back to python (#92)
* (fix): add T data type * (chore): tests * (fix): bump ubuntu on readthedocs.yml * (fix): add clang package specifically for readthedocs * (fix): try clang * (fix): handle uninstalled clang * (fix): right, in a docker container * (style): match indent * (fix): use standard api, update test to latest version * (fix): latest fixed ubuntu
1 parent 48ddecb commit 518ebef

File tree

5 files changed

+28
-27
lines changed

5 files changed

+28
-27
lines changed

.github/workflows/cd.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ jobs:
5959
# If we're running on rhel centos, install needed packages.
6060
if command -v yum &> /dev/null; then
6161
yum update -y && yum install -y perl-core
62+
# https://github.com/PyO3/maturin-action/discussions/152
63+
if [[ "${{ matrix.os }}" == "linux" && "${{ matrix.target }}" == "x86_64" && "${{ matrix.manylinux }}" == "2_28" ]]; then
64+
yum update -y && yum install -y clang
65+
fi
6266
fi
6367
- run: ${{ (matrix.os == 'windows' && 'dir') || 'ls -lh' }} dist/
6468
- run: twine check --strict dist/*

.readthedocs.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
version: 2
22
build:
3-
os: ubuntu-20.04
3+
os: ubuntu-24.04
4+
apt_packages:
5+
- clang
46
tools:
57
python: "3.12"
68
rust: "latest"

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ filterwarnings = [
8383
"ignore:The loop argument is deprecated since Python 3.8.*:DeprecationWarning",
8484
"ignore:Creating a zarr.buffer.gpu.*:UserWarning",
8585
"ignore:Duplicate name:UserWarning", # from ZipFile
86+
"ignore:.*not part in the Zarr format 3.*:UserWarning",
8687
]
8788
markers = ["gpu: mark a test as requiring CuPy and GPU"]
8889

python/zarrs/pipeline.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,9 +233,9 @@ def _raise_error_on_unsupported_batch_dtype(
233233
],
234234
):
235235
# https://github.com/LDeakin/zarrs/blob/0532fe983b7b42b59dbf84e50a2fe5e6f7bad4ce/zarrs_metadata/src/v2_to_v3.rs#L289-L293 for VSUMm
236-
# Further, our pipeline does not support variable-length objects due to limitations on decode_into, so object is also out
236+
# Further, our pipeline does not support variable-length objects due to limitations on decode_into, so object/np.dtypes.StringDType is also out
237237
if any(
238-
info.dtype.kind in {"V", "S", "U", "M", "m", "O"}
238+
info.dtype.kind in {"V", "S", "U", "M", "m", "O", "T"}
239239
for (_, info, _, _, _) in batch_info
240240
):
241241
raise UnsupportedDataTypeError()

tests/test_vlen.py

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,14 @@
22

33
import numpy as np
44
import pytest
5-
from zarr import Array
5+
import zarr
66
from zarr.abc.codec import Codec
77
from zarr.abc.store import Store
8-
from zarr.codecs import VLenBytesCodec, VLenUTF8Codec, ZstdCodec
8+
from zarr.codecs import ZstdCodec
99
from zarr.core.metadata.v3 import ArrayV3Metadata, DataType
1010
from zarr.core.strings import _NUMPY_SUPPORTS_VLEN_STRING
1111
from zarr.storage import StorePath
1212

13-
pytest.skip(allow_module_level=True)
14-
1513
numpy_str_dtypes: list[type | str | None] = [None, str, "str", np.dtypes.StrDType]
1614
expected_zarr_string_dtype: np.dtype[Any]
1715
if _NUMPY_SUPPORTS_VLEN_STRING:
@@ -21,30 +19,28 @@
2119
expected_zarr_string_dtype = np.dtype("O")
2220

2321

24-
@pytest.mark.parametrize("store", ["memory", "local"], indirect=["store"])
22+
@pytest.mark.parametrize("store", ["local"], indirect=["store"])
2523
@pytest.mark.parametrize("dtype", numpy_str_dtypes)
2624
@pytest.mark.parametrize("as_object_array", [False, True])
27-
@pytest.mark.parametrize(
28-
"codecs", [None, [VLenUTF8Codec()], [VLenUTF8Codec(), ZstdCodec()]]
29-
)
25+
@pytest.mark.parametrize("compressor", [None, ZstdCodec()])
3026
def test_vlen_string(
31-
*,
3227
store: Store,
33-
dtype: None | np.dtype[Any],
28+
dtype: np.dtype[Any] | None,
29+
*,
3430
as_object_array: bool,
35-
codecs: None | list[Codec],
31+
compressor: Codec | None,
3632
) -> None:
3733
strings = ["hello", "world", "this", "is", "a", "test"]
3834
data = np.array(strings, dtype=dtype).reshape((2, 3))
3935

4036
sp = StorePath(store, path="string")
41-
a = Array.create(
37+
a = zarr.create_array(
4238
sp,
4339
shape=data.shape,
44-
chunk_shape=data.shape,
40+
chunks=data.shape,
4541
dtype=data.dtype,
4642
fill_value="",
47-
codecs=codecs,
43+
compressors=compressor,
4844
)
4945
assert isinstance(a.metadata, ArrayV3Metadata) # needed for mypy
5046

@@ -59,33 +55,31 @@ def test_vlen_string(
5955
assert a.dtype == expected_zarr_string_dtype
6056

6157
# test round trip
62-
b = Array.open(sp)
58+
b = zarr.open(sp)
6359
assert isinstance(b.metadata, ArrayV3Metadata) # needed for mypy
6460
assert np.array_equal(data, b[:, :])
6561
assert b.metadata.data_type == DataType.string
6662
assert a.dtype == expected_zarr_string_dtype
6763

6864

69-
@pytest.mark.parametrize("store", ["memory", "local"], indirect=["store"])
65+
@pytest.mark.parametrize("store", ["local"], indirect=["store"])
7066
@pytest.mark.parametrize("as_object_array", [False, True])
71-
@pytest.mark.parametrize(
72-
"codecs", [None, [VLenBytesCodec()], [VLenBytesCodec(), ZstdCodec()]]
73-
)
67+
@pytest.mark.parametrize("compressor", [None, ZstdCodec()])
7468
def test_vlen_bytes(
75-
*, store: Store, as_object_array: bool, codecs: None | list[Codec]
69+
store: Store, *, as_object_array: bool, compressor: Codec | None
7670
) -> None:
7771
bstrings = [b"hello", b"world", b"this", b"is", b"a", b"test"]
7872
data = np.array(bstrings).reshape((2, 3))
7973
assert data.dtype == "|S5"
8074

8175
sp = StorePath(store, path="string")
82-
a = Array.create(
76+
a = zarr.create_array(
8377
sp,
8478
shape=data.shape,
85-
chunk_shape=data.shape,
79+
chunks=data.shape,
8680
dtype=data.dtype,
8781
fill_value=b"",
88-
codecs=codecs,
82+
compressors=compressor,
8983
)
9084
assert isinstance(a.metadata, ArrayV3Metadata) # needed for mypy
9185

@@ -99,7 +93,7 @@ def test_vlen_bytes(
9993
assert a.dtype == "O"
10094

10195
# test round trip
102-
b = Array.open(sp)
96+
b = zarr.open(sp)
10397
assert isinstance(b.metadata, ArrayV3Metadata) # needed for mypy
10498
assert np.array_equal(data, b[:, :])
10599
assert b.metadata.data_type == DataType.bytes

0 commit comments

Comments
 (0)