-
-
Notifications
You must be signed in to change notification settings - Fork 350
Parametrize Array with v2/v3 metadata #3304
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
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #3304 +/- ##
==========================================
+ Coverage 60.73% 60.79% +0.06%
==========================================
Files 78 79 +1
Lines 9407 9423 +16
==========================================
+ Hits 5713 5729 +16
Misses 3694 3694
🚀 New features to boost your workflow:
|
53da48a
to
d9e50d2
Compare
AsyncArrayV3: TypeAlias = AsyncArray[ArrayV3Metadata] | ||
"""A Zarr format 3 `AsyncArray`""" | ||
|
||
AnyArray: TypeAlias = Array[Any] |
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.
Should this be Array[ArrayV2Metadata] | Array[ArrayV3Metadata]
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.
Yep, I guess that's safer 👍
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 couldn't get that to work, beacuse of an error that I sort of but not really understand Any
is fine though - .metadata
still gets inferred correctly:
import zarr
import zarr.storage
arr = zarr.ones(shape=(1,))
meta = arr.metadata
reveal_locals()
"""
test.py:6: note: Revealed local types are:
test.py:6: note: arr: zarr.core.array.Array[Any]
test.py:6: note: meta: zarr.core.metadata.v2.ArrayV2Metadata | zarr.core.metadata.v3.ArrayV3Metadata
"""
It has been a longstanding bugbear of mine that there's no easy way to specify a v2 or v3 array type. This especially came up in the context of #3257, which deals specifically with v2/v3 arrays.
This PR ads type parametrization to the
Array
class.After this PR, there is lots of improvements to adding overloads to functions and methods that could be made, but to keep review easier I'd like to leave that for a follow up PR.