NDArray.__setitem__ raises AttributeError for list index keys
維護者通常 2 天內回覆
還沒有人認領這個 Issue。
評估
研究方向
從 src/blosc2/ndarray.py 中 NDArray.setitem 的進階索引分支開始,特別檢查第 5106–5108 行附近對純量布林鍵的檢查。將使用列表鍵和元組鍵的指定與正常運作的 NumPy 陣列案例進行比較。完成條件是這些指定不再引發 AttributeError,且既有的陣列鍵行為仍正常運作。
由索引模型根據 Issue 內容生成。
描述
Assigning with a fancy index that is a Python list, or a tuple that contains an index array or list, raises AttributeError (main d3bca9e5 and 4.14.1). Reading with the same keys works, and an index array as the whole key works too.
import blosc2, numpy as np
a = blosc2.zeros((20, 30, 40), dtype=np.float32)
idx = np.array([1, 3, 5])
a[idx] = np.ones((3, 30, 40), np.float32) # ok
a[[1, 3, 5]] = np.ones((3, 30, 40), np.float32) # AttributeError: 'list' object has no attribute 'shape'
a[[1, 3, 5], 3:17] = np.ones((3, 14, 40), np.float32) # AttributeError: 'tuple' object has no attribute 'shape'
a[idx, 3:17] = np.ones((3, 14, 40), np.float32) # AttributeError: 'tuple' object has no attribute 'shape'
a[2, [1, 3, 5]] = np.ones((3, 40), np.float32) # AttributeError: 'tuple' object has no attribute 'shape'
a[[1, 3, 5], 3:17] # reading works
Cause. The fancy-index branch of NDArray.__setitem__ checks for a scalar boolean key on the original key, key.shape == () and hasattr(key, "dtype") and ... (ndarray.py#L5106-L5108), which only works when key is a NumPy array. Testing isinstance(key, np.ndarray) (or getattr(key, "shape", None) == ()) first should be enough.
Found while testing write paths for #763; not fixed there to keep that PR to one change.
- 主要語言
- Python
- 星號
- 214
- 分支
- 72
- 平均合併
- 3 天 9 小時
- 30 天內合併 PR
- 24
環境準備
在瀏覽器裡用你自己的 GitHub 帳號啟動這個專案的開發容器。
- 沒有 Dockerfile 或 Docker Compose 檔案
- 沒有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
Blosc/python-blosc2 的其他 Issue
-
難度 2/5 1-3 小時 新手友好度 74/100
Blosc/python-blosc2#757 ·
維護者通常 2 天內回覆
-
難度 2/5 1-3 小時 新手友好度 68/100
Blosc/python-blosc2#731 ·
維護者通常 2 天內回覆
-
documentation sustain-2026
難度 2/5 1-3 小時 新手友好度 75/100
Blosc/python-blosc2#720 · 3 則留言 ·
維護者通常 2 天內回覆
-
sustain-2026
難度 2/5 1-3 小時 新手友好度 75/100
Blosc/python-blosc2#717 ·
維護者通常 2 天內回覆
-
documentation sustain-2026
難度 2/5 1-3 小時 新手友好度 80/100
Blosc/python-blosc2#714 ·
維護者通常 2 天內回覆
查看 Blosc/python-blosc2 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 76/100
hkust-nlp/Toolathlon#101 ·
-
enhancement good first issue
難度 2/5 1-3 小時 新手友好度 78/100
SkyTruth/cerulean-cloud#219 ·
-
area:security priority:low size:small
難度 2/5 1-3 小時 新手友好度 84/100
RonaldHensbergen/composable-data-stack#1217 ·
維護者通常 1 天內回覆
-
good first issue help wanted
難度 2/5 1-3 小時 新手友好度 88/100
blixvip/BlendClone#27 ·
-
難度 2/5 1-3 小時 新手友好度 74/100