Registering a class as a subclass of a numpy array (without subclassing)

245 views Asked by At

Without subclassing from numpy ndarray, I have a class that implements all ndarray methods. In spite of this, some numpy operations fail. It seems to me that, isinstance(obj, ndarray) is used inside numpy code. Is there a way to register (like in abc) my class as a subclass of a numpy ndarray (without subclassing)?

1

There are 1 answers

0
J. Martinot-Lagarde On

You can use the array interface: http://docs.scipy.org/doc/numpy/reference/arrays.interface.html. This allows to use numpy ufuncs with your class.

You can have a dynamic array_interface if you use it as a property.