-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Zarr: handle numpy.datetime64/timedelta64 extension types in V3 #13913
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
base: master
Are you sure you want to change the base?
Zarr: handle numpy.datetime64/timedelta64 extension types in V3 #13913
Conversation
| "shape": [3], | ||
| "data_type": { | ||
| "name": extension_name, | ||
| "configuration": {"unit": "ns", "scale_factor": 1}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should likely expose those configuration attributes as "data_type.unit" and "data_type.scale_factor" attributes so users can make sense of the array values
And looking at https://github.com/zarr-developers/zarr-extensions/tree/main/data-types/numpy.datetime64#fill-value-representation, the "NaT" fill_nodata value should be taken into account
It would also be worth enhancing the test to read actual (non-zero) array values to check that then endianness is correctly handled
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should likely expose those configuration attributes as "data_type.unit" and "data_type.scale_factor"
and also "data_type.name"
frmts/zarr/zarr_v3_array.cpp
Outdated
| elt.gdalType = GDALExtendedDataType::Create(GDT_Int64); | ||
| elt.gdalSize = elt.gdalType.GetSize(); | ||
| elt.nativeSize = elt.gdalSize; | ||
| if (elt.nativeSize > 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the if() test can be removed: the condition is always true
|
Thanks Even! Addressed those in a second commit. I'm less comfortable with the second part so here is a review summary from the digital friend, which might be interesting in its own right:
To consider: The The |
Zarr V3: support numpy.datetime64 extension data type, fixes missing extension support of #13912
Adds an else if branch in ParseDtypeV3 that handles JSON object extension types with "name": "numpy.datetime64" or "numpy.timedelta64", mapping them to GDT_Int64.
Adds three test cases to
autotest/gdrivers/zarr_driver.py:test_zarr_read_numpy_datetime64_extension_zarr_v3 — Parametrized over both numpy.datetime64 and numpy.timedelta64. Creates a synthetic V3 store with the extension type (no fallback key, matching what zarr-python 3.x writes). Asserts it opens and maps to GDT_Int64.
test_zarr_read_numpy_datetime64_unsupported_extension_zarr_v3 — Verifies that an unrecognized extension type (without fallback) correctly raises an error.
What are related issues/pull requests?
Fixes #13912 and relates to similar extension enhancement request #13912
Tasklist