Uh oh!
There was an error while loading. Please reload this page.
fix: validate v3 dtypes when loading/creating v3 metadata - #2209
Conversation
| ) -> None: | ||
| shape_parsed = parse_shapelike(shape) | ||
| dtype_parsed = parse_dtype(dtype) | ||
| dtype_parsed = dtype # parsing is likely not needed here |
There was a problem hiding this comment.
| dtype_parsed=dtype# parsing is likely not needed here | |
| dtype_parsed=dtype |
The input type is already np.dtype[Any] so I don't think we need to parse this.
| def parse_dtype(data: npt.DTypeLike) -> np.dtype[Any]: | ||
| # todo: real validation | ||
| return np.dtype(data) |
There was a problem hiding this comment.
we now parse v2 and v3 dtypes differently.
| dtype=npst.scalar_dtypes().filter(lambda x: x.kind != "m"), | ||
| dtype=npst.scalar_dtypes().filter( | ||
| lambda x: (x.kind not in ["m", "M"]) and (x.byteorder not in [">"]) | ||
| ), |
There was a problem hiding this comment.
I concur. It's not being handled today
| async def test_datetime_metadata(fill_value: int, precision: str) -> None: | ||
| # @pytest.mark.parametrize("fill_value", [-1, 0, 1, 2932897]) | ||
| # @pytest.mark.parametrize("precision", ["ns", "D"]) | ||
| # async def test_datetime_metadata(fill_value: int, precision: str) -> None: |
There was a problem hiding this comment.
this test was creating an invalid dtype (datetime). We can leave it in place and bring it back when there is support for this dtype in v3.
| (0, "int16"), | ||
| (1e10, "uint64"), | ||
| (-999, "float32"), | ||
| (1e32, "float64"), |
There was a problem hiding this comment.
also add a test for NaN fill values
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Davis Bennett <davis.v.bennett@gmail.com>
Uh oh!
There was an error while loading. Please reload this page.
d-v-b
commented
Sep 23, 2024
this looks great, thanks! |
* v3: chore: update pre-commit hooks (zarr-developers#2222) fix: validate v3 dtypes when loading/creating v3 metadata (zarr-developers#2209) fix typo in store integration test (zarr-developers#2223) Basic Zarr-python 2.x compatibility changes (zarr-developers#2098) Make Group.arrays, groups compatible with v2 (zarr-developers#2213) Typing fixes to test_indexing (zarr-developers#2193) Default to RemoteStore for fsspec URIs (zarr-developers#2198) Make MemoryStore serialiazable (zarr-developers#2204) [v3] Implement Group methods for empty, full, ones, and zeros (zarr-developers#2210) implement `store.list_prefix` and `store._set_many` (zarr-developers#2064) Fixed codec for v2 data with no fill value (zarr-developers#2207)
This PR validates data types in v3 metadata. The behavior implemented raises an error if a data type outside of the current v3 spec is discovered in either a
zarr.jsonmetadata document or in theArrayconstructor.xref: #2200
TODO: