pydata / pydata/xarray

Broadcast does not return Datasets with unified chunks

Open
#5,435 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

topic-dask
Dominant language
Python
Stars
4.2k
Forks
1.4k
Avg merge
2d 15h
Merged PRs (30d)
14

Description

What happened:
If I broadcast a Dataset with chunked DataArrays, the resulting DataArrays are chunked differently.

What you expected to happen:
If I broadcast a dataset with 2 vectors of chunk size 1, I'd expect to get 2D arrays with chunksize (1, 1), rather than (1, N) and (M, 1).

Minimal Complete Verifiable Example:

import xarray as xr
ds = xr.Dataset({i: xr.DataArray(range(i*10), dims=f"dim_{i}").chunk(1) for i in range(1, 3)})
ds.broadcast_like(ds)
<xarray.Dataset>
Dimensions:  (dim_1: 10, dim_2: 20)
Dimensions without coordinates: dim_1, dim_2
Data variables:
    1        (dim_1, dim_2) int64 dask.array<chunksize=(1, 20), meta=np.ndarray>
    2        (dim_1, dim_2) int64 dask.array<chunksize=(10, 1), meta=np.ndarray>

Anything else we need to know?:

Environment:

Output of xr.show_versions()

INSTALLED VERSIONS

commit: None
python: 3.9.5 (default, May 18 2021, 19:34:48)
[GCC 7.3.0]
python-bits: 64
OS: Linux
OS-release: 5.8.0-53-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: ('en_US', 'UTF-8')
libhdf5: None
libnetcdf: None

xarray: 0.18.2
pandas: 1.2.4
numpy: 1.20.3
scipy: None
netCDF4: None
pydap: None
h5netcdf: None
h5py: None
Nio: None
zarr: None
cftime: None
nc_time_axis: None
PseudoNetCDF: None
rasterio: None
cfgrib: None
iris: None
bottleneck: None
dask: 2021.05.1
distributed: 2021.05.1
matplotlib: None
cartopy: None
seaborn: None
numbagg: None
pint: None
setuptools: 52.0.0.post20210125
pip: 21.1.2
conda: None
pytest: None
IPython: 7.24.1
sphinx: None

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the minimal example through Dataset.broadcast_like and inspect the resulting DataArray chunks. The fix is complete when broadcasting the two chunked vectors produces 2D arrays with chunksize (1, 1), as expected in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.