User guide
NumPy User Guide, Release 1.9.0
an operation involving two or more sub-types arises. In operations where different sub-types are being used,
the sub-type with the largest __array_priority__ attribute will determine the sub-type of the output(s).
If two sub- types have the same __array_priority__ then the sub-type of the first argument determines
the output. The default __array_priority__ attribute returns a value of 0.0 for the base ndarray type and
1.0 for a sub-type. This attribute can also be defined by objects that are not sub-types of the ndarray and can be
used to determine which __array_wrap__ method should be called for the return output.
The __array_wrap__ method
ndarray.__array_wrap__
Any class or type can define this method which should take an ndarray argument and return an instance of
the type. It can be seen as the opposite of the __array__ method. This method is used by the ufuncs
(and other NumPy functions) to allow other objects to pass through. For Python >2.4, it can also be used to
write a decorator that converts a function that works only with ndarrays to one that works with any type with
__array__ and __array_wrap__ methods.
5.4. Beyond the Basics 105