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

Method do

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

Source from the content-addressed store, hash-verified

915class LstsqCases(LinalgSquareTestCase, LinalgNonsquareTestCase):
916
917 def do(self, a, b, tags):
918 arr = np.asarray(a)
919 m, n = arr.shape
920 u, s, vt = linalg.svd(a, False)
921 x, residuals, rank, sv = linalg.lstsq(a, b, rcond=-1)
922 if m == 0:
923 assert_((x == 0).all())
924 if m <= n:
925 assert_almost_equal(b, dot(a, x))
926 assert_equal(rank, m)
927 else:
928 assert_equal(rank, n)
929 assert_almost_equal(sv, sv.__array_wrap__(s))
930 if rank == n and m > n:
931 expect_resids = (
932 np.asarray(abs(np.dot(a, x) - b)) ** 2).sum(axis=0)
933 expect_resids = np.asarray(expect_resids)
934 if np.asarray(b).ndim == 1:
935 expect_resids.shape = (1,)
936 assert_equal(residuals.shape, expect_resids.shape)
937 else:
938 expect_resids = np.array([]).view(type(x))
939 assert_almost_equal(residuals, expect_resids)
940 assert_(np.issubdtype(residuals.dtype, np.floating))
941 assert_(consistent_subclass(x, b))
942 assert_(consistent_subclass(residuals, b))
943
944
945class TestLstsq(LstsqCases):

Callers

nothing calls this directly

Calls 11

assert_Function · 0.90
assert_almost_equalFunction · 0.90
dotFunction · 0.90
assert_equalFunction · 0.90
absFunction · 0.85
consistent_subclassFunction · 0.85
dotMethod · 0.80
allMethod · 0.45
__array_wrap__Method · 0.45
sumMethod · 0.45
viewMethod · 0.45

Tested by

no test coverage detected