Boolean indexing when elements of mask shape are zero?
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 35/100
- issue の種類
- ドキュメント
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- python
調査の方向性
まずリンク先の Boolean Array Indexing セクションを読み、その後、NumPy、CuPy、array_api_strict、jax.numpy、PyTorch、dask.array について示されている挙動を比較します。仕様に、サイズ 0 のブールマスク次元が有効かどうか、およびバックエンドがどのような結果またはエラーを生成すべきかが明記されれば完了です。
索引モデルが issue の本文から書いたものです。
説明
The standard seems to allow elements of a boolean index's shape to be zero.
The size of each dimension in B must equal the size of the corresponding dimension in
Aor be0,
But I have read a few times, and I don't think it specifies what should happen in this case.
This returns an empty array in NumPy, CuPy, array_api_strict, and jax.numpy.
import array_api_strict as xp
x = xp.asarray([1, 2, 3])
i = xp.asarray([], dtype=xp.bool)
x[i] # array([], dtype=int64)
The behavior would follow from the usual rules if the index were integral, but it's not obvious to me that this should work for a boolean index of zero size. Indeed, PyTorch fails with:
IndexError: The shape of the mask [0] at index 0 does not match the shape of the indexed tensor [3] at index 0
and dask.array fails with:
ValueError: operands could not be broadcast together with shapes (3,) (0,)
If the NumPy behavior is desired, does it follow from the usual rule, or is it a special case? Either way, it would help to spell out the desired behavior to ensure consistency among backends.
- 主要言語
- Python
- スター
- 281
- フォーク
- 52
- PR マージ指標
- 30日以内にマージされた PR はありません
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
data-apis/array-api のほかの issue
-
難易度 1/5 1〜3時間 初心者へのやさしさ 88/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
-
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
-
Maintenance
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
data-apis/array-api の issue をすべて見る
似ている issue
-
documentation help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 90/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 90/100
simonw/sqlite-utils#872 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100