def test_wrong_coefficient_matrix(self): x = vector() y = vector() z = scalar() b = lstsq(x, y, z) f = function([x, y, z], b) with pytest.raises(np.linalg.linalg.LinAlgError): f([2, 1], [2, 1], 1)
def test_wrong_rcond_dimension(self): x = vector() y = vector() z = vector() b = lstsq(x, y, z) f = function([x, y, z], b) with pytest.raises(np.linalg.LinAlgError): f([2, 1], [2, 1], [2, 1])
def test_correct_solution(self): x = lmatrix() y = lmatrix() z = lscalar() b = lstsq(x, y, z) f = function([x, y, z], b) TestMatrix1 = np.asarray([[2, 1], [3, 4]]) TestMatrix2 = np.asarray([[17, 20], [43, 50]]) TestScalar = np.asarray(1) f = function([x, y, z], b) m = f(TestMatrix1, TestMatrix2, TestScalar) assert np.allclose(TestMatrix2, np.dot(TestMatrix1, m[0]))