Beispiel #1
0
def test_struct_literal(value):
    typestr = "struct<field1: string, field2: float64>"
    a = ibis.struct(value, type=typestr)
    assert a.op().value == frozendict(
        field1=value['field1'], field2=value['field2']
    )
    assert a.type() == datatypes.dtype(typestr)
Beispiel #2
0
 def __create__(cls, *args, **kwargs):
     key = (cls, args, frozendict(kwargs))
     try:
         return cls.__instances__[key]
     except KeyError:
         instance = super().__create__(*args, **kwargs)
         cls.__instances__[key] = instance
         return instance
Beispiel #3
0
def test_singleton_basics():
    one = OneAndOnly()
    only = OneAndOnly()
    assert one is only

    assert len(OneAndOnly.__instances__) == 1
    key = (OneAndOnly, (), frozendict())
    assert OneAndOnly.__instances__[key] is one
Beispiel #4
0
 def __init__(self, table, replacements, **kwargs):
     super().__init__(
         table=table,
         replacements=(replacements if
                       not isinstance(replacements, collections.abc.Mapping)
                       else util.frozendict(replacements)),
         **kwargs,
     )
Beispiel #5
0
def _struct_to_frozendict(typ: Struct, values: Mapping) -> PythonDecimal:
    value_types = typ.pairs
    values = {
        k: _normalize(typ[k], v) for k, v in values.items() if k in value_types
    }
    return frozendict(values)
Beispiel #6
0
def _map_to_frozendict(typ: Map, values: Mapping) -> PythonDecimal:
    values = {k: _normalize(typ.value_type, v) for k, v in values.items()}
    return frozendict(values)