示例#1
0
class Node4(AttributeAsDict):
    attr_tag = 'attr'

    a = BytesField('b')
    b = NDArrayField('c')
    c = Datetime64Field('d')
    d = Timedelta64Field('e')
    e = DataTypeField('f')
    f = DictField('g', ValueType.string, ValueType.list(ValueType.bool))
    g = DictField('h')
    h = TupleField('i', ValueType.int64, ValueType.unicode, ValueType.string,
                   ValueType.float32, ValueType.datetime64,
                   ValueType.timedelta64, ValueType.dtype)
    i = TupleField('j', ValueType.slice)
    j = ReferenceField('k', Node5)
    k = ListField('l', ValueType.reference('Node5'))
    l = OneOfField('m', n5=Node5, n6=Node6)
    m = ReferenceField('n', None)
    n = ListField('o', ValueType.reference(None))
    w = IndexField('v')
    ww = IndexField('vw')
    x = SeriesField('w')
    y = DataFrameField('x')
    z = ListField('y')
    o = FunctionField('p')

    @classmethod
    def cls(cls, provider):
        if provider.type == ProviderType.protobuf:
            from mars.serialize.tests.testser_pb2 import Node4Def
            return Node4Def
        return super().cls(provider)
示例#2
0
class Node1(Serializable):
    a = IdentityField('a', ValueType.string)
    b1 = Int8Field('b1')
    b2 = Int16Field('b2')
    b3 = Int32Field('b3')
    b4 = Int64Field('b4')
    c1 = UInt8Field('c1')
    c2 = UInt16Field('c2')
    c3 = UInt32Field('c3')
    c4 = UInt64Field('c4')
    d1 = Float16Field('d1')
    d2 = Float32Field('d2')
    d3 = Float64Field('d3')
    cl1 = Complex64Field('cl1')
    cl2 = Complex128Field('cl2')
    e = BoolField('e')
    f1 = KeyField('f1')
    f2 = AnyField('f2')
    f3 = AnyField('f3')
    g = ReferenceField('g', 'Node2')
    h = ListField('h')
    i = ListField('i', ValueType.reference('self'))
    j = ReferenceField('j', None)
    k = ListField('k', ValueType.reference(None))
    l = FunctionField('l')  # noqa: E741
    m = TZInfoField('m')
    n = IntervalArrayField('n')
    o = NamedtupleField('o')
    p = RegexField('p')

    def __new__(cls, *args, **kwargs):
        if 'a' in kwargs and kwargs['a'] == 'test1':
            return object.__new__(Node8)
        return object.__new__(cls)

    @classmethod
    def cls(cls, provider):
        if provider.type == ProviderType.protobuf:
            from mars.serialize.tests.testser_pb2 import Node1Def
            return Node1Def
        return super().cls(provider)