コード例 #1
0
ファイル: test_value_exprs.py プロジェクト: wesm/ibis
def test_literal_promotions(table, op, name, case, ex_type):
    col = table[name]

    result = op(col, case)
    ex_class = dt.array_type(ex_type)
    assert isinstance(result, ex_class)

    result = op(case, col)
    ex_class = dt.array_type(ex_type)
    assert isinstance(result, ex_class)
コード例 #2
0
    def _check_literal_promote_cases(self, op, cases):
        for name, val, ex_type in cases:
            col = self.table[name]

            result = op(col, val)
            ex_class = dt.array_type(ex_type)
            assert isinstance(result, ex_class)

            result = op(val, col)
            ex_class = dt.array_type(ex_type)
            assert isinstance(result, ex_class)
コード例 #3
0
ファイル: test_value_exprs.py プロジェクト: hdfeos/ibis
    def _check_literal_promote_cases(self, op, cases):
        for name, val, ex_type in cases:
            col = self.table[name]

            result = op(col, val)
            ex_class = dt.array_type(ex_type)
            assert isinstance(result, ex_class)

            result = op(val, col)
            ex_class = dt.array_type(ex_type)
            assert isinstance(result, ex_class)
コード例 #4
0
def test_string_to_number(table, type):
    casted = table.g.cast(type)
    assert isinstance(casted, dt.array_type(type))

    casted_literal = ibis.literal('5').cast(type).name('bar')
    assert isinstance(casted_literal, dt.scalar_type(type))
    assert casted_literal.get_name() == 'bar'
コード例 #5
0
ファイル: test_value_exprs.py プロジェクト: wesm/ibis
def test_string_to_number(table, type):
    casted = table.g.cast(type)
    assert isinstance(casted, dt.array_type(type))

    casted_literal = ibis.literal("5").cast(type).name("bar")
    assert isinstance(casted_literal, dt.scalar_type(type))
    assert casted_literal.get_name() == "bar"
コード例 #6
0
    def test_string_to_number(self):
        types = ['int8', 'int32', 'double', 'float']

        for t in types:
            c = 'g'
            casted = self.table[c].cast(t)
            assert isinstance(casted, dt.array_type(t))

            casted_literal = ibis.literal('5').cast(t).name('bar')
            assert isinstance(casted_literal, dt.scalar_type(t))
            assert casted_literal.get_name() == 'bar'
コード例 #7
0
ファイル: test_value_exprs.py プロジェクト: hdfeos/ibis
    def test_string_to_number(self):
        types = ['int8', 'int32', 'double', 'float']

        for t in types:
            c = 'g'
            casted = self.table[c].cast(t)
            assert isinstance(casted, dt.array_type(t))

            casted_literal = ibis.literal('5').cast(t).name('bar')
            assert isinstance(casted_literal, dt.scalar_type(t))
            assert casted_literal.get_name() == 'bar'
コード例 #8
0
ファイル: test_table.py プロジェクト: zuxfoucault/ibis
    def test_getitem_column_select(self):
        for k, v in self.schema_dict.iteritems():
            col = self.table[k]

            # Make sure it's the right type
            assert isinstance(col, ArrayExpr)
            assert isinstance(col, array_type(v))

            # Ensure we have a field selection with back-reference to the table
            parent = col.parent()
            assert isinstance(parent, ops.TableColumn)
            assert parent.parent() is self.table
コード例 #9
0
ファイル: test_table.py プロジェクト: zuxfoucault/ibis
    def test_getitem_column_select(self):
        for k, v in self.schema_dict.iteritems():
            col = self.table[k]

            # Make sure it's the right type
            assert isinstance(col, ArrayExpr)
            assert isinstance(col, array_type(v))

            # Ensure we have a field selection with back-reference to the table
            parent = col.parent()
            assert isinstance(parent, ops.TableColumn)
            assert parent.parent() is self.table
コード例 #10
0
        (operator.pow, 'b', 1.5, 'double'),
        (operator.pow, 'c', 1.5, 'double'),
        (operator.pow, 'd', 1.5, 'double'),
        (operator.pow, 'e', 2, 'float'),
        (operator.pow, 'f', 2, 'double'),
        (operator.pow, 'a', -2, 'double'),
        (operator.pow, 'b', -2, 'double'),
        (operator.pow, 'c', -2, 'double'),
        (operator.pow, 'd', -2, 'double'),
    ],
    ids=lambda arg: str(getattr(arg, '__name__', arg)))
def test_literal_promotions(table, op, name, case, ex_type):
    col = table[name]

    result = op(col, case)
    ex_class = dt.array_type(ex_type)
    assert isinstance(result, ex_class)

    result = op(case, col)
    ex_class = dt.array_type(ex_type)
    assert isinstance(result, ex_class)


@pytest.mark.xfail(raises=AssertionError, reason='NYT')
def test_add_array_promotions():
    assert False


@pytest.mark.xfail(raises=AssertionError, reason='NYT')
def test_subtract_array_promotions():
    assert False