numpy/numpy — pull request #4815 by mhvk (2014-06-19 21:22:57+00:00)
Title: BUG __numpy_ufunc__ gives unexpected TypeError with subclasses

I'm trying to use `__numpy_ufunc__` for astropy `Quantity` and found surprising difficulties with subclasses, where `+` yields a `TypeError` while `+` works (see below for a simple example using just `ndarray` subclasses). This behaviour seems surprising. Am I missing something?
```
import numpy as np
np.version.version
# '1.9.0.dev-133d4f4'
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)

class MyA2(MyA):
pass

np.arange(2.).view(MyA) + np.arange(2.).view(MyA2)
# array([ 0., 2.])
np.arange(2.).view(MyA2) + np.arange(2.).view(MyA)
# TypeError: unsupported operand type(s) for +: 'MyA2' and 'MyA'
```