-
-
Notifications
You must be signed in to change notification settings - Fork 346
improvements to parse_dtype
#3264
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: main
Are you sure you want to change the base?
Conversation
…more JSON-like inputs, and test for round-trips
…into widen-parse-data-type
cc @TomNicholas |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3264 +/- ##
==========================================
+ Coverage 59.59% 59.62% +0.03%
==========================================
Files 78 78
Lines 8696 8702 +6
==========================================
+ Hits 5182 5189 +7
+ Misses 3514 3513 -1
🚀 New features to boost your workflow:
|
d684ada adds a test to ensure that |
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.
Nice - I like the name change. Having two identical functions in our API seems a bit confusing from a user POV: https://zarr--3264.org.readthedocs.build/en/3264/api/zarr/dtype/index.html#functions. Could you remove parse_data_type
from __all__
so it's removed from the docs, but will still be imported and work for backwards compatibility?
Interpret the input as a ZDType. | ||
|
||
This function wraps ``parse_dtype``. The only difference is the function name. This function may | ||
be deprecated in a future version of Zarr Python in favor of ``parse_dtype``. | ||
|
||
Parameters | ||
---------- | ||
dtype_spec : ZDTypeLike | ||
The input to be interpreted as a ZDType. This could be a ZDType, which will be returned | ||
directly, or a JSON representation of a ZDType, or a native dtype, or a python object that | ||
can be converted into a native dtype. | ||
zarr_format : ZarrFormat | ||
The Zarr format version. | ||
|
||
Returns | ||
------- | ||
ZDType[TBaseDType, TBaseScalar] | ||
The ZDType corresponding to the input. | ||
|
||
Examples | ||
-------- | ||
>>> parse_dtype("int32", zarr_format=2) | ||
Int32(endianness="little") | ||
""" |
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.
I'd say bin the docstirng here to avoid duplication, and just point to parse_dtype
.
NullTerminatedBytes(length=10) | ||
>>> parse_data_type({"name": "numpy.datetime64", "configuration": {"unit": "s", "scale_factor": 10}}, zarr_format=3) | ||
DateTime64(endianness='little', scale_factor=10, unit='s') | ||
>>> parse_dtype("int32", zarr_format=2) |
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.
Huh, does this not need an import? not an issue, just a question
@@ -84,4 +85,5 @@ | |||
"data_type_registry", | |||
"data_type_registry", | |||
"parse_data_type", |
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.
"parse_data_type", |
parse_dtype
.parse_data_type
is kept around but it just wrapsparse_dtype
. The reason for this change is naming consistency -- theZDType
methods already use the "dtype" abbreviation extensively, so it's potentially confusing thatparse_data_type
does not.parse_dtype
(with the exception of "|O", which is ambiguous).closes #3263