'Test indexing with boolean arrays.'

def test_logical_indices(self):

    A = np.array([[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]])
    C = Constant(A)
    expr = C[(A <= 2)]
    self.assertEqual(expr.size, (2, 1))
    self.assertEqual(expr.sign, s.POSITIVE)
    self.assertItemsAlmostEqual(A[(A <= 2)], expr.value)
    expr = C[((A % 2) == 0)]
    self.assertEqual(expr.size, (6, 1))
    self.assertEqual(expr.sign, s.POSITIVE)
    self.assertItemsAlmostEqual(A[((A % 2) == 0)], expr.value)
    expr = C[(np.array([True, False, True]), 3)]
    self.assertEqual(expr.size, (2, 1))
    self.assertEqual(expr.sign, s.POSITIVE)
    self.assertItemsAlmostEqual(A[(np.array([True, False, True]), 3)], expr.value)
    expr = C[(1, np.array([True, False, False, True]))]
    self.assertEqual(expr.size, (2, 1))
    self.assertEqual(expr.sign, s.POSITIVE)
    self.assertItemsAlmostEqual(A[(1, np.array([True, False, False, True]))], expr.value)
    expr = C[np.array([True, True, True]), 1:3]
    self.assertEqual(expr.size, (3, 2))
    self.assertEqual(expr.sign, s.POSITIVE)
    self.assertItemsAlmostEqual(A[np.array([True, True, True]), 1:3], expr.value)
    expr = C[1:(-1), np.array([True, False, True, True])]
    self.assertEqual(expr.size, (1, 3))
    self.assertEqual(expr.sign, s.POSITIVE)
    self.assertItemsAlmostEqual(A[1:(-1), np.array([True, False, True, True])], expr.value)
    expr = C[(np.array([True, True, True]), np.array([True, False, True, True]))]
    self.assertEqual(expr.size, (3, 1))
    self.assertEqual(expr.sign, s.POSITIVE)
    self.assertItemsAlmostEqual(A[(np.array([True, True, True]), np.array([True, False, True, True]))], expr.value)
