Cast fill value to array's dtype #2020
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In v3 right now, we don't apply any parsing or validation to the
fill_value
attribute of an array. This PR fixes that.In this PR, the
fill_value
is cast to an instance of the array's dtype, using normal numpy dtype casting semantics. I also added JSON serialization for complex dtypes, but this is not tested yet. I will add those tests as part of a later refactor of the metadata tests.For v2 arrays, I am importing the v2 fill value parsing function and wrapping it in a very light wrapper. This preserves all the v2 behavior.
I also added a
fill_value
attribute to theArray
class. Happy to remove this if it's not supposed to be there.I put the metadata tests in a new directory structure:
tests/v3/metadata/test_v2.py
for v2 stuff andtests/v3/metadata/test_v3.py
for v3 stuff. This keeps the v2 and v3 logic separated, and removes the need to name functionstest_foo_v3
and the like. We should ultimately use an analogous layout in the library code.Longer term we should support the raw bits datatypes defined in the zarr v3 spec, but I don't think we need that now.
TODO: