-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Open
Labels
bugneeds triageIssue that has not been reviewed by xarray team memberIssue that has not been reviewed by xarray team member
Description
What happened?
When opening a Zarr array created with a NumPy 2 StringDType the Xarray DataArray doesn't have the same chunks as the underlying Zarr array.
What did you expect to happen?
The Xarray chunking should be the same as the Zarr chunking. In the MVCE below, the chunking is the same if using a fixed-length unicode dtype (dtype="U").
Minimal Complete Verifiable Example
# /// script
# requires-python = ">=3.11"
# dependencies = [
# "xarray[complete]@git+https://github.com/pydata/xarray.git@main",
# "zarr",
# ]
# ///
#
# This script automatically imports the development branch of xarray to check for issues.
# Please delete this header if you have _not_ tested this script with `uv run`!
import numpy as np
import xarray as xr
import zarr
xr.show_versions()
# create chunked string array using zarr
root = zarr.create_group(store="g")
data = np.array([
["a", "b", "c", "d"],
["e", "f", "g", "h"],
["i", "j", "k", "l"],
["m", "n", "o", "p"],
], dtype="T")
a = root.create_array(name="a", data=data, chunks=(2, 2), dimension_names=["x", "y"])
# open with xarray and check chunk sizes
x = xr.open_zarr("g", consolidated=False)
assert x["a"].chunks == ((2, 2), (2, 2)) # failsSteps to reproduce
No response
MVCE confirmation
- Minimal example — the example is as focused as reasonably possible to demonstrate the underlying issue in xarray.
- Complete example — the example is self-contained, including all data and the text of any traceback.
- Verifiable example — the example copy & pastes into an IPython prompt or Binder notebook, returning the result.
- New issue — a search of GitHub Issues suggests this is not a duplicate.
- Recent environment — the issue occurs with the latest version of xarray and its dependencies.
Relevant log output
Anything else we need to know?
No response
Environment
Details
Metadata
Metadata
Assignees
Labels
bugneeds triageIssue that has not been reviewed by xarray team memberIssue that has not been reviewed by xarray team member