コード例 #1
0
ファイル: pobject.py プロジェクト: zz198808/bigflow
 def _operator_helper(self, other, op, reversed=False, isSop=False):
     if isSop:
         # single operand operators
         return self.map(lambda x: op(x))
     elif not isinstance(other, ptype.PType):
         if reversed:
             return self.map(lambda x: op(other, x))
         else:
             return self.map(lambda x: op(x, other))
     else:
         return self.map(lambda x, other: op(x, other), other)
コード例 #2
0
ファイル: pobject.py プロジェクト: yangwei024/bigflow
 def _operator_helper(self, other, op, reversed=False, isSop=False):
     if isSop:
         # single operand operators
         return self.map(lambda x: op(x))
     elif not isinstance(other, ptype.PType):
         if reversed:
             return self.map(lambda x: op(other, x))
         else:
             return self.map(lambda x: op(x, other))
     else:
         return self.map(lambda x, other: op(x, other), other)
コード例 #3
0
def test_scalar_ops(data):
    from operator import add, sub, mul, truediv

    for op in (add, sub, mul, truediv):
        assert eq(compute(op(t.amount, 10), data), op(x['amount'], 10))
        assert eq(compute(op(t.amount, t.id), data), op(x['amount'], x['id']))
        assert eq(compute(op(10.0, t.amount), data), op(10.0, x['amount']))
        assert eq(compute(op(10, t.amount), data), op(10, x['amount']))
コード例 #4
0
def test_scalar_ops(data):
    from operator import add, sub, mul, truediv

    for op in (add, sub, mul, truediv):
        assert eq(compute(op(t.amount, 10), data), op(x['amount'], 10))
        assert eq(compute(op(t.amount, t.id), data), op(x['amount'], x['id']))
        assert eq(compute(op(10.0, t.amount), data), op(10.0, x['amount']))
        assert eq(compute(op(10, t.amount), data), op(10, x['amount']))
コード例 #5
0
def test_failing_floordiv(data):
    from operator import floordiv as op

    with pytest.raises(TypeError):
        assert eq(compute(op(t.amount, 10), data), op(x['amount'], 10))

    with pytest.raises(TypeError):
        assert eq(compute(op(t.amount, t.id), data), op(x['amount'], x['id']))

    with pytest.raises(TypeError):
        assert eq(compute(op(10.0, t.amount), data), op(10.0, x['amount']))

    with pytest.raises(TypeError):
        assert eq(compute(op(10, t.amount), data), op(10, x['amount']))
コード例 #6
0
def test_failing_floordiv(data):
    from operator import floordiv as op

    with pytest.raises(TypeError):
        assert eq(compute(op(t.amount, 10), data), op(x['amount'], 10))

    with pytest.raises(TypeError):
        assert eq(compute(op(t.amount, t.id), data), op(x['amount'], x['id']))

    with pytest.raises(TypeError):
        assert eq(compute(op(10.0, t.amount), data), op(10.0, x['amount']))

    with pytest.raises(TypeError):
        assert eq(compute(op(10, t.amount), data), op(10, x['amount']))