{"action":"created","comment":{"url":"https://api.github.com/repos/pydata/xarray/pulls/comments/356243834","pull_request_review_id":330101255,"id":356243834,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDM1NjI0MzgzNA==","diff_hunk":"@@ -540,6 +540,20 @@ def _broadcast_indexes(self, key):\n             k.item() if isinstance(k, np.ndarray) and k.ndim == 0 else k for k in key\n         )\n \n+        key_dict = dict(zip(self.dims, key))\n+        for dim, k in key_dict.items():\n+            if isinstance(k, Iterable):\n+                # let da.sel(x=da.x) pass but skip if Variable has different dimensions\n+                # e.g. da.sel(x=Variable((\"points\",), [0, 1, 2]))\n+                if isinstance(k, Variable) and k.dims != (dim,):\n+                    continue\n+                if duck_array_ops.array_equiv(k, np.arange(self.sizes[dim])):\n+                    # short-circuit when keys are effectively slice(None)\n+                    # This preserves dask name and passes lazy array equivalence checks\n+                    # (see duck_array_ops.lazy_array_equiv)\n+                    key_dict[dim] = slice(None)\n+        key = tuple(key_dict.values())","path":"xarray/core/variable.py","position":25,"original_position":25,"commit_id":"28074b979258cbc120a1b8f8d4a0311e7f25bd6a","original_commit_id":"28074b979258cbc120a1b8f8d4a0311e7f25bd6a","user":{"login":"shoyer","id":1217238,"node_id":"MDQ6VXNlcjEyMTcyMzg=","avatar_url":"https://avatars2.githubusercontent.com/u/1217238?v=4","gravatar_id":"","url":"https://api.github.com/users/shoyer","html_url":"https://github.com/shoyer","followers_url":"https://api.github.com/users/shoyer/followers","following_url":"https://api.github.com/users/shoyer/following{/other_user}","gists_url":"https://api.github.com/users/shoyer/gists{/gist_id}","starred_url":"https://api.github.com/users/shoyer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shoyer/subscriptions","organizations_url":"https://api.github.com/users/shoyer/orgs","repos_url":"https://api.github.com/users/shoyer/repos","events_url":"https://api.github.com/users/shoyer/events{/privacy}","received_events_url":"https://api.github.com/users/shoyer/received_events","type":"User","site_admin":false},"body":"I agree, this would be safe on dask arrays. But it probably makes sense to do that at a lower level, e.g., inside `DaskIndexingAdapter`. Or maybe even inside dask itself?","created_at":"2019-12-10T19:50:21Z","updated_at":"2019-12-10T19:50:22Z","html_url":"https://github.com/pydata/xarray/pull/3588#discussion_r356243834","pull_request_url":"https://api.github.com/repos/pydata/xarray/pulls/3588","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/pydata/xarray/pulls/comments/356243834"},"html":{"href":"https://github.com/pydata/xarray/pull/3588#discussion_r356243834"},"pull_request":{"href":"https://api.github.com/repos/pydata/xarray/pulls/3588"}},"in_reply_to_id":353266948},"pull_request":{"url":"https://api.github.com/repos/pydata/xarray/pulls/3588","id":348410727,"node_id":"MDExOlB1bGxSZXF1ZXN0MzQ4NDEwNzI3","html_url":"https://github.com/pydata/xarray/pull/3588","diff_url":"https://github.com/pydata/xarray/pull/3588.diff","patch_url":"https://github.com/pydata/xarray/pull/3588.patch","issue_url":"https://api.github.com/repos/pydata/xarray/issues/3588","number":3588,"state":"open","locked":false,"title":"Optimize isel for lazy array equality checking","user":{"login":"dcherian","id":2448579,"node_id":"MDQ6VXNlcjI0NDg1Nzk=","avatar_url":"https://avatars3.githubusercontent.com/u/2448579?v=4","gravatar_id":"","url":"https://api.github.com/users/dcherian","html_url":"https://github.com/dcherian","followers_url":"https://api.github.com/users/dcherian/followers","following_url":"https://api.github.com/users/dcherian/following{/other_user}","gists_url":"https://api.github.com/users/dcherian/gists{/gist_id}","starred_url":"https://api.github.com/users/dcherian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dcherian/subscriptions","organizations_url":"https://api.github.com/users/dcherian/orgs","repos_url":"https://api.github.com/users/dcherian/repos","events_url":"https://api.github.com/users/dcherian/events{/privacy}","received_events_url":"https://api.github.com/users/dcherian/received_events","type":"User","site_admin":false},"body":"<!-- Feel free to remove check-list items aren't relevant to your change -->\r\n\r\n - [x] Closes #3558\r\n - [x] Tests added\r\n - [x] Passes `black . && mypy . && flake8`\r\n - [x] Fully documented, including `whats-new.rst` for all changes and `api.rst` for new API\r\n\r\nThis mostly adds tests that already pass (yay!).","created_at":"2019-12-03T15:58:40Z","updated_at":"2019-12-10T19:50:22Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f970ef954516906e73ccb0f7a8b9879c41a7a34c","assignee":null,"assignees":[],"requested_reviewers":[{"login":"shoyer","id":1217238,"node_id":"MDQ6VXNlcjEyMTcyMzg=","avatar_url":"https://avatars2.githubusercontent.com/u/1217238?v=4","gravatar_id":"","url":"https://api.github.com/users/shoyer","html_url":"https://github.com/shoyer","followers_url":"https://api.github.com/users/shoyer/followers","following_url":"https://api.github.com/users/shoyer/following{/other_user}","gists_url":"https://api.github.com/users/shoyer/gists{/gist_id}","starred_url":"https://api.github.com/users/shoyer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shoyer/subscriptions","organizations_url":"https://api.github.com/users/shoyer/orgs","repos_url":"https://api.github.com/users/shoyer/repos","events_url":"https://api.github.com/users/shoyer/events{/privacy}","received_events_url":"https://api.github.com/users/shoyer/received_events","type":"User","site_admin":false},{"login":"crusaderky","id":6213168,"node_id":"MDQ6VXNlcjYyMTMxNjg=","avatar_url":"https://avatars1.githubusercontent.com/u/6213168?v=4","gravatar_id":"","url":"https://api.github.com/users/crusaderky","html_url":"https://github.com/crusaderky","followers_url":"https://api.github.com/users/crusaderky/followers","following_url":"https://api.github.com/users/crusaderky/following{/other_user}","gists_url":"https://api.github.com/users/crusaderky/gists{/gist_id}","starred_url":"https://api.github.com/users/crusaderky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/crusaderky/subscriptions","organizations_url":"https://api.github.com/users/crusaderky/orgs","repos_url":"https://api.github.com/users/crusaderky/repos","events_url":"https://api.github.com/users/crusaderky/events{/privacy}","received_events_url":"https://api.github.com/users/crusaderky/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/pydata/xarray/pulls/3588/commits","review_comments_url":"https://api.github.com/repos/pydata/xarray/pulls/3588/comments","review_comment_url":"https://api.github.com/repos/pydata/xarray/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pydata/xarray/issues/3588/comments","statuses_url":"https://api.github.com/repos/pydata/xarray/statuses/28074b979258cbc120a1b8f8d4a0311e7f25bd6a","head":{"label":"dcherian:optimize-lazy-equiv","ref":"optimize-lazy-equiv","sha":"28074b979258cbc120a1b8f8d4a0311e7f25bd6a","user":{"login":"dcherian","id":2448579,"node_id":"MDQ6VXNlcjI0NDg1Nzk=","avatar_url":"https://avatars3.githubusercontent.com/u/2448579?v=4","gravatar_id":"","url":"https://api.github.com/users/dcherian","html_url":"https://github.com/dcherian","followers_url":"https://api.github.com/users/dcherian/followers","following_url":"https://api.github.com/users/dcherian/following{/other_user}","gists_url":"https://api.github.com/users/dcherian/gists{/gist_id}","starred_url":"https://api.github.com/users/dcherian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dcherian/subscriptions","organizations_url":"https://api.github.com/users/dcherian/orgs","repos_url":"https://api.github.com/users/dcherian/repos","events_url":"https://api.github.com/users/dcherian/events{/privacy}","received_events_url":"https://api.github.com/users/dcherian/received_events","type":"User","site_admin":false},"repo":{"id":111721718,"node_id":"MDEwOlJlcG9zaXRvcnkxMTE3MjE3MTg=","name":"xarray","full_name":"dcherian/xarray","private":false,"owner":{"login":"dcherian","id":2448579,"node_id":"MDQ6VXNlcjI0NDg1Nzk=","avatar_url":"https://avatars3.githubusercontent.com/u/2448579?v=4","gravatar_id":"","url":"https://api.github.com/users/dcherian","html_url":"https://github.com/dcherian","followers_url":"https://api.github.com/users/dcherian/followers","following_url":"https://api.github.com/users/dcherian/following{/other_user}","gists_url":"https://api.github.com/users/dcherian/gists{/gist_id}","starred_url":"https://api.github.com/users/dcherian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dcherian/subscriptions","organizations_url":"https://api.github.com/users/dcherian/orgs","repos_url":"https://api.github.com/users/dcherian/repos","events_url":"https://api.github.com/users/dcherian/events{/privacy}","received_events_url":"https://api.github.com/users/dcherian/received_events","type":"User","site_admin":false},"html_url":"https://github.com/dcherian/xarray","description":"N-D labeled arrays and datasets in Python","fork":true,"url":"https://api.github.com/repos/dcherian/xarray","forks_url":"https://api.github.com/repos/dcherian/xarray/forks","keys_url":"https://api.github.com/repos/dcherian/xarray/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dcherian/xarray/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dcherian/xarray/teams","hooks_url":"https://api.github.com/repos/dcherian/xarray/hooks","issue_events_url":"https://api.github.com/repos/dcherian/xarray/issues/events{/number}","events_url":"https://api.github.com/repos/dcherian/xarray/events","assignees_url":"https://api.github.com/repos/dcherian/xarray/assignees{/user}","branches_url":"https://api.github.com/repos/dcherian/xarray/branches{/branch}","tags_url":"https://api.github.com/repos/dcherian/xarray/tags","blobs_url":"https://api.github.com/repos/dcherian/xarray/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dcherian/xarray/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dcherian/xarray/git/refs{/sha}","trees_url":"https://api.github.com/repos/dcherian/xarray/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dcherian/xarray/statuses/{sha}","languages_url":"https://api.github.com/repos/dcherian/xarray/languages","stargazers_url":"https://api.github.com/repos/dcherian/xarray/stargazers","contributors_url":"https://api.github.com/repos/dcherian/xarray/contributors","subscribers_url":"https://api.github.com/repos/dcherian/xarray/subscribers","subscription_url":"https://api.github.com/repos/dcherian/xarray/subscription","commits_url":"https://api.github.com/repos/dcherian/xarray/commits{/sha}","git_commits_url":"https://api.github.com/repos/dcherian/xarray/git/commits{/sha}","comments_url":"https://api.github.com/repos/dcherian/xarray/comments{/number}","issue_comment_url":"https://api.github.com/repos/dcherian/xarray/issues/comments{/number}","contents_url":"https://api.github.com/repos/dcherian/xarray/contents/{+path}","compare_url":"https://api.github.com/repos/dcherian/xarray/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dcherian/xarray/merges","archive_url":"https://api.github.com/repos/dcherian/xarray/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dcherian/xarray/downloads","issues_url":"https://api.github.com/repos/dcherian/xarray/issues{/number}","pulls_url":"https://api.github.com/repos/dcherian/xarray/pulls{/number}","milestones_url":"https://api.github.com/repos/dcherian/xarray/milestones{/number}","notifications_url":"https://api.github.com/repos/dcherian/xarray/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dcherian/xarray/labels{/name}","releases_url":"https://api.github.com/repos/dcherian/xarray/releases{/id}","deployments_url":"https://api.github.com/repos/dcherian/xarray/deployments","created_at":"2017-11-22T18:58:27Z","updated_at":"2019-12-05T16:46:05Z","pushed_at":"2019-12-10T16:02:06Z","git_url":"git://github.com/dcherian/xarray.git","ssh_url":"git@github.com:dcherian/xarray.git","clone_url":"https://github.com/dcherian/xarray.git","svn_url":"https://github.com/dcherian/xarray","homepage":"http://xarray.pydata.org","size":23037,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":0,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":1,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"pydata:master","ref":"master","sha":"69c85b85a1ef5d13b6ca51b6b655a1f719cc5abf","user":{"login":"pydata","id":1284191,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEyODQxOTE=","avatar_url":"https://avatars0.githubusercontent.com/u/1284191?v=4","gravatar_id":"","url":"https://api.github.com/users/pydata","html_url":"https://github.com/pydata","followers_url":"https://api.github.com/users/pydata/followers","following_url":"https://api.github.com/users/pydata/following{/other_user}","gists_url":"https://api.github.com/users/pydata/gists{/gist_id}","starred_url":"https://api.github.com/users/pydata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pydata/subscriptions","organizations_url":"https://api.github.com/users/pydata/orgs","repos_url":"https://api.github.com/users/pydata/repos","events_url":"https://api.github.com/users/pydata/events{/privacy}","received_events_url":"https://api.github.com/users/pydata/received_events","type":"Organization","site_admin":false},"repo":{"id":13221727,"node_id":"MDEwOlJlcG9zaXRvcnkxMzIyMTcyNw==","name":"xarray","full_name":"pydata/xarray","private":false,"owner":{"login":"pydata","id":1284191,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEyODQxOTE=","avatar_url":"https://avatars0.githubusercontent.com/u/1284191?v=4","gravatar_id":"","url":"https://api.github.com/users/pydata","html_url":"https://github.com/pydata","followers_url":"https://api.github.com/users/pydata/followers","following_url":"https://api.github.com/users/pydata/following{/other_user}","gists_url":"https://api.github.com/users/pydata/gists{/gist_id}","starred_url":"https://api.github.com/users/pydata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pydata/subscriptions","organizations_url":"https://api.github.com/users/pydata/orgs","repos_url":"https://api.github.com/users/pydata/repos","events_url":"https://api.github.com/users/pydata/events{/privacy}","received_events_url":"https://api.github.com/users/pydata/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/pydata/xarray","description":"N-D labeled arrays and datasets in Python","fork":false,"url":"https://api.github.com/repos/pydata/xarray","forks_url":"https://api.github.com/repos/pydata/xarray/forks","keys_url":"https://api.github.com/repos/pydata/xarray/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pydata/xarray/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pydata/xarray/teams","hooks_url":"https://api.github.com/repos/pydata/xarray/hooks","issue_events_url":"https://api.github.com/repos/pydata/xarray/issues/events{/number}","events_url":"https://api.github.com/repos/pydata/xarray/events","assignees_url":"https://api.github.com/repos/pydata/xarray/assignees{/user}","branches_url":"https://api.github.com/repos/pydata/xarray/branches{/branch}","tags_url":"https://api.github.com/repos/pydata/xarray/tags","blobs_url":"https://api.github.com/repos/pydata/xarray/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pydata/xarray/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pydata/xarray/git/refs{/sha}","trees_url":"https://api.github.com/repos/pydata/xarray/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pydata/xarray/statuses/{sha}","languages_url":"https://api.github.com/repos/pydata/xarray/languages","stargazers_url":"https://api.github.com/repos/pydata/xarray/stargazers","contributors_url":"https://api.github.com/repos/pydata/xarray/contributors","subscribers_url":"https://api.github.com/repos/pydata/xarray/subscribers","subscription_url":"https://api.github.com/repos/pydata/xarray/subscription","commits_url":"https://api.github.com/repos/pydata/xarray/commits{/sha}","git_commits_url":"https://api.github.com/repos/pydata/xarray/git/commits{/sha}","comments_url":"https://api.github.com/repos/pydata/xarray/comments{/number}","issue_comment_url":"https://api.github.com/repos/pydata/xarray/issues/comments{/number}","contents_url":"https://api.github.com/repos/pydata/xarray/contents/{+path}","compare_url":"https://api.github.com/repos/pydata/xarray/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pydata/xarray/merges","archive_url":"https://api.github.com/repos/pydata/xarray/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pydata/xarray/downloads","issues_url":"https://api.github.com/repos/pydata/xarray/issues{/number}","pulls_url":"https://api.github.com/repos/pydata/xarray/pulls{/number}","milestones_url":"https://api.github.com/repos/pydata/xarray/milestones{/number}","notifications_url":"https://api.github.com/repos/pydata/xarray/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pydata/xarray/labels{/name}","releases_url":"https://api.github.com/repos/pydata/xarray/releases{/id}","deployments_url":"https://api.github.com/repos/pydata/xarray/deployments","created_at":"2013-09-30T17:21:10Z","updated_at":"2019-12-10T16:02:05Z","pushed_at":"2019-12-10T16:02:02Z","git_url":"git://github.com/pydata/xarray.git","ssh_url":"git@github.com:pydata/xarray.git","clone_url":"https://github.com/pydata/xarray.git","svn_url":"https://github.com/pydata/xarray","homepage":"http://xarray.pydata.org","size":23099,"stargazers_count":1477,"watchers_count":1477,"language":"Python","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":493,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":606,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":493,"open_issues":606,"watchers":1477,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pydata/xarray/pulls/3588"},"html":{"href":"https://github.com/pydata/xarray/pull/3588"},"issue":{"href":"https://api.github.com/repos/pydata/xarray/issues/3588"},"comments":{"href":"https://api.github.com/repos/pydata/xarray/issues/3588/comments"},"review_comments":{"href":"https://api.github.com/repos/pydata/xarray/pulls/3588/comments"},"review_comment":{"href":"https://api.github.com/repos/pydata/xarray/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pydata/xarray/pulls/3588/commits"},"statuses":{"href":"https://api.github.com/repos/pydata/xarray/statuses/28074b979258cbc120a1b8f8d4a0311e7f25bd6a"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"shoyer"}}