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 ·