-
-
Notifications
You must be signed in to change notification settings - Fork 12k
Closed
Description
If I define a ndarray subclass that implements __numpy_ufunc__, it segfaults whenever it contains a record array and a comparison is done (see below). Note that any direct calls to ufunc give the usual TypeError, and the segfault can be avoided by defining one's own __eq__, __ne__.
import numpy as np
class MyA(np.ndarray):
def __numpy_ufunc__(self, ufunc, method, i, inputs, **kwargs):
return getattr(ufunc, method)(*(input.view(np.ndarray)
for input in inputs), **kwargs)
a = np.arange(12.).reshape(4,3)
ma = a.view(MyA)
ma == ma[0]
# works as expected
ra = a.view(dtype=('f8,f8,f8')).squeeze()
ra == ra[0]
# works as expected: array([ True, False, False, False], dtype=bool)
mra = ra.view(MyA)
mra == ra[0]
# Segmentation fault
Metadata
Metadata
Assignees
Labels
No labels