-
-
Notifications
You must be signed in to change notification settings - Fork 11.1k
Closed
Description
Describe the issue:
The following small script returns nan+nanj
for x
:
import numpy as np
a = np.diag([1+0j, 1])
np.exp(0)
x = np.linalg.det(a)
Commenting out the np.exp(0)
or running np.linalg.det(a)
again returns the correct result, i.e. 1+j0
.
I've encountered this in numpy 1.21.2 with CPUs that support AVX512 and MKL installed. It appears to be fixed in numpy 1.21.4 but I couldn't figure out which commit fixed it, so I reporting it here in case it was only fixed accidentally and other cases are lurking out there. Running numpy without MKL appears to avoid the bug.
When it fails, the call to np.linalg.det
prints out:
2158: RuntimeWarning: invalid value encountered in det
r = _umath_linalg.det(a, signature=signature)
Reproduce the code example:
import numpy as np
a = np.diag([1+0j, 1])
np.exp(0)
x = np.linalg.det(a)
assert x == 1
Error message:
2158: RuntimeWarning: invalid value encountered in det
r = _umath_linalg.det(a, signature=signature)
Traceback (most recent call last):
File "npexp.py", line 15, in <module>
assert x == 1
AssertionError
NumPy/Python version information:
1.21.2 3.9.7 (default, Sep 16 2021, 13:09:58)
[GCC 7.5.0]