{"action":"created","issue":{"url":"https://api.github.com/repos/numpy/numpy/issues/4815","labels_url":"https://api.github.com/repos/numpy/numpy/issues/4815/labels{/name}","comments_url":"https://api.github.com/repos/numpy/numpy/issues/4815/comments","events_url":"https://api.github.com/repos/numpy/numpy/issues/4815/events","html_url":"https://github.com/numpy/numpy/pull/4815","id":36045125,"number":4815,"title":"BUG __numpy_ufunc__ gives unexpected TypeError with subclasses","user":{"login":"mhvk","id":2789820,"avatar_url":"https://avatars.githubusercontent.com/u/2789820?v=3","gravatar_id":"","url":"https://api.github.com/users/mhvk","html_url":"https://github.com/mhvk","followers_url":"https://api.github.com/users/mhvk/followers","following_url":"https://api.github.com/users/mhvk/following{/other_user}","gists_url":"https://api.github.com/users/mhvk/gists{/gist_id}","starred_url":"https://api.github.com/users/mhvk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mhvk/subscriptions","organizations_url":"https://api.github.com/users/mhvk/orgs","repos_url":"https://api.github.com/users/mhvk/repos","events_url":"https://api.github.com/users/mhvk/events{/privacy}","received_events_url":"https://api.github.com/users/mhvk/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/numpy/numpy/labels/component:%20numpy.core","name":"component: numpy.core","color":"ff0000"},{"url":"https://api.github.com/repos/numpy/numpy/labels/Maintenance","name":"Maintenance","color":"02e10c"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/numpy/numpy/milestones/35","html_url":"https://github.com/numpy/numpy/milestones/1.10.0%20release","labels_url":"https://api.github.com/repos/numpy/numpy/milestones/35/labels","id":1055363,"number":35,"title":"1.10.0 release","description":"Marker for PRs that should go into Numpy 1.10.1.","creator":{"login":"charris","id":77272,"avatar_url":"https://avatars.githubusercontent.com/u/77272?v=3","gravatar_id":"","url":"https://api.github.com/users/charris","html_url":"https://github.com/charris","followers_url":"https://api.github.com/users/charris/followers","following_url":"https://api.github.com/users/charris/following{/other_user}","gists_url":"https://api.github.com/users/charris/gists{/gist_id}","starred_url":"https://api.github.com/users/charris/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/charris/subscriptions","organizations_url":"https://api.github.com/users/charris/orgs","repos_url":"https://api.github.com/users/charris/repos","events_url":"https://api.github.com/users/charris/events{/privacy}","received_events_url":"https://api.github.com/users/charris/received_events","type":"User","site_admin":false},"open_issues":17,"closed_issues":20,"state":"open","created_at":"2015-04-07T00:02:10Z","updated_at":"2015-05-05T15:42:45Z","due_on":null,"closed_at":null},"comments":28,"created_at":"2014-06-19T02:33:35Z","updated_at":"2015-05-06T00:04:55Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/numpy/numpy/pulls/4815","html_url":"https://github.com/numpy/numpy/pull/4815","diff_url":"https://github.com/numpy/numpy/pull/4815.diff","patch_url":"https://github.com/numpy/numpy/pull/4815.patch"},"body":"I'm trying to use `__numpy_ufunc__` for astropy `Quantity` and found surprising difficulties with subclasses, where `<Q-subclass>+<Q>` yields a `TypeError` while `<Q>+<Q-subclass>` works (see below for a simple example using just `ndarray` subclasses). This behaviour seems surprising. Am I missing something?\r\n```\r\nimport numpy as np\r\nnp.version.version\r\n# '1.9.0.dev-133d4f4'\r\nclass MyA(np.ndarray):                                \r\n    def __numpy_ufunc__(self, ufunc, method, i, inputs, **kwargs):\r\n        return getattr(ufunc, method)(*(input.view(np.ndarray) for input in inputs), **kwargs)\r\n\r\nclass MyA2(MyA):                                      \r\n    pass\r\n\r\nnp.arange(2.).view(MyA) + np.arange(2.).view(MyA2)\r\n# array([ 0.,  2.])\r\nnp.arange(2.).view(MyA2) + np.arange(2.).view(MyA)\r\n# TypeError: unsupported operand type(s) for +: 'MyA2' and 'MyA'\r\n```"},"comment":{"url":"https://api.github.com/repos/numpy/numpy/issues/comments/99266756","html_url":"https://github.com/numpy/numpy/pull/4815#issuecomment-99266756","issue_url":"https://api.github.com/repos/numpy/numpy/issues/4815","id":99266756,"user":{"login":"charris","id":77272,"avatar_url":"https://avatars.githubusercontent.com/u/77272?v=3","gravatar_id":"","url":"https://api.github.com/users/charris","html_url":"https://github.com/charris","followers_url":"https://api.github.com/users/charris/followers","following_url":"https://api.github.com/users/charris/following{/other_user}","gists_url":"https://api.github.com/users/charris/gists{/gist_id}","starred_url":"https://api.github.com/users/charris/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/charris/subscriptions","organizations_url":"https://api.github.com/users/charris/orgs","repos_url":"https://api.github.com/users/charris/repos","events_url":"https://api.github.com/users/charris/events{/privacy}","received_events_url":"https://api.github.com/users/charris/received_events","type":"User","site_admin":false},"created_at":"2015-05-06T00:04:55Z","updated_at":"2015-05-06T00:04:55Z","body":"@mhvk @pv As I see it, Pauli addresses the python interpreter operator problems at the operator level, which I think is were it belongs. I'm inclined to close this and go with #5748. Is it correct that ufuncs still have problems? I note in trying astorpy.units that `np.multiply(42, u.meter)` returns NotImplemented."}}