You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I don't actually know what you call this, but I'm calling it dot syntax for accessing arrays. With zarr version 2.18.4, I can do the following:
importzarrimportnumpyasnpz=zarr.open("two.zarr",mode="w")
d=z.create_dataset("d",shape=(2),dtype=np.int32)
# this works!z.d
But with zarr version 3.0.6, the following throws an exception:
importzarrimportnumpyasnpz=zarr.open("three.zarr",mode="w")
d=z.create_array("d",shape=(2),dtype=np.int32)
# this now throws the exception "AttributeError: 'Group' object has no attribute 'd'"z.d
Is this expected? Unexpected? I didn't see anything in the 3.0 Migration Guide, but it wouldn't surprise me if I missed something.
Steps to reproduce
importzarrimportnumpyasnpz=zarr.open("three.zarr",mode="w")
d=z.create_array("d",shape=(2),dtype=np.int32)
# this now throws the exception "AttributeError: 'Group' object has no attribute 'd'"z.d
For context, IIRC it was removed because many IDEs (e.g. JupyterLab, VCCode) will introspect python objects to provide auto-completion. With this dot syntax, that would actually trigger listing of groups, reading metadata, etc. operations with significant side effects and performance implications.
Interesting! I never personally ran into the IDE issue in Visual Studio Code, but I can see how it could be painful. I think I've used both g.x and g["x"] syntax without thinking terribly deeply about it, so I don't think I'll miss the "." syntax. I'm more concerned that finding all the instances where we used "." syntax is going to be tricky because it's not something you can just grep for. But if it's causing that many issues with IDEs, then I understand why you've dropped it.
Activity
d-v-b commentedon Apr 16, 2025
hi @christine-e-smit, yes the "." syntax for getting group members has been removed in 3.0. To get a member of a group named
"foo", usegroup["foo"]I suspect we simply failed to mention this in the migration guide. I can fix this shortly.
christine-e-smit commentedon Apr 17, 2025
Thank you for the clarification. I've submitted a pull request with some suggested language for the documentation.
rabernat commentedon Apr 17, 2025
@christine-e-smit - did you find this syntax valuable?
For context, IIRC it was removed because many IDEs (e.g. JupyterLab, VCCode) will introspect python objects to provide auto-completion. With this dot syntax, that would actually trigger listing of groups, reading metadata, etc. operations with significant side effects and performance implications.
christine-e-smit commentedon Apr 17, 2025
Interesting! I never personally ran into the IDE issue in Visual Studio Code, but I can see how it could be painful. I think I've used both
g.xandg["x"]syntax without thinking terribly deeply about it, so I don't think I'll miss the "." syntax. I'm more concerned that finding all the instances where we used "." syntax is going to be tricky because it's not something you can just grep for. But if it's causing that many issues with IDEs, then I understand why you've dropped it.