【发布时间】:2021-10-08 08:39:24
【问题描述】:
我有一个 NumPy 数组,其中包含一个略大于 260 的数字,我正在其上运行来自 scipy.special 的 gamma ufunc,它当前返回数组的此条目的 inf,因为结果结束1e514,Python 通常可以处理的最大浮点数约为 1.8e308。我尝试将我的数组更改为 float128 类型,希望这可以解决问题,但是不,这会导致我收到错误:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: ufunc 'gamma' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
有没有办法解决这个错误,还是 Python ufunc 无法处理超过 1.8e308 的所有浮点数?
【问题讨论】:
标签: python floating-point numpy-ufunc