MCPcopy
hub / github.com/numpy/numpy / do

Method do

numpy/linalg/tests/test_linalg.py:1247–1265  ·  view source on GitHub ↗
(self, a, b, tags)

Source from the content-addressed store, hash-verified

1245class TestEighCases(HermitianTestCase, HermitianGeneralizedTestCase):
1246
1247 def do(self, a, b, tags):
1248 # note that eigenvalue arrays returned by eig must be sorted since
1249 # their order isn't guaranteed.
1250 res = linalg.eigh(a)
1251 ev, evc = res.eigenvalues, res.eigenvectors
1252 evalues, evectors = linalg.eig(a)
1253 evalues.sort(axis=-1)
1254 assert_almost_equal(ev, evalues)
1255
1256 assert_allclose(matmul(a, evc),
1257 np.asarray(ev)[..., None, :] * np.asarray(evc),
1258 rtol=get_rtol(ev.dtype))
1259
1260 ev2, evc2 = linalg.eigh(a, 'U')
1261 assert_almost_equal(ev2, evalues)
1262
1263 assert_allclose(matmul(a, evc2),
1264 np.asarray(ev2)[..., None, :] * np.asarray(evc2),
1265 rtol=get_rtol(ev.dtype), err_msg=repr(a))
1266
1267
1268class TestEigh:

Callers

nothing calls this directly

Calls 5

assert_almost_equalFunction · 0.90
assert_allcloseFunction · 0.90
matmulFunction · 0.90
get_rtolFunction · 0.85
sortMethod · 0.45

Tested by

no test coverage detected