MCPcopy Create free account
hub / github.com/numpy/numpy / check_qr

Method check_qr

numpy/linalg/tests/test_linalg.py:1637–1674  ·  view source on GitHub ↗
(self, a)

Source from the content-addressed store, hash-verified

1635 array = np.array
1636
1637 def check_qr(self, a):
1638 # This test expects the argument `a` to be an ndarray or
1639 # a subclass of an ndarray of inexact type.
1640 a_type = type(a)
1641 a_dtype = a.dtype
1642 m, n = a.shape
1643 k = min(m, n)
1644
1645 # mode == 'complete'
1646 res = linalg.qr(a, mode='complete')
1647 Q, R = res.Q, res.R
1648 assert_(Q.dtype == a_dtype)
1649 assert_(R.dtype == a_dtype)
1650 assert_(isinstance(Q, a_type))
1651 assert_(isinstance(R, a_type))
1652 assert_(Q.shape == (m, m))
1653 assert_(R.shape == (m, n))
1654 assert_almost_equal(dot(Q, R), a)
1655 assert_almost_equal(dot(Q.T.conj(), Q), np.eye(m))
1656 assert_almost_equal(np.triu(R), R)
1657
1658 # mode == 'reduced'
1659 q1, r1 = linalg.qr(a, mode='reduced')
1660 assert_(q1.dtype == a_dtype)
1661 assert_(r1.dtype == a_dtype)
1662 assert_(isinstance(q1, a_type))
1663 assert_(isinstance(r1, a_type))
1664 assert_(q1.shape == (m, k))
1665 assert_(r1.shape == (k, n))
1666 assert_almost_equal(dot(q1, r1), a)
1667 assert_almost_equal(dot(q1.T.conj(), q1), np.eye(k))
1668 assert_almost_equal(np.triu(r1), r1)
1669
1670 # mode == 'r'
1671 r2 = linalg.qr(a, mode='r')
1672 assert_(r2.dtype == a_dtype)
1673 assert_(isinstance(r2, a_type))
1674 assert_almost_equal(r2, r1)
1675
1676
1677 @pytest.mark.parametrize(["m", "n"], [

Callers 2

test_qr_emptyMethod · 0.95

Calls 4

assert_Function · 0.90
assert_almost_equalFunction · 0.90
dotFunction · 0.90
minFunction · 0.50

Tested by

no test coverage detected