Unable to run groupby, map after shuffle_to_chunks

オープン
#11,212 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
48/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
numpy, python
領域
data

調査の方向性

提供された MVCE を実行し、groupby("y").shuffle_to_chunks() と、それに続く groupby("y").map(...) のエントリポイントを追跡して、チャンクサイズが不明になる箇所に注目してください。compute_chunk_sizes() の前後でデータを比較し、その後、グループを反復処理して恒等関数を適用しても ValueError なしに完了することを確認してください。

索引モデルが issue の本文から書いたものです。

説明

bug needs triage
What happened?

ValueError: Array chunk size or shape is unknown. Possible solution with x.compute_chunk_sizes()

What did you expect to happen?

Able to successfully iterate over groups and apply a function

Minimal Complete Verifiable Example
# /// script
# requires-python = ">=3.11"
# dependencies = [
#   "xarray[complete]@git+https://github.com/pydata/xarray.git@main",
# ]
# ///
#
# 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 xarray as xr
xr.show_versions()
import dask.array as da
import numpy as np
import xarray as xr

data = da.ones((583753, 184), chunks=(18243, 12))

y = np.random.choice(np.array([1, 2, 3, 4, 5]), size=data.shape[0], replace=True)
d = xr.DataArray(data=data, coords={"y": y}, dims=["y", "x"])
d = d.groupby("y").shuffle_to_chunks()
d.data = d.data.compute_chunk_sizes()
d.groupby("y").map(lambda x: x)[
    0, 0].compute()  # ValueError: Array chunk size or shape is unknown. Possible solution with x.compute_chunk_sizes()
Steps 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

INSTALLED VERSIONS

commit: None
python: 3.12.12 | packaged by conda-forge | (main, Jan 27 2026, 00:01:15) [Clang 19.1.7 ]
python-bits: 64
OS: Darwin
OS-release: 25.3.0
machine: arm64
processor: arm
byteorder: little
LC_ALL: None
LANG: C.UTF-8
LOCALE: ('C', 'UTF-8')
libhdf5: 1.14.6
libnetcdf: None
xarray: 2026.2.0
pandas: 2.3.3
numpy: 1.26.4
scipy: 1.16.3
netCDF4: None
pydap: None
h5netcdf: 1.8.1
h5py: 3.15.1
zarr: 2.18.7
cftime: None
nc_time_axis: None
iris: None
bottleneck: None
dask: 2025.11.0
distributed: 2025.11.0
matplotlib: 3.10.8
cartopy: None
seaborn: 0.13.2
numbagg: None
fsspec: 2026.2.0
cupy: None
pint: 0.25.2
sparse: None
flox: 0.11.2
numpy_groupies: 0.11.3
setuptools: 82.0.0
pip: 26.0.1
conda: None
pytest: 9.0.2
mypy: None
IPython: 9.10.0
sphinx: None

主要言語
Python
スター
4.2k
フォーク
1.5k
平均マージ
2日 21時間
マージ済み PR(30日)
74

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

pydata/xarray のほかの issue

pydata/xarray の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。