Skip to content

Commit fc3d4c3

Browse files
rabernatshoyer
andauthored
Update xarray/backends/zarr.py
Co-authored-by: Stephan Hoyer <[email protected]>
1 parent c33c9d9 commit fc3d4c3

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

xarray/backends/zarr.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -311,13 +311,15 @@ def _get_zarr_dims_and_attrs(zarr_obj, dimension_key, try_nczarr):
311311
# Zarr V3 explicitly stores the dimension names in the metadata
312312
try:
313313
# if this exists, we are looking at a Zarr V3 array
314-
# convert None to empty tuple
315-
dimensions = zarr_obj.metadata.dimension_names or ()
316-
attributes = dict(zarr_obj.attrs)
317-
return dimensions, attributes
314+
metadata = zarr_obj.metadata
318315
except AttributeError:
319316
# continue to old code path
320317
pass
318+
else:
319+
# convert None to empty tuple
320+
dimensions = metadata.dimension_names or ()
321+
attributes = dict(zarr_obj.attrs)
322+
return dimensions, attributes
321323

322324
# Zarr arrays do not have dimensions. To get around this problem, we add
323325
# an attribute that specifies the dimension. We have to hide this attribute

0 commit comments

Comments
 (0)