Пример #1
0
 def test_AggByAppending(self):
     x = Coordinate(0)
     y = Coordinate(1)
     z = Coordinate(2)
     L = AggExpr(x)
     L.append(y)
     L.append(z)
     assert (L[0] == x and L[1] == y and L[2] == z)
Пример #2
0
    def test_InvalidAggInputAggWithinAgg(self):
        with pytest.raises(ValueError) as err_info:
            x = Coordinate(0)
            y = Coordinate(1)
            L1 = AggExpr(x)
            L2 = AggExpr(y, L1)

        print('detected expected exception: {}'.format(err_info))
        assert ('Agg within list' in str(err_info.value))
Пример #3
0
    def test_NoMultiplyingAggs2(self):
        with pytest.raises(ValueError) as err_info:
            x = Coordinate(0)
            y = Coordinate(1)
            L1 = AggExpr(x)
            L2 = AggExpr(y)
            f = L1 * L2

        print('detected expected exception: {}'.format(err_info))
        assert ('not compatible' in str(err_info.value))
Пример #4
0
    def test_InvalidAggInputNotAnExpr2(self):
        with pytest.raises(ValueError) as err_info:
            x = Coordinate(0)
            L = AggExpr((x, 'not an Expr'))

        print('detected expected exception: {}'.format(err_info))
        assert ('not convertible' in str(err_info.value))
Пример #5
0
 def test_AggFromNumpy(self):
     x = Coordinate(0)
     a = np.array([1, 2, 3])
     L = AggExpr(1, x, a)
     print(L)
     assert (L[0].sameas(ConstantScalarExpr(1)) and L[1] == x
             and L[2].sameas(ConstantVectorExpr(a)))
Пример #6
0
    def test_NoDividingOfAggs(self):
        with pytest.raises(ValueError) as err_info:
            x = Coordinate(0)
            L1 = AggExpr(x)
            f = L1 / 2

        print('detected expected exception: {}'.format(err_info))
        assert ('Dividing a list' in str(err_info.value))
Пример #7
0
    def test_NoNegatingAggs(self):
        with pytest.raises(ValueError) as err_info:
            x = Coordinate(0)
            L1 = AggExpr(x)
            f = -L1

        print('detected expected exception: {}'.format(err_info))
        assert ('cannot negate' in str(err_info.value))
Пример #8
0
    def test_NoAddingAggs1(self):
        with pytest.raises(ValueError) as err_info:
            x = Coordinate(0)
            y = Coordinate(1)
            L1 = AggExpr(x)
            f = y + L1

        print('detected expected exception: {}'.format(err_info))
        assert ('not compatible' in str(err_info.value))
Пример #9
0
    def test_DiffOpOfAgg(self):
        with pytest.raises(TypeError) as err_info:
            x = Coordinate(0)
            y = Coordinate(1)
            z = Coordinate(2)
            L = AggExpr(x, y, z)

            bad = Rot(L)

        print('detected expected exception: {}'.format(err_info))
        assert ('cannot accept' in str(err_info.value))
Пример #10
0
    def test_AggIter(self):
        x = Coordinate(0)
        a = np.array([1, 2, 3])
        a2 = Expr._convertToExpr(a)
        c = 1
        c2 = Expr._convertToExpr(c)
        L = AggExpr(c, x, a)
        tup = (c2, x, a2)
        same = True
        for e1, e2 in zip(L, tup):
            same = same and (e1.sameas(e2))

        assert (same)
Пример #11
0
 def test_AggComparison4(self):
     x = Coordinate(0)
     y = Coordinate(1)
     L1 = AggExpr(x, y)
     E2 = x + y
     assert (not L1.sameas(E2) and not E2.sameas(L1))
Пример #12
0
 def test_AggComparison3(self):
     x = Coordinate(0)
     y = Coordinate(1)
     L1 = AggExpr(x, y)
     L2 = AggExpr(x)
     assert (not L1.sameas(L2) and not L2.sameas(L1))
Пример #13
0
 def test_LengthOneAgg(self):
     x = Coordinate(0)
     L = AggExpr(x)
     assert (L[0] == x)
Пример #14
0
 def test_AggComparison2(self):
     x = Coordinate(0)
     y = Coordinate(1)
     L1 = AggExpr(x, y)
     L2 = AggExpr(y, x)
     assert (not L1.sameas(L2))
Пример #15
0
 def test_AggFromNumber2(self):
     x = Coordinate(0)
     L = AggExpr(1, x)
     assert (L[0].sameas(ConstantScalarExpr(1)) and L[1] == x)
Пример #16
0
 def test_AggFromNumber1(self):
     L = AggExpr(1)
     assert (L[0].sameas(ConstantScalarExpr(1)))
Пример #17
0
 def test_AggFromAgg(self):
     x = Coordinate(0)
     y = Coordinate(1)
     L = AggExpr([x, y])
     assert (L[0] == x and L[1] == y)
Пример #18
0
 def test_AggFromTuple(self):
     x = Coordinate(0)
     y = Coordinate(1)
     L = AggExpr((x, y))
     assert (L[0] == x and L[1] == y)
Пример #19
0
 def test_AggFromVArgs(self):
     x = Coordinate(0)
     y = Coordinate(1)
     L = AggExpr(x, y)
     assert (L[0] == x and L[1] == y)