在我的 python 代码中,我经常使用numpy.allclose
. 另一方面,除了这些检查之外,实现还能够处理多精度 ( mpmath.mpc
) 数字。如果我想为这些mpmath
数字运行验证码,我会得到类似
>>> check(H)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "module.py", line 19, in check_H
assert(numpy.allclose(H, I, rtol=rtol, atol=atol))
File "/home/gereon/python/numpy/core/numeric.py", line 2025, in allclose
xinf = isinf(x)
TypeError: ufunc 'isinf' not supported for the input types, and the inputs could
not be safely coerced to any supported types according to the casting rule ''safe''
检查两个多精度数组是否足够相等的最佳方法是什么?