8000 fixed testdet test. It failed due to eigvails failing in single preci… · numpy/numpy@76a1963 · GitHub
[go: up one dir, main page]

Skip to content

Commit 76a1963

Browse files
ovillellaspv
authored andcommitted
fixed testdet test. It failed due to eigvails failing in single precision and notifying the failure as nans.
1 parent 866d230 commit 76a1963

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

numpy/core/tests/test_gufuncs_linalg.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@
6767

6868
old_assert_almost_equal = assert_almost_equal
6969

70+
_highp = {
71+
single: double,
72+
double: double,
73+
csingle: cdouble,
74+
cdouble: cdouble
75+
}
7076

7177
def assert_almost_equal(a, b, **kw):
7278
if a.dtype.type in (single, csingle):
@@ -245,7 +251,9 @@ def do(self, a, b):
245251
d = gula.det(a)
246252
s, ld = gula.slogdet(a)
247253
assert_almost_equal(s * np.exp(ld), d)
248-
ev = gula.eigvals(a)
254+
# use eigvals in high-precision. This way problems in the complex single
255+
# test is avoided as eigvals fails in there.
256+
ev = gula.eigvals(a.astype(_highp[a.dtype.type])).astype(a.dtype.type)
249257
assert_almost_equal(d, multiply.reduce(ev, axis=(ev.ndim-1)))
250258
assert_almost_equal(s * np.exp(ld), multiply.reduce(ev, axis=(ev.ndim-1)))
251259
if s != 0:

0 commit comments

Comments
 (0)
0