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

Method test_empty_a_b

numpy/linalg/tests/test_linalg.py:973–986  ·  view source on GitHub ↗
(self, m, n, n_rhs)

Source from the content-addressed store, hash-verified

971 (0, 0, 0)
972 ])
973 def test_empty_a_b(self, m, n, n_rhs):
974 a = np.arange(m * n).reshape(m, n)
975 b = np.ones((m, n_rhs))
976 x, residuals, rank, s = linalg.lstsq(a, b, rcond=None)
977 if m == 0:
978 assert_((x == 0).all())
979 assert_equal(x.shape, (n, n_rhs))
980 assert_equal(residuals.shape, ((n_rhs,) if m > n else (0,)))
981 if m > n and n_rhs > 0:
982 # residuals are exactly the squared norms of b's columns
983 r = b - np.dot(a, x)
984 assert_almost_equal(residuals, (r * r).sum(axis=-2))
985 assert_equal(rank, min(m, n))
986 assert_equal(s.shape, (min(m, n),))
987
988 def test_incompatible_dims(self):
989 # use modified version of docstring example

Callers

nothing calls this directly

Calls 8

assert_Function · 0.90
assert_equalFunction · 0.90
assert_almost_equalFunction · 0.90
reshapeMethod · 0.80
dotMethod · 0.80
minFunction · 0.50
allMethod · 0.45
sumMethod · 0.45

Tested by

no test coverage detected