BUG: `linalg.pinv` fails on integer input with `rtol=None`
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
研究方向
追蹤回溯指向 numpy/linalg/_linalg.py 中的 pinv,其中 finfo 收到了整數 dtype。閱讀 pinv 的實作以及附近針對整數輸入和 rtol=None 的測試;為回報中的呼叫補上測試,並確認它會傳回浮點單位矩陣,且不改變預設行為。
由索引模型根據 Issue 內容生成。
描述
Describe the issue:
np.linalg.pinv accepts an integer identity matrix with the default cutoff, but fails with rtol=None. Both calls should return the floating-point identity matrix.
Reproduce the code example:
import numpy as np
data = np.array([[1, 0], [0, 1]], dtype=np.int64)
print(np.linalg.pinv(data))
np.linalg.pinv(data, rtol=None)
Error message:
[[1. 0.]
[0. 1.]]
Traceback (most recent call last):
File "/test.py", line 5, in <module>
np.linalg.pinv(data, rtol=None)
~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
File "/home/xxx/anaconda3/envs/py314/lib/python3.14/site-packages/numpy/linalg/_linalg.py", line 2258, in pinv
rcond = max(a.shape[-2:]) * finfo(a.dtype).eps
~~~~~^^^^^^^^^
File "/home/xxx/anaconda3/envs/py314/lib/python3.14/site-packages/numpy/_core/getlimits.py", line 216, in __new__
obj = object.__new__(cls)._init(dtype)
File "/home/xxx/anaconda3/envs/py314/lib/python3.14/site-packages/numpy/_core/getlimits.py", line 226, in _init
_populate_finfo_constants(self, self.dtype)
~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
ValueError: data type dtype('int64') not compatible with finfo
Python and NumPy Versions:
2.5.5
3.14.10 | packaged by Anaconda, Inc. | (main, Oct 27 2026, 01:15:40) [GCC 14.3.0]
Runtime Environment:
2.5.5
3.14.10 | packaged by Anaconda, Inc. | (main, Oct 27 2026, 01:15:40) [GCC 14.3.0]
[{'numpy_version': '2.5.5',
'python': '3.14.10 | packaged by Anaconda, Inc. | (main, Oct 27 2026, '
'01:15:40) [GCC 14.3.0]',
'uname': uname_result(system='Linux', node='rog', release='6.17.0-29-generic', version='#29~24.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon May 11 10:30:58 UTC 2', machine='x86_64')},
{'simd_extensions': {'baseline': ['X86_V2'],
'found': ['X86_V3', 'X86_V4', 'AVX512_ICL'],
'not_found': ['AVX512_SPR']}},
{'ignore_floating_point_errors_in_matmul': False},
{'architecture': 'SkylakeX',
'filepath': '/home/jacin/anaconda3/envs/py314/lib/python3.14/site-packages/numpy.libs/libscipy_openblas64_-4b78795a.so',
'internal_api': 'openblas',
'num_threads': 16,
'prefix': 'libscipy_openblas',
'threading_layer': 'pthreads',
'user_api': 'blas',
'version': '0.3.34.237.2'}]
How does this issue affect you or how did you find it:
We are currently developing a computational framework based on NumPy. In the process of developing and testing this new framework, we encountered these practical issues, and we are submitting them in the hope that they can be resolved.
- 主要語言
- Python
- 星號
- 33.5k
- 分支
- 13.1k
- 平均合併
- 1 天 19 小時
- 30 天內合併 PR
- 143
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
numpy/numpy 的其他 Issue
-
00 - Bug
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆
-
00 - Bug
難度 2/5 1-3 小時 新手友好度 70/100
維護者通常 1 天內回覆
-
BUG: f2py treats a backslash as an escape inside character literals可能已有人在做 @HaoZeke 於 17 天前認領。 未關閉00 - Bug component: numpy.f2py
難度 2/5 1-3 小時 新手友好度 78/100
numpy/numpy#33220 · 2 則留言 · 已指派 1 人 ·
維護者通常 1 天內回覆
-
DOC: use CITATION.cff file format for citation information可能已有人在做 @JaroCamphuijsen 於 58 天前認領。 未關閉04 - Documentation
難度 2/5 1-3 小時 新手友好度 85/100
維護者通常 1 天內回覆
-
BUG: `np.trim_zeros` raises `TypeError` for multi-dimensional sequences可能已有人在做 @Aniketsy 於 94 天前認領。 未關閉00 - Bug
難度 2/5 1-3 小時 新手友好度 72/100
維護者通常 1 天內回覆
相似的 Issue
-
難度 1/5 1 小時以內 新手友好度 72/100
521xueweihan/HelloGitHub#4543 ·
-
難度 2/5 1-3 小時 新手友好度 83/100
emeryberger/CSrankings#15700 ·
維護者通常 2 天內回覆
-
Bug | 工作不正常 Triage | 待检查
難度 2/5 1-3 小時 新手友好度 77/100
OneDragon-Anything/ZenlessZoneZero-OneDragon#3084 ·
維護者通常 1 天內回覆
-
Task select patterns with uppercase letters never match可能已有人在做 @manobhisriram 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 76/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 76/100
維護者通常 1 天內回覆