GitHub PullRequestReviewCommentEvent at 2014-09-19 14:27:39
Repository: iris
Actor: bjlittle
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/SciTools/iris/pulls/comments/17787492","id":17787492,"diff_hunk":"@@ -98,14 +106,57 @@ def data(self):\n                 msg = 'Unsupported scanning mode: {}'.format(\n                     grid_section['scanningMode'])\n                 raise TranslationError(msg)\n-            data = sections[7]['codedValues'].reshape(grid_section['Nj'],\n-                                                      grid_section['Ni'])\n+            shape = (grid_section['Nj'], grid_section['Ni'])\n+            proxy = _DataProxy(shape, np.dtype('f8'), np.nan,\n+                               self._recreate_raw, self._regularise)\n+            data = biggus.NumpyArrayAdapter(proxy)\n         else:\n             fmt = 'Grid definition template {} is not supported'\n             raise TranslationError(fmt.format(template))\n         return data\n \n \n+class _DataProxy(object):\n+    \"\"\"A reference to the data payload of a single GRIB message.\"\"\"\n+\n+    __slots__ = ('shape', 'dtype', 'fill_value', 'recreate_raw', 'regularise')\n+\n+    def __init__(self, shape, dtype, fill_value, recreate_raw, regularise):\n+        self.shape = shape\n+        self.dtype = dtype\n+        self.fill_value = fill_value\n+        self.recreate_raw = recreate_raw\n+        self.regularise = regularise\n+\n+    @property\n+    def ndim(self):\n+        return len(self.shape)\n+\n+    def __getitem__(self, keys):\n+        # NB. Currently assumes that the validity of this interpretation\n+        # is checked before this proxy is created.\n+        message = self.recreate_raw()\n+        sections = message.sections\n+        grid_section = sections[3]\n+        data = sections[7]['codedValues'].reshape(grid_section['Nj'],\n+                                                  grid_section['Ni'])\n+        return data.__getitem__(keys)\n+\n+    def __repr__(self):\n+        msg = '<{self.__class__.__name__} shape={self.shape} ' \\\n+          'dtype={self.dtype!r} fill_value={self.fill_value!r} ' \\\n+          'recreate_raw={self.recreate_raw!r} ' \\\n+          'regularise={self.regularise}>'","path":"lib/iris/fileformats/grib/_message.py","position":96,"original_position":96,"commit_id":"07e5f727d3a04de7cfb62908399643d5dda2ce93","original_commit_id":"07e5f727d3a04de7cfb62908399643d5dda2ce93","user":{"login":"bjlittle","id":2051656,"avatar_url":"https://avatars.githubusercontent.com/u/2051656?v=2","gravatar_id":"907798185f1ed99aead3bb410977197b","url":"https://api.github.com/users/bjlittle","html_url":"https://github.com/bjlittle","followers_url":"https://api.github.com/users/bjlittle/followers","following_url":"https://api.github.com/users/bjlittle/following{/other_user}","gists_url":"https://api.github.com/users/bjlittle/gists{/gist_id}","starred_url":"https://api.github.com/users/bjlittle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bjlittle/subscriptions","organizations_url":"https://api.github.com/users/bjlittle/orgs","repos_url":"https://api.github.com/users/bjlittle/repos","events_url":"https://api.github.com/users/bjlittle/events{/privacy}","received_events_url":"https://api.github.com/users/bjlittle/received_events","type":"User","site_admin":false},"body":"@rhattersley indent this block by two more spaces ... pep8 is complaining.","created_at":"2014-09-19T14:27:39Z","updated_at":"2014-09-19T14:27:39Z","html_url":"https://github.com/SciTools/iris/pull/1322#discussion_r17787492","pull_request_url":"https://api.github.com/repos/SciTools/iris/pulls/1322","_links":{"self":{"href":"https://api.github.com/repos/SciTools/iris/pulls/comments/17787492"},"html":{"href":"https://github.com/SciTools/iris/pull/1322#discussion_r17787492"},"pull_request":{"href":"https://api.github.com/repos/SciTools/iris/pulls/1322"}}},"pull_request":{"url":"https://api.github.com/repos/SciTools/iris/pulls/1322","id":21497770,"html_url":"https://github.com/SciTools/iris/pull/1322","diff_url":"https://github.com/SciTools/iris/pull/1322.diff","patch_url":"https://github.com/SciTools/iris/pull/1322.patch","issue_url":"https://api.github.com/repos/SciTools/iris/issues/1322","number":1322,"state":"open","locked":false,"title":"Lazy data for GRIB.","user":{"login":"rhattersley","id":917914,"avatar_url":"https://avatars.githubusercontent.com/u/917914?v=2","gravatar_id":"1889af9f21c3e07af149e04f23a9619b","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},"body":"","created_at":"2014-09-19T13:37:33Z","updated_at":"2014-09-19T14:27:39Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9573d39e60e5647d89d8f0c04e30ce667aa8f172","assignee":{"login":"bjlittle","id":2051656,"avatar_url":"https://avatars.githubusercontent.com/u/2051656?v=2","gravatar_id":"907798185f1ed99aead3bb410977197b","url":"https://api.github.com/users/bjlittle","html_url":"https://github.com/bjlittle","followers_url":"https://api.github.com/users/bjlittle/followers","following_url":"https://api.github.com/users/bjlittle/following{/other_user}","gists_url":"https://api.github.com/users/bjlittle/gists{/gist_id}","starred_url":"https://api.github.com/users/bjlittle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bjlittle/subscriptions","organizations_url":"https://api.github.com/users/bjlittle/orgs","repos_url":"https://api.github.com/users/bjlittle/repos","events_url":"https://api.github.com/users/bjlittle/events{/privacy}","received_events_url":"https://api.github.com/users/bjlittle/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/SciTools/iris/pulls/1322/commits","review_comments_url":"https://api.github.com/repos/SciTools/iris/pulls/1322/comments","review_comment_url":"https://api.github.com/repos/SciTools/iris/pulls/comments/{number}","comments_url":"https://api.github.com/repos/SciTools/iris/issues/1322/comments","statuses_url":"https://api.github.com/repos/SciTools/iris/statuses/07e5f727d3a04de7cfb62908399643d5dda2ce93","head":{"label":"rhattersley:lazy-grib-data","ref":"lazy-grib-data","sha":"07e5f727d3a04de7cfb62908399643d5dda2ce93","user":{"login":"rhattersley","id":917914,"avatar_url":"https://avatars.githubusercontent.com/u/917914?v=2","gravatar_id":"1889af9f21c3e07af149e04f23a9619b","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},"repo":{"id":5312787,"name":"iris","full_name":"rhattersley/iris","owner":{"login":"rhattersley","id":917914,"avatar_url":"https://avatars.githubusercontent.com/u/917914?v=2","gravatar_id":"1889af9f21c3e07af149e04f23a9619b","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},"private":false,"html_url":"https://github.com/rhattersley/iris","description":"","fork":true,"url":"https://api.github.com/repos/rhattersley/iris","forks_url":"https://api.github.com/repos/rhattersley/iris/forks","keys_url":"https://api.github.com/repos/rhattersley/iris/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rhattersley/iris/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rhattersley/iris/teams","hooks_url":"https://api.github.com/repos/rhattersley/iris/hooks","issue_events_url":"https://api.github.com/repos/rhattersley/iris/issues/events{/number}","events_url":"https://api.github.com/repos/rhattersley/iris/events","assignees_url":"https://api.github.com/repos/rhattersley/iris/assignees{/user}","branches_url":"https://api.github.com/repos/rhattersley/iris/branches{/branch}","tags_url":"https://api.github.com/repos/rhattersley/iris/tags","blobs_url":"https://api.github.com/repos/rhattersley/iris/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rhattersley/iris/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rhattersley/iris/git/refs{/sha}","trees_url":"https://api.github.com/repos/rhattersley/iris/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rhattersley/iris/statuses/{sha}","languages_url":"https://api.github.com/repos/rhattersley/iris/languages","stargazers_url":"https://api.github.com/repos/rhattersley/iris/stargazers","contributors_url":"https://api.github.com/repos/rhattersley/iris/contributors","subscribers_url":"https://api.github.com/repos/rhattersley/iris/subscribers","subscription_url":"https://api.github.com/repos/rhattersley/iris/subscription","commits_url":"https://api.github.com/repos/rhattersley/iris/commits{/sha}","git_commits_url":"https://api.github.com/repos/rhattersley/iris/git/commits{/sha}","comments_url":"https://api.github.com/repos/rhattersley/iris/comments{/number}","issue_comment_url":"https://api.github.com/repos/rhattersley/iris/issues/comments/{number}","contents_url":"https://api.github.com/repos/rhattersley/iris/contents/{+path}","compare_url":"https://api.github.com/repos/rhattersley/iris/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rhattersley/iris/merges","archive_url":"https://api.github.com/repos/rhattersley/iris/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rhattersley/iris/downloads","issues_url":"https://api.github.com/repos/rhattersley/iris/issues{/number}","pulls_url":"https://api.github.com/repos/rhattersley/iris/pulls{/number}","milestones_url":"https://api.github.com/repos/rhattersley/iris/milestones{/number}","notifications_url":"https://api.github.com/repos/rhattersley/iris/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rhattersley/iris/labels{/name}","releases_url":"https://api.github.com/repos/rhattersley/iris/releases{/id}","created_at":"2012-08-06T10:24:45Z","updated_at":"2014-06-25T15:40:53Z","pushed_at":"2014-09-19T13:37:19Z","git_url":"git://github.com/rhattersley/iris.git","ssh_url":"git@github.com:rhattersley/iris.git","clone_url":"https://github.com/rhattersley/iris.git","svn_url":"https://github.com/rhattersley/iris","homepage":null,"size":97753,"stargazers_count":1,"watchers_count":1,"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":1,"default_branch":"master"}},"base":{"label":"SciTools:master","ref":"master","sha":"fc2172a7950df123459a29f4571029971f37717b","user":{"login":"SciTools","id":1391487,"avatar_url":"https://avatars.githubusercontent.com/u/1391487?v=2","gravatar_id":null,"url":"https://api.github.com/users/SciTools","html_url":"https://github.com/SciTools","followers_url":"https://api.github.com/users/SciTools/followers","following_url":"https://api.github.com/users/SciTools/following{/other_user}","gists_url":"https://api.github.com/users/SciTools/gists{/gist_id}","starred_url":"https://api.github.com/users/SciTools/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SciTools/subscriptions","organizations_url":"https://api.github.com/users/SciTools/orgs","repos_url":"https://api.github.com/users/SciTools/repos","events_url":"https://api.github.com/users/SciTools/events{/privacy}","received_events_url":"https://api.github.com/users/SciTools/received_events","type":"Organization","site_admin":false},"repo":{"id":5312648,"name":"iris","full_name":"SciTools/iris","owner":{"login":"SciTools","id":1391487,"avatar_url":"https://avatars.githubusercontent.com/u/1391487?v=2","gravatar_id":null,"url":"https://api.github.com/users/SciTools","html_url":"https://github.com/SciTools","followers_url":"https://api.github.com/users/SciTools/followers","following_url":"https://api.github.com/users/SciTools/following{/other_user}","gists_url":"https://api.github.com/users/SciTools/gists{/gist_id}","starred_url":"https://api.github.com/users/SciTools/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SciTools/subscriptions","organizations_url":"https://api.github.com/users/SciTools/orgs","repos_url":"https://api.github.com/users/SciTools/repos","events_url":"https://api.github.com/users/SciTools/events{/privacy}","received_events_url":"https://api.github.com/users/SciTools/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/SciTools/iris","description":"A powerful, easy to use, and community-driven Python library for analysing and visualising meteorological and oceanographic data sets.","fork":false,"url":"https://api.github.com/repos/SciTools/iris","forks_url":"https://api.github.com/repos/SciTools/iris/forks","keys_url":"https://api.github.com/repos/SciTools/iris/keys{/key_id}","collaborators_url":"https://api.github.com/repos/SciTools/iris/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/SciTools/iris/teams","hooks_url":"https://api.github.com/repos/SciTools/iris/hooks","issue_events_url":"https://api.github.com/repos/SciTools/iris/issues/events{/number}","events_url":"https://api.github.com/repos/SciTools/iris/events","assignees_url":"https://api.github.com/repos/SciTools/iris/assignees{/user}","branches_url":"https://api.github.com/repos/SciTools/iris/branches{/branch}","tags_url":"https://api.github.com/repos/SciTools/iris/tags","blobs_url":"https://api.github.com/repos/SciTools/iris/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/SciTools/iris/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/SciTools/iris/git/refs{/sha}","trees_url":"https://api.github.com/repos/SciTools/iris/git/trees{/sha}","statuses_url":"https://api.github.com/repos/SciTools/iris/statuses/{sha}","languages_url":"https://api.github.com/repos/SciTools/iris/languages","stargazers_url":"https://api.github.com/repos/SciTools/iris/stargazers","contributors_url":"https://api.github.com/repos/SciTools/iris/contributors","subscribers_url":"https://api.github.com/repos/SciTools/iris/subscribers","subscription_url":"https://api.github.com/repos/SciTools/iris/subscription","commits_url":"https://api.github.com/repos/SciTools/iris/commits{/sha}","git_commits_url":"https://api.github.com/repos/SciTools/iris/git/commits{/sha}","comments_url":"https://api.github.com/repos/SciTools/iris/comments{/number}","issue_comment_url":"https://api.github.com/repos/SciTools/iris/issues/comments/{number}","contents_url":"https://api.github.com/repos/SciTools/iris/contents/{+path}","compare_url":"https://api.github.com/repos/SciTools/iris/compare/{base}...{head}","merges_url":"https://api.github.com/repos/SciTools/iris/merges","archive_url":"https://api.github.com/repos/SciTools/iris/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/SciTools/iris/downloads","issues_url":"https://api.github.com/repos/SciTools/iris/issues{/number}","pulls_url":"https://api.github.com/repos/SciTools/iris/pulls{/number}","milestones_url":"https://api.github.com/repos/SciTools/iris/milestones{/number}","notifications_url":"https://api.github.com/repos/SciTools/iris/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/SciTools/iris/labels{/name}","releases_url":"https://api.github.com/repos/SciTools/iris/releases{/id}","created_at":"2012-08-06T10:09:14Z","updated_at":"2014-09-03T15:45:46Z","pushed_at":"2014-09-19T13:36:21Z","git_url":"git://github.com/SciTools/iris.git","ssh_url":"git@github.com:SciTools/iris.git","clone_url":"https://github.com/SciTools/iris.git","svn_url":"https://github.com/SciTools/iris","homepage":"http://scitools.org.uk/iris/","size":144285,"stargazers_count":71,"watchers_count":71,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":61,"mirror_url":null,"open_issues_count":142,"forks":61,"open_issues":142,"watchers":71,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/SciTools/iris/pulls/1322"},"html":{"href":"https://github.com/SciTools/iris/pull/1322"},"issue":{"href":"https://api.github.com/repos/SciTools/iris/issues/1322"},"comments":{"href":"https://api.github.com/repos/SciTools/iris/issues/1322/comments"},"review_comments":{"href":"https://api.github.com/repos/SciTools/iris/pulls/1322/comments"},"review_comment":{"href":"https://api.github.com/repos/SciTools/iris/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/SciTools/iris/pulls/1322/commits"},"statuses":{"href":"https://api.github.com/repos/SciTools/iris/statuses/07e5f727d3a04de7cfb62908399643d5dda2ce93"}}}}