'Test indicator transform.'

def test_indicator(self):

    cons = [(self.a >= 0), (self.x == 2)]
    obj = cvxpy.Minimize((self.a - sum_entries(self.x)))
    expr = cvxpy.indicator(cons)
    assert expr.is_convex()
    assert expr.is_positive()
    prob = Problem((Minimize(expr) + obj))
    result = prob.solve()
    self.assertAlmostEqual((-4), result)
    self.assertAlmostEqual(0, self.a.value)
    self.assertItemsAlmostEqual([2, 2], self.x.value)
    self.assertAlmostEqual(0, expr.value)
    self.a.value = (-1)
    self.assertAlmostEqual(np.infty, expr.value)
