logaddexp() of integer arrays gives float32, where NumPy gives float64
維護者通常 2 天內回覆
還沒有人認領這個 Issue。
評估
研究方向
閱讀 src/blosc2/ndarray.py 中的 logaddexp(),並將其整數結果 dtype 與 issue 中描述的 NumPy 行為進行比較。檢查直接呼叫和 blosc2.lazyexpr("logaddexp(a, b)", ...) 形式,並涵蓋列出的整數位元寬度。兩種形式都回傳相符的 dtype,並保留較大整數所示範的精度,即為完成。
由索引模型根據 Issue 內容生成。
描述
blosc2.logaddexp() sets the result dtype to float32 whenever its operands' result type is an integer (logaddexp() in src/blosc2/ndarray.py: if np.issubdtype(dtype, np.integer): dtype = blosc2.float32). NumPy uses the float type that holds the operands: float64 for 32- and 64-bit integers, float32 for 16-bit ones and float16 for 8-bit ones. The string form, blosc2.lazyexpr("logaddexp(a, b)", ...), gives float32 too. Larger integers lose precision:
import numpy as np
import blosc2
x = np.array([2**24 + 1]) # int64
a = blosc2.asarray(x)
blosc2.logaddexp(a, a).dtype # float32 NumPy: float64
blosc2.logaddexp(a, a)[:] # [16777218.] NumPy: [16777217.69314718]
| operands | blosc2 | NumPy |
|---|---|---|
| int8 | float32 | float16 |
| int16 | float32 | float32 |
| int32, int64, uint32 | float32 | float64 |
The same on main and with #741. Found while checking #754, which does not change logaddexp().
Bool operands raise TypeError: logaddexp doesn't accept boolean arguments., where NumPy gives float16. That may be on purpose, since the docstring asks for floating-point operands, as the array API does.
A fix could take the dtype from NumPy on empty operands, as #754 does for hypot() and the other two-argument float functions. I can send a PR for it if you like.
AI disclosure: the analysis was done with Claude Code; I reviewed it.
- 主要語言
- 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 小時 新手友好度 82/100
Blosc/python-blosc2#764 ·
維護者通常 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
-
[BUG]: Compliance rules never see Unity Catalog views as views可能已有人在做 @wagnercsantos 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 78/100
databrickslabs/ontos#1348 ·
維護者通常 3 天內回覆
-
`forum_pr_poster` action will always return `none` when checking for pre-existing feedback threads, even if a feedback thread already exists.可能已有人在做 @pgmzeta 今天認領。 未關閉E-Verified P-Major
難度 2/5 1-3 小時 新手友好度 79/100
goonstation/goonstation#28259 ·
維護者通常 2 天內回覆
-
enhancement
難度 2/5 1-3 小時 新手友好度 65/100
woonstadrotterdam/monumenten#70 ·
維護者通常 15 天內回覆
-
binding:python bug
難度 2/5 1-3 小時 新手友好度 82/100
維護者通常 1 天內回覆
-
The Browser tab fails with a Wayland error when Open Terminal runs from a Wayland desktop session未關閉
難度 2/5 1-3 小時 新手友好度 78/100
open-webui/open-terminal#210 ·