{"action":"created","issue":{"url":"https://api.github.com/repos/Unidata/netcdf4-python/issues/385","labels_url":"https://api.github.com/repos/Unidata/netcdf4-python/issues/385/labels{/name}","comments_url":"https://api.github.com/repos/Unidata/netcdf4-python/issues/385/comments","events_url":"https://api.github.com/repos/Unidata/netcdf4-python/issues/385/events","html_url":"https://github.com/Unidata/netcdf4-python/issues/385","id":63967643,"number":385,"title":"Runtime detection of indexing semantics","user":{"login":"rhattersley","id":917914,"avatar_url":"https://avatars.githubusercontent.com/u/917914?v=3","gravatar_id":"","url":"https://api.github.com/users/rhattersley","html_url":"https://github.com/rhattersley","followers_url":"https://api.github.com/users/rhattersley/followers","following_url":"https://api.github.com/users/rhattersley/following{/other_user}","gists_url":"https://api.github.com/users/rhattersley/gists{/gist_id}","starred_url":"https://api.github.com/users/rhattersley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rhattersley/subscriptions","organizations_url":"https://api.github.com/users/rhattersley/orgs","repos_url":"https://api.github.com/users/rhattersley/repos","events_url":"https://api.github.com/users/rhattersley/events{/privacy}","received_events_url":"https://api.github.com/users/rhattersley/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":17,"created_at":"2015-03-24T10:55:43Z","updated_at":"2015-03-30T13:51:28Z","closed_at":null,"body":"netCDF4 and numpy differ in how they treat tuple/array indexing arguments:\r\n```python\r\n>>> type(v)\r\n<type 'netCDF4.Variable'>\r\n>>> v.shape\r\n(240, 37, 49)\r\n>>> v[(0, 1), (0, 2, 3)].shape\r\n(2, 3, 49)\r\n>>> np.array(v)[(0, 1), (0, 2, 3)].shape\r\nTraceback (most recent call last):\r\n  File \"<stdin>\", line 1, in <module>\r\nIndexError: shape mismatch: indexing arrays could not be broadcast together with shapes (2,) (3,) \r\n```\r\n\r\nIt's something of a long shot, but ... given an object that supports indexing, how can I determine at runtime which of these two styles it supports?\r\n\r\nI like to avoid `isinstance(v, netCDF4.Variable)`, or probing the behaviour with something like `v[(0, 1), (0, 2, 3), 0]` as it could have a relatively large cost."},"comment":{"url":"https://api.github.com/repos/Unidata/netcdf4-python/issues/comments/87687923","html_url":"https://github.com/Unidata/netcdf4-python/issues/385#issuecomment-87687923","issue_url":"https://api.github.com/repos/Unidata/netcdf4-python/issues/385","id":87687923,"user":{"login":"jswhit","id":579593,"avatar_url":"https://avatars.githubusercontent.com/u/579593?v=3","gravatar_id":"","url":"https://api.github.com/users/jswhit","html_url":"https://github.com/jswhit","followers_url":"https://api.github.com/users/jswhit/followers","following_url":"https://api.github.com/users/jswhit/following{/other_user}","gists_url":"https://api.github.com/users/jswhit/gists{/gist_id}","starred_url":"https://api.github.com/users/jswhit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jswhit/subscriptions","organizations_url":"https://api.github.com/users/jswhit/orgs","repos_url":"https://api.github.com/users/jswhit/repos","events_url":"https://api.github.com/users/jswhit/events{/privacy}","received_events_url":"https://api.github.com/users/jswhit/received_events","type":"User","site_admin":false},"created_at":"2015-03-30T13:51:28Z","updated_at":"2015-03-30T13:51:28Z","body":"A special attribute sounds like a reasonable idea to me (and here is as good a place as any to discuss it).  How about \"__orthogonal_indexing__\"?\r\n\r\nHas anyone ever approached the numpy developers about supporting orthogonal indexing, at least as an option?"}}