

def test_simple_overdet(self):
    for dtype in REAL_DTYPES:
        a = np.array([[1, 2], [4, 5], [3, 4]], dtype=dtype)
        b = np.array([1, 2, 3], dtype=dtype)
        for lapack_driver in TestLstsq.lapack_drivers:
            for overwrite in (True, False):
                a1 = a.copy()
                b1 = b.copy()
                try:
                    out = lstsq(a1, b1, lapack_driver=lapack_driver, overwrite_a=overwrite, overwrite_b=overwrite)
                except LstsqLapackError:
                    if (lapack_driver is None):
                        mesg = 'LstsqLapackError raised with lapack_driver being None.'
                        raise AssertionError(mesg)
                    else:
                        continue
                x = out[0]
                if (lapack_driver == 'gelsy'):
                    residuals = np.sum(((b - a.dot(x)) ** 2))
                else:
                    residuals = out[1]
                r = out[2]
                assert_((r == 2), ('expected efficient rank 2, got %s' % r))
                assert_allclose(abs(((dot(a, x) - b) ** 2)).sum(axis=0), residuals, rtol=(25 * np.finfo(a1.dtype).eps), atol=(25 * np.finfo(a1.dtype).eps), err_msg=('driver: %s' % lapack_driver))
                assert_allclose(x, ((- 0.428571428571429), 0.85714285714285), rtol=(25 * np.finfo(x.dtype).eps), atol=(25 * np.finfo(a1.dtype).eps), err_msg=('driver: %s' % lapack_driver))

dataset/ETHPy150Open scipy/scipy/scipy/linalg/tests/test_basic.py TestLstsq.test_simple_overdet/VarMisuse@329/447 `a1`->`x`