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, ir.array_type(t)) casted_literal = ibis.literal('5').cast(t).name('bar') assert isinstance(casted_literal, ir.scalar_type(t)) assert casted_literal.get_name() == 'bar'
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, ir.array_type(t)) casted_literal = ibis.literal("5").cast(t).name("bar") assert isinstance(casted_literal, ir.scalar_type(t)) assert casted_literal.get_name() == "bar"
def test_int_literal_cases(self): cases = [(5, 'int8'), (127, 'int8'), (128, 'int16'), (32767, 'int16'), (32768, 'int32'), (2147483647, 'int32'), (2147483648, 'int64'), (-5, 'int8'), (-128, 'int8'), (-129, 'int16'), (-32769, 'int32'), (-2147483649, 'int64'), (1.5, 'double'), ('foo', 'string')] for value, ex_type in cases: expr = ibis.literal(value) klass = ir.scalar_type(ex_type) assert isinstance(expr, klass) assert isinstance(expr.op(), ir.Literal) assert expr.op().value is value
def test_int_literal_cases(self): cases = [ (5, 'int8'), (127, 'int8'), (128, 'int16'), (32767, 'int16'), (32768, 'int32'), (2147483647, 'int32'), (2147483648, 'int64'), (-5, 'int8'), (-128, 'int8'), (-129, 'int16'), (-32769, 'int32'), (-2147483649, 'int64'), (1.5, 'double'), ('foo', 'string') ] for value, ex_type in cases: expr = ibis.literal(value) klass = ir.scalar_type(ex_type) assert isinstance(expr, klass) assert isinstance(expr.op(), ir.Literal) assert expr.op().value is value
def test_int_literal_cases(self): cases = [ (5, "int8"), (127, "int8"), (128, "int16"), (32767, "int16"), (32768, "int32"), (2147483647, "int32"), (2147483648, "int64"), (-5, "int8"), (-128, "int8"), (-129, "int16"), (-32769, "int32"), (-2147483649, "int64"), (1.5, "double"), ("foo", "string"), ] for value, ex_type in cases: expr = ibis.literal(value) klass = ir.scalar_type(ex_type) assert isinstance(expr, klass) assert isinstance(expr.op(), ir.Literal) assert expr.op().value is value
def output_type(self): # Scalar but type of caller return ir.scalar_type(self.args[0].type())
def _min_max_output_rule(self): arg = self.args[0] if isinstance(arg, ir.DecimalValue): return _decimal_scalar_ctor(arg._precision, 38) else: return ir.scalar_type(arg.type())
def shape_like_args(args, out_type): if util.any_of(args, ir.ArrayExpr): return ir.array_type(out_type) else: return ir.scalar_type(out_type)
def shape_like(arg, out_type): if isinstance(arg, ir.ScalarExpr): return ir.scalar_type(out_type) else: return ir.array_type(out_type)