{"action":"created","comment":{"url":"https://api.github.com/repos/pydata/xarray/pulls/comments/62772010","id":62772010,"diff_hunk":"@@ -2494,3 +2494,36 @@ def test_setattr_raises(self):\n             ds.foo = 2\n         with self.assertRaisesRegexp(AttributeError, 'cannot set attr'):\n             ds.other = 2\n+\n+    def test_get_variables_by_attributes(self):\n+        ds = Dataset({'temperature_0': (['t'],  [0], dict(standard_name='air_potential_temperature', height='0 m')),\n+                      'temperature_10': (['t'],  [0], dict(standard_name='air_potential_temperature', height='10 m')),\n+                      'precipitation': (['t'], [0], dict(standard_name='convective_precipitation_flux'))},\n+                    coords={'time': (['t'], [0], dict(axis='T'))})\n+\n+        # Test return empty Dataset.\n+        ds.get_variables_by_attributes(standard_name='invalid_standard_name')\n+        new_ds = ds.get_variables_by_attributes(standard_name='invalid_standard_name')\n+        self.assertFalse(bool(new_ds))","path":"xarray/test/test_dataset.py","position":14,"original_position":14,"commit_id":"1385f5f386c5398b829066f065bbf6971ae01460","original_commit_id":"1385f5f386c5398b829066f065bbf6971ae01460","user":{"login":"ocefpaf","id":950575,"avatar_url":"https://avatars.githubusercontent.com/u/950575?v=3","gravatar_id":"","url":"https://api.github.com/users/ocefpaf","html_url":"https://github.com/ocefpaf","followers_url":"https://api.github.com/users/ocefpaf/followers","following_url":"https://api.github.com/users/ocefpaf/following{/other_user}","gists_url":"https://api.github.com/users/ocefpaf/gists{/gist_id}","starred_url":"https://api.github.com/users/ocefpaf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ocefpaf/subscriptions","organizations_url":"https://api.github.com/users/ocefpaf/orgs","repos_url":"https://api.github.com/users/ocefpaf/repos","events_url":"https://api.github.com/users/ocefpaf/events{/privacy}","received_events_url":"https://api.github.com/users/ocefpaf/received_events","type":"User","site_admin":false},"body":"@MaximilianR is this OK to test for am empty `Dataset`? Pandas has the `.empty` property, but I could not find am equivalent on `xarray`.","created_at":"2016-05-10T23:37:46Z","updated_at":"2016-05-10T23:37:46Z","html_url":"https://github.com/pydata/xarray/pull/844#discussion_r62772010","pull_request_url":"https://api.github.com/repos/pydata/xarray/pulls/844","_links":{"self":{"href":"https://api.github.com/repos/pydata/xarray/pulls/comments/62772010"},"html":{"href":"https://github.com/pydata/xarray/pull/844#discussion_r62772010"},"pull_request":{"href":"https://api.github.com/repos/pydata/xarray/pulls/844"}}},"pull_request":{"url":"https://api.github.com/repos/pydata/xarray/pulls/844","id":68940102,"html_url":"https://github.com/pydata/xarray/pull/844","diff_url":"https://github.com/pydata/xarray/pull/844.diff","patch_url":"https://github.com/pydata/xarray/pull/844.patch","issue_url":"https://api.github.com/repos/pydata/xarray/issues/844","number":844,"state":"open","locked":false,"title":"Add a get_variables_by_attributes method to Dataset","user":{"login":"ocefpaf","id":950575,"avatar_url":"https://avatars.githubusercontent.com/u/950575?v=3","gravatar_id":"","url":"https://api.github.com/users/ocefpaf","html_url":"https://github.com/ocefpaf","followers_url":"https://api.github.com/users/ocefpaf/followers","following_url":"https://api.github.com/users/ocefpaf/following{/other_user}","gists_url":"https://api.github.com/users/ocefpaf/gists{/gist_id}","starred_url":"https://api.github.com/users/ocefpaf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ocefpaf/subscriptions","organizations_url":"https://api.github.com/users/ocefpaf/orgs","repos_url":"https://api.github.com/users/ocefpaf/repos","events_url":"https://api.github.com/users/ocefpaf/events{/privacy}","received_events_url":"https://api.github.com/users/ocefpaf/received_events","type":"User","site_admin":false},"body":"This PR adds the `get_variables_by_attributes` method similar to the one in `netCDF4-python` and netcdf-java libraries. It is useful to filter a Dataset to known/expected attributes.\r\n\r\n@shoyer I don't really like the docs nor the change log entry I created. I will look at them again tomorrow with fresh eyes to see if I can improve them.\r\n\r\nCloses https://github.com/pydata/xarray/issues/567\r\n\r\nxref: https://github.com/pydata/xarray/issues/567#issuecomment-216947679","created_at":"2016-05-04T22:08:07Z","updated_at":"2016-05-10T23:37:46Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6e2267d83cae68c217413d050493451d5c29fc65","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/pydata/xarray/pulls/844/commits","review_comments_url":"https://api.github.com/repos/pydata/xarray/pulls/844/comments","review_comment_url":"https://api.github.com/repos/pydata/xarray/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pydata/xarray/issues/844/comments","statuses_url":"https://api.github.com/repos/pydata/xarray/statuses/1385f5f386c5398b829066f065bbf6971ae01460","head":{"label":"ocefpaf:get_by_attr","ref":"get_by_attr","sha":"1385f5f386c5398b829066f065bbf6971ae01460","user":{"login":"ocefpaf","id":950575,"avatar_url":"https://avatars.githubusercontent.com/u/950575?v=3","gravatar_id":"","url":"https://api.github.com/users/ocefpaf","html_url":"https://github.com/ocefpaf","followers_url":"https://api.github.com/users/ocefpaf/followers","following_url":"https://api.github.com/users/ocefpaf/following{/other_user}","gists_url":"https://api.github.com/users/ocefpaf/gists{/gist_id}","starred_url":"https://api.github.com/users/ocefpaf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ocefpaf/subscriptions","organizations_url":"https://api.github.com/users/ocefpaf/orgs","repos_url":"https://api.github.com/users/ocefpaf/repos","events_url":"https://api.github.com/users/ocefpaf/events{/privacy}","received_events_url":"https://api.github.com/users/ocefpaf/received_events","type":"User","site_admin":false},"repo":{"id":58000618,"name":"xarray","full_name":"ocefpaf/xarray","owner":{"login":"ocefpaf","id":950575,"avatar_url":"https://avatars.githubusercontent.com/u/950575?v=3","gravatar_id":"","url":"https://api.github.com/users/ocefpaf","html_url":"https://github.com/ocefpaf","followers_url":"https://api.github.com/users/ocefpaf/followers","following_url":"https://api.github.com/users/ocefpaf/following{/other_user}","gists_url":"https://api.github.com/users/ocefpaf/gists{/gist_id}","starred_url":"https://api.github.com/users/ocefpaf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ocefpaf/subscriptions","organizations_url":"https://api.github.com/users/ocefpaf/orgs","repos_url":"https://api.github.com/users/ocefpaf/repos","events_url":"https://api.github.com/users/ocefpaf/events{/privacy}","received_events_url":"https://api.github.com/users/ocefpaf/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ocefpaf/xarray","description":"N-D labeled arrays and datasets in Python","fork":true,"url":"https://api.github.com/repos/ocefpaf/xarray","forks_url":"https://api.github.com/repos/ocefpaf/xarray/forks","keys_url":"https://api.github.com/repos/ocefpaf/xarray/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ocefpaf/xarray/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ocefpaf/xarray/teams","hooks_url":"https://api.github.com/repos/ocefpaf/xarray/hooks","issue_events_url":"https://api.github.com/repos/ocefpaf/xarray/issues/events{/number}","events_url":"https://api.github.com/repos/ocefpaf/xarray/events","assignees_url":"https://api.github.com/repos/ocefpaf/xarray/assignees{/user}","branches_url":"https://api.github.com/repos/ocefpaf/xarray/branches{/branch}","tags_url":"https://api.github.com/repos/ocefpaf/xarray/tags","blobs_url":"https://api.github.com/repos/ocefpaf/xarray/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ocefpaf/xarray/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ocefpaf/xarray/git/refs{/sha}","trees_url":"https://api.github.com/repos/ocefpaf/xarray/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ocefpaf/xarray/statuses/{sha}","languages_url":"https://api.github.com/repos/ocefpaf/xarray/languages","stargazers_url":"https://api.github.com/repos/ocefpaf/xarray/stargazers","contributors_url":"https://api.github.com/repos/ocefpaf/xarray/contributors","subscribers_url":"https://api.github.com/repos/ocefpaf/xarray/subscribers","subscription_url":"https://api.github.com/repos/ocefpaf/xarray/subscription","commits_url":"https://api.github.com/repos/ocefpaf/xarray/commits{/sha}","git_commits_url":"https://api.github.com/repos/ocefpaf/xarray/git/commits{/sha}","comments_url":"https://api.github.com/repos/ocefpaf/xarray/comments{/number}","issue_comment_url":"https://api.github.com/repos/ocefpaf/xarray/issues/comments{/number}","contents_url":"https://api.github.com/repos/ocefpaf/xarray/contents/{+path}","compare_url":"https://api.github.com/repos/ocefpaf/xarray/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ocefpaf/xarray/merges","archive_url":"https://api.github.com/repos/ocefpaf/xarray/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ocefpaf/xarray/downloads","issues_url":"https://api.github.com/repos/ocefpaf/xarray/issues{/number}","pulls_url":"https://api.github.com/repos/ocefpaf/xarray/pulls{/number}","milestones_url":"https://api.github.com/repos/ocefpaf/xarray/milestones{/number}","notifications_url":"https://api.github.com/repos/ocefpaf/xarray/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ocefpaf/xarray/labels{/name}","releases_url":"https://api.github.com/repos/ocefpaf/xarray/releases{/id}","deployments_url":"https://api.github.com/repos/ocefpaf/xarray/deployments","created_at":"2016-05-03T20:46:18Z","updated_at":"2016-05-03T20:46:19Z","pushed_at":"2016-05-10T23:36:19Z","git_url":"git://github.com/ocefpaf/xarray.git","ssh_url":"git@github.com:ocefpaf/xarray.git","clone_url":"https://github.com/ocefpaf/xarray.git","svn_url":"https://github.com/ocefpaf/xarray","homepage":"http://xarray.pydata.org","size":6264,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"pydata:master","ref":"master","sha":"b25d145b092e1f0ae6555e9ac2103a7afb838592","user":{"login":"pydata","id":1284191,"avatar_url":"https://avatars.githubusercontent.com/u/1284191?v=3","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,"name":"xarray","full_name":"pydata/xarray","owner":{"login":"pydata","id":1284191,"avatar_url":"https://avatars.githubusercontent.com/u/1284191?v=3","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},"private":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":"2016-05-10T05:21:45Z","pushed_at":"2016-05-10T23:36:20Z","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":6762,"stargazers_count":371,"watchers_count":371,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":104,"mirror_url":null,"open_issues_count":159,"forks":104,"open_issues":159,"watchers":371,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pydata/xarray/pulls/844"},"html":{"href":"https://github.com/pydata/xarray/pull/844"},"issue":{"href":"https://api.github.com/repos/pydata/xarray/issues/844"},"comments":{"href":"https://api.github.com/repos/pydata/xarray/issues/844/comments"},"review_comments":{"href":"https://api.github.com/repos/pydata/xarray/pulls/844/comments"},"review_comment":{"href":"https://api.github.com/repos/pydata/xarray/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pydata/xarray/pulls/844/commits"},"statuses":{"href":"https://api.github.com/repos/pydata/xarray/statuses/1385f5f386c5398b829066f065bbf6971ae01460"}}}}