'Test gradient for matrix_frac'

def test_matrix_frac(self):

    expr = matrix_frac(self.A, self.B)
    self.A.value = np.eye(2)
    self.B.value = np.eye(2)
    self.assertItemsAlmostEqual(expr.grad[self.A].todense(), [2, 0, 0, 2])
    self.assertItemsAlmostEqual(expr.grad[self.B].todense(), [(-1), 0, 0, (-1)])
    self.B.value = np.zeros((2, 2))
    self.assertAlmostEqual(expr.grad[self.A], None)
    self.assertAlmostEqual(expr.grad[self.B], None)
    expr = matrix_frac(self.x, self.A)
    self.x.value = [2, 3]
    self.A.vaule = np.eye(2)
    self.assertItemsAlmostEqual(expr.grad[self.x].todense(), [4, 6])
    self.assertItemsAlmostEqual(expr.grad[self.A].todense(), [(-4), (-6), (-6), (-9)])
