Conversation
Codecov Report
Additional details and impacted files
|
jpivarski
left a comment
There was a problem hiding this comment.
Why would NumPy introduce __slots__ on a mixin? (Mixins are supposed to not be in charge of what data a class has, and therefore not define the __init__ and attributes. Defining __slots__ forces an exact set of data attributes, and therefore make the class not a mixin. #2533 is exactly the reason why mixins are okay for multiple inheritance and classes that define data are not.)
Since we have our own definition of NDArrayOperatorsMixin,
awkward/src/awkward/_connect/numpy.py
Lines 315 to 401 in 7f9be54
(though it was removed in #2115), I'd prefer to just use our definition and therefore control it. It means that we'll need to be on top of any new additional unary/binary operators (like @), but we don't have to be on the defensive about upstream technicalities like this.
|
numpy issue numpy/numpy#22876 and PR numpy/numpy#23113 |
|
Oh, so my reading of this is that
By that logic, the NumPy developers concluded that there could be no downside to it. In #2533, we seem to have discovered a downside: Maybe a different solution to this is to define We don't want an infectious implementation requirement to spread to all downstream libraries that use Awkward, especially if the error message is cryptic, like If defining If defining |
|
The way that the layout checker works is that it has a notion of type-supertype "compatibility", and it attempts to find a compatible common base. To generate our mixin classes for both records and arrays, we do something like class ArrayImpl(MixinType, ak.Array):
...The logic checking type-supertype compatibility for multiple inheritance walks down the Let's imagine that we add slots to Of the two approaches, it's probably safer to assume that the user doesn't define import awkward as ak
behavior = {}
class Point:
__slots__ = ()
class MyPoint(Point, ak.Array):
...
behavior["*", "Point"] = MyPoint
ak.operations.zip(
{
"x": ak.Array([1, 1]),
"y": ak.Array([1, 1]),
},
with_name="Point",
behavior=behavior,
)For the same reasons outlined above: I think, therefore, the safest immediate step is to drop the slots, by using our own mixin. For our ecosystem, I think there's lesser benefit to |
Let's go with that. I was also thinking that |
|
I've taken your above comment as approval for merging! |
Fixes #2533 by vendoring our own version of
NDArrayOperatorsMixin