-
-
Notifications
You must be signed in to change notification settings - Fork 273
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
[v2 / v3 compat] add Group.array
and data
kwarg to array creation
#2042
Conversation
…unking; restore data kwarg to array creation
another change worth noting: in main we have some very thin array creation routines that just pass |
docs are failing but I don't think that's on me. |
I think the doc fails are on you. They are:
At a guess, it might be because you've used |
Are warnings failures? |
Yes |
(because warnings are caused by things that mess up formatting in the docs - sphinx can still generate docs if warnings are emitted, but they might not be formatted correctly, hence it is sensible to error the doc build on warnings) |
the doc failures were due to breaking a long type annotation into multiple lines. it should be fixed now. On the subect of docs, I don't think the sphinx error message was very clear, and I also don't think sphinx is doing a good job. See the below example. The function signature is very hard to read. For a different project I'm using Is there some way we can get sphinx to display API docs like this? |
src/zarr/array.py
Outdated
from zarr.sync import sync | ||
from zarr.v2.util import guess_chunks |
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 probably shouldn't import from zarr.v2
in v3 code.
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.
generally I agree, but the explicit goal here is v2 compatibility. we could re-implement the exact same code in the v3 codebase, but I think that has greater drawbacks.
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.
Didn't we decide to remove the zarr.v2
modules before releasing 3.0?
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.
on the other hand, it would be good to get this routine in v3 so that we can make improvements to it. So I'm +1 on removing the v2 import and porting the logic. I will make that change.
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.
Didn't we decide to remove the zarr.v2 modules before releasing 3.0?
yes, I think we did. that's another good reason to port this routine.
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.
5abaab6 brings guess_chunks
over to v3, and adds tests.
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.
Looks good. See my one comment on importing from zarr.v2
.
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.
Excellent!
this is not quite ready -- I realized that we are checking for pre-existing arrays, but not for pre-existing groups. fix + tests incoming. |
in In this PR, I added checks for groups or arrays (or both, in the case of v2), and created specific exceptions for both. I tried to implement the array / group checks in a way that's somewhat respectful of IO budget, which means that the functions for checking for groups / arrays returns |
data
keyword argument for array creation, matching the behavior from v2.data
isnpt.ArrayLike | None
, ifNone
(the default) an array is initialized as normal (i.e., only metadata is written). Otherwise, after creating array metadata, we will write the contents ofdata
to the array.array
method toGroup
, matching behavior from v2. this is basically an alias forGroup.create_array
, and has a deprecation warningMemoryStore.list_dir
that was revealed by the aforementioned testscontains_array
andcontains_group
functions that report on whether aStorePath
contains an array or group, respectively.errors.py
, a top-level module that containsContainsGroupError
andContainsArrayError
, which are much like the identically named classes from v2, but these ones also report the path to the container root in the error message which is much better than the v2 behavior of only reporting the name of the array / group.fixes #2028
cc @tomwhite
TODO: