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
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