diff --git a/src/awkward/_v2/highlevel.py b/src/awkward/_v2/highlevel.py index 7fcfab05de..a54aa8be46 100644 --- a/src/awkward/_v2/highlevel.py +++ b/src/awkward/_v2/highlevel.py @@ -275,8 +275,6 @@ def __init__( layout = ak._v2.operations.structure.with_name( layout, with_name, highlevel=False ) - if self.__class__ is Array: - self.__class__ = ak._v2._util.arrayclass(layout, behavior) if library is not None and library != ak._v2.operations.convert.library(layout): layout = ak._v2.operations.convert.to_library( @@ -367,6 +365,7 @@ def behavior(self): @behavior.setter def behavior(self, behavior): if behavior is None or isinstance(behavior, Mapping): + self.__class__ = ak._v2._util.arrayclass(self._layout, behavior) self._behavior = behavior else: raise TypeError("behavior must be None or a dict") @@ -1447,8 +1446,6 @@ def __setstate__(self, state): layout = ak._v2.operations.structure.concatenate( layouts, highlevel=False ) - if self.__class__ is Array: - self.__class__ = ak._v2._util.arrayclass(layout, behavior) self.layout = layout self.behavior = behavior @@ -1544,8 +1541,6 @@ def __init__( layout = ak._v2.operations.structure.with_name( layout, with_name, highlevel=False ) - if self.__class__ is Record: - self.__class__ = ak._v2._util.recordclass(layout, behavior) if library is not None and library != ak._v2.operations.convert.library(layout): layout = ak._v2.operations.convert.to_library( @@ -1631,7 +1626,8 @@ def behavior(self): @behavior.setter def behavior(self, behavior): - if behavior is None or isinstance(behavior, dict): + if behavior is None or isinstance(behavior, Mapping): + self.__class__ = ak._v2._util.recordclass(self._layout, behavior) self._behavior = behavior else: raise TypeError("behavior must be None or a dict") @@ -2048,8 +2044,6 @@ def __setstate__(self, state): layouts, highlevel=False ) layout = ak._v2.record.Record(layout, at) - if self.__class__ is Record: - self.__class__ = ak._v2._util.recordclass(layout, behavior) self.layout = layout self.behavior = behavior diff --git a/src/awkward/_v2/operations/structure/ak_isclose.py b/src/awkward/_v2/operations/structure/ak_isclose.py index 40cd0b126d..55ea5fce05 100644 --- a/src/awkward/_v2/operations/structure/ak_isclose.py +++ b/src/awkward/_v2/operations/structure/ak_isclose.py @@ -46,7 +46,7 @@ def action(inputs, nplike, **kwargs): ), ) - behavior = ak._v2._util.behavior_of(one, two, behavior=behavior) + behavior = ak._v2._util.behavior_of(a, b, behavior=behavior) out = ak._v2._broadcasting.broadcast_and_apply([one, two], action, behavior) assert isinstance(out, tuple) and len(out) == 1 diff --git a/src/awkward/_v2/operations/structure/ak_where.py b/src/awkward/_v2/operations/structure/ak_where.py index ec210077d3..8b1b08a1da 100644 --- a/src/awkward/_v2/operations/structure/ak_where.py +++ b/src/awkward/_v2/operations/structure/ak_where.py @@ -104,7 +104,7 @@ def where(condition, *args, **kwargs): # else: # return None -# behavior = ak._v2._util.behaviorof(akcondition, left, right) +# behavior = ak._v2._util.behaviorof(condition, *args) # out = ak._v2._util.broadcast_and_apply( # [akcondition, left, right], # getfunction, diff --git a/src/awkward/highlevel.py b/src/awkward/highlevel.py index 950259e222..34e51edeb8 100644 --- a/src/awkward/highlevel.py +++ b/src/awkward/highlevel.py @@ -267,8 +267,6 @@ def __init__( layout = ak.operations.structure.with_name( layout, with_name, highlevel=False ) - if self.__class__ is Array: - self.__class__ = ak._util.arrayclass(layout, behavior) if kernels is not None and kernels != ak.operations.convert.kernels(layout): layout = ak.operations.convert.to_kernels(layout, kernels, highlevel=False) @@ -360,6 +358,7 @@ def behavior(self): @behavior.setter def behavior(self, behavior): if behavior is None or isinstance(behavior, dict): + self.__class__ = ak._util.arrayclass(self._layout, behavior) self._behavior = behavior else: raise TypeError( @@ -1480,8 +1479,6 @@ def __setstate__(self, state): layout = ak.operations.convert.from_buffers( form, length, container, highlevel=False, behavior=behavior ) - if self.__class__ is Array: - self.__class__ = ak._util.arrayclass(layout, behavior) self.layout = layout self.behavior = behavior self._caches = ak._util.find_caches(self.layout) @@ -1585,8 +1582,6 @@ def __init__( layout = ak.operations.structure.with_name( layout, with_name, highlevel=False ) - if self.__class__ is Record: - self.__class__ = ak._util.recordclass(layout, behavior) if kernels is not None and kernels != ak.operations.convert.kernels(layout): layout = ak.operations.convert.to_kernels(layout, kernels, highlevel=False) @@ -1674,6 +1669,7 @@ def behavior(self): @behavior.setter def behavior(self, behavior): if behavior is None or isinstance(behavior, dict): + self.__class__ = ak._util.recordclass(self._layout, behavior) self._behavior = behavior else: raise TypeError( @@ -2082,8 +2078,6 @@ def __setstate__(self, state): form, length, container, highlevel=False, behavior=behavior ) layout = ak.layout.Record(layout, at) - if self.__class__ is Record: - self.__class__ = ak._util.recordclass(layout, behavior) self.layout = layout self.behavior = behavior self._caches = ak._util.find_caches(self.layout) diff --git a/src/awkward/operations/structure.py b/src/awkward/operations/structure.py index e2793aac38..f53910abee 100644 --- a/src/awkward/operations/structure.py +++ b/src/awkward/operations/structure.py @@ -1744,7 +1744,7 @@ def getfunction(inputs): else: return None - behavior = ak._util.behaviorof(akcondition, left, right) + behavior = ak._util.behaviorof(condition, *args) out = ak._util.broadcast_and_apply( [akcondition, left, right], getfunction, @@ -4417,7 +4417,7 @@ def getfunction(inputs): else: return None - behavior = ak._util.behaviorof(one, two, behavior=behavior) + behavior = ak._util.behaviorof(a, b, behavior=behavior) out = ak._util.broadcast_and_apply( [one, two], getfunction, behavior, pass_depth=False )