Exemplo n.º 1
0
def custom_broadcast(layout, behavior):
    layout = awkward1.partition.first(layout)
    behavior = Behavior(awkward1.behavior, behavior)
    custom = layout.parameter("__array__")
    if not (isinstance(custom, str) or (py27 and isinstance(custom, unicode))):
        custom = layout.parameter("__record__")
    if not (isinstance(custom, str) or (py27 and isinstance(custom, unicode))):
        custom = layout.purelist_parameter("__record__")
    if (isinstance(custom, str) or (py27 and isinstance(custom, unicode))):
        for key, fcn in behavior.items():
            if (isinstance(key, tuple) and len(key) == 2
                    and key[0] == "__broadcast__" and key[1] == custom):
                return fcn
    return None
Exemplo n.º 2
0
 def is_fully_regular(layout):
     if (
         isinstance(layout, awkward1.layout.RegularArray)
         and layout.parameter("__record__") is None
         and layout.parameter("__array__") is None
     ):
         if isinstance(layout.content, awkward1.layout.NumpyArray):
             return True
         elif isinstance(layout.content, awkward1.layout.RegularArray):
             return is_fully_regular(layout.content)
         else:
             return False
     else:
         return False
Exemplo n.º 3
0
def recordclass(layout, behavior):
    layout = awkward1.partition.first(layout)
    behavior = Behavior(awkward1.behavior, behavior)
    rec = layout.parameter("__record__")
    if isinstance(rec, str) or (py27 and isinstance(rec, unicode)):
        cls = behavior[rec]
        if isinstance(cls, type) and issubclass(cls, awkward1.highlevel.Record):
            return cls
    return awkward1.highlevel.Record
Exemplo n.º 4
0
def arrayclass(layout, behavior):
    layout = awkward1.partition.first(layout)
    behavior = Behavior(awkward1.behavior, behavior)
    arr = layout.parameter("__array__")
    if isinstance(arr, str) or (py27 and isinstance(arr, unicode)):
        cls = behavior[arr]
        if isinstance(cls, type) and issubclass(cls, awkward1.highlevel.Array):
            return cls
    rec = layout.parameter("__record__")
    if isinstance(rec, str) or (py27 and isinstance(rec, unicode)):
        cls = behavior[".", rec]
        if isinstance(cls, type) and issubclass(cls, awkward1.highlevel.Array):
            return cls
    deeprec = layout.purelist_parameter("__record__")
    if isinstance(deeprec, str) or (py27 and isinstance(deeprec, unicode)):
        cls = behavior["*", deeprec]
        if isinstance(cls, type) and issubclass(cls, awkward1.highlevel.Array):
            return cls
    return awkward1.highlevel.Array