MCPcopy Index your code
hub / github.com/numpy/numpy / do

Method do

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

Source from the content-addressed store, hash-verified

743class SVDHermitianCases(HermitianTestCase, HermitianGeneralizedTestCase):
744
745 def do(self, a, b, tags):
746 u, s, vt = linalg.svd(a, False, hermitian=True)
747 assert_allclose(a, matmul(np.asarray(u) * np.asarray(s)[..., None, :],
748 np.asarray(vt)),
749 rtol=get_rtol(u.dtype))
750
751 def hermitian(mat):
752 axes = list(range(mat.ndim))
753 axes[-1], axes[-2] = axes[-2], axes[-1]
754 return np.conj(np.transpose(mat, axes=axes))
755
756 expected = np.broadcast_to(np.eye(u.shape[-1]), u.shape)
757 assert_almost_equal(np.matmul(u, hermitian(u)), expected)
758 expected = np.broadcast_to(np.eye(vt.shape[-1]), vt.shape)
759 assert_almost_equal(np.matmul(vt, hermitian(vt)), expected)
760 assert_equal(np.sort(s)[..., ::-1], s)
761 assert_(consistent_subclass(u, a))
762 assert_(consistent_subclass(vt, a))
763
764
765class TestSVDHermitian(SVDHermitianCases, SVDBaseTests):

Callers

nothing calls this directly

Calls 8

assert_allcloseFunction · 0.90
matmulFunction · 0.90
assert_almost_equalFunction · 0.90
assert_equalFunction · 0.90
assert_Function · 0.90
get_rtolFunction · 0.85
consistent_subclassFunction · 0.85
sortMethod · 0.45

Tested by

no test coverage detected