Skip to content

[v3] Missing array method on groups #2028

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

Closed
tomwhite opened this issue Jul 11, 2024 · 5 comments · Fixed by #2042
Closed

[v3] Missing array method on groups #2028

tomwhite opened this issue Jul 11, 2024 · 5 comments · Fixed by #2042
Labels
bug Potential issues with the zarr-python library

Comments

@tomwhite
Copy link
Contributor

Zarr version

3.0.0a1

Numcodecs version

0.12.1

Python Version

3.11.9

Operating System

Mac

Installation

pip

Description

There is no Group.array method in v3, which is a fairly common way of creating nested arrays.

Steps to reproduce

>>> import numpy as np
>>> import zarr.v2 as zarr
>>> a = np.arange(100000000).reshape(10000, 10000)
>>> root = zarr.group()
>>> root.array("a", a)
<zarr.v2.core.Array '/a' (10000, 10000) int64>
>>> import zarr
>>> root = zarr.group()
>>> root.array("a", a)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'Group' object has no attribute 'array'. Did you mean: 'arrays'?

Additional output

No response

@tomwhite tomwhite added the bug Potential issues with the zarr-python library label Jul 11, 2024
@d-v-b
Copy link
Contributor

d-v-b commented Jul 11, 2024

this functionality is handled by Group.create_array (that's the async function, which is wrapped by a method with the same name on the synchronous group class)

@tomwhite
Copy link
Contributor Author

It's an incompatible change - and it doesn't allow the data to be passed in to the function.

@d-v-b
Copy link
Contributor

d-v-b commented Jul 11, 2024

noted. my personal view is that create_array is a better name for this routine than array and so long-term that function should be what people use, and I do think create_array should be changed to take a data parameter. As a stop-gap measure for v2 compatibility, perhaps we could implement SyncGroup.array as a wrapper around SyncGroup.create_array, with a loud deprecation warning? Not sure what the deprecation window should be.

thoughts @jhamman ?

@rabernat
Copy link
Contributor

I strongly favor not breaking existing public Zarr API with the V3 release as much as feasible. Doing so will make users unhappy. Yes the API may be too broad. So let's deprecate things carefully, rather than releasing breaking changes.

@d-v-b
Copy link
Contributor

d-v-b commented Jul 16, 2024

@tomwhite I started working on this over here. Feel free to weigh in on that branch, or on the PR it will become in a few days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Potential issues with the zarr-python library
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants