'Test gradient for max_entries'

def test_max_entries(self):

    expr = max_entries(self.x)
    self.x.value = [2, 1]
    self.assertItemsAlmostEqual(expr.grad[self.x].todense(), [1, 0])
    expr = max_entries(self.A)
    self.A.value = np.matrix([[1, 2], [4, 3]])
    self.assertItemsAlmostEqual(expr.grad[self.A].todense(), [0, 1, 0, 0])
    expr = max_entries(self.A, axis=0)
    self.A.value = np.matrix([[1, 2], [4, 3]])
    self.assertItemsAlmostEqual(expr.grad[self.A].todense(), np.matrix([[0, 0], [1, 0], [0, 0], [0, 1]]))
    expr = max_entries(self.A, axis=1)
    self.A.value = np.matrix([[1, 2], [4, 3]])
    self.assertItemsAlmostEqual(expr.grad[self.A].todense(), np.matrix([[0, 0], [0, 1], [1, 0], [0, 0]]))
