

def test_simple_overdet_complex(self):
    for dtype in COMPLEX_DTYPES:
        a = np.array([[(1 + 2j), 2], [4, 5], [3, 4]], dtype=dtype)
        b = np.array([1, (2 + 4j), 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'):
                    res = (b - a.dot(x))
                    residuals = np.sum((res * res.conj()))
                else:
                    residuals = out[1]
                r = out[2]
                assert_((r == 2), ('expected efficient rank 2, got %s' % r))
                assert_allclose(abs(((dot(a, self) - 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.4831460674157303) + 0.258426966292135j), (0.921348314606741 + 0.292134831460674j)), rtol=(25 * np.finfo(a1.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_complex/VarMisuse@261/357 `x`->`self`