'Test domain for exp.'

def test_exp(self):

    expr = exp(self.a)
    self.a.value = 2
    self.assertAlmostEqual(expr.grad[self.a], np.exp(2))
    self.a.value = 3
    self.assertAlmostEqual(expr.grad[self.a], np.exp(3))
    self.a.value = (-1)
    self.assertAlmostEqual(expr.grad[self.a], np.exp((-1)))
    expr = exp(self.x)
    self.x.value = [3, 4]
    val = (np.zeros((2, 2)) + np.diag(np.exp([3, 4])))
    self.assertItemsAlmostEqual(expr.grad[self.x].todense(), val)
    expr = exp(self.x)
    self.x.value = [(-1e-09), 4]
    val = (np.zeros((2, 2)) + np.diag(np.exp([(-1e-09), 4])))
    self.assertItemsAlmostEqual(expr.grad[self.x].todense(), val)
    expr = exp(self.A)
    self.A.value = [[1, 2], [3, 4]]
    val = (np.zeros((4, 4)) + np.diag(np.exp([1, 2, 3, 4])))
    self.assertItemsAlmostEqual(expr.grad[self.A].todense(), val)
