{"action":"created","comment":{"url":"https://api.github.com/repos/SciTools/iris/pulls/comments/33344447","id":33344447,"diff_hunk":"@@ -166,10 +207,79 @@ def __call__(self, xi, method=None):\n                     raise ValueError(\"One of the requested xi is out of \"\n                                      \"bounds in dimension %d\" % i)\n \n-        indices, norm_distances, out_of_bounds = self._find_indices(xi.T)\n+        method = self.method if method is None else method\n+        prepared = (xi_shape, method) + self._find_indices(xi.T)\n+        if TIMINGS:\n+            print('Prepare:', time.time() - t0)\n+\n+        if SPARSE and method == 'linear':\n+            t0 = time.time()\n+\n+            xi_shape, method, indices, norm_distances, out_of_bounds = prepared\n+\n+            # Allocate arrays for describing the sparse matrix.\n+            n_src_values_per_result_value = 2 ** ndim\n+            n_result_values = len(indices[0])\n+            n_non_zero = n_result_values * n_src_values_per_result_value\n+            weights = np.ones(n_non_zero, dtype=norm_distances[0].dtype)\n+            col_indices = np.empty(n_non_zero)\n+            row_ptrs = np.arange(0, n_non_zero + n_src_values_per_result_value,\n+                                 n_src_values_per_result_value)\n+\n+            corners = itertools.product(*[[(i, 1 - n), (i + 1, n)]\n+                                          for i, n in zip(indices,\n+                                                          norm_distances)])\n+            shape = self.values.shape[:ndim]\n+\n+            for i, corner in enumerate(corners):\n+                corner_indices = [ci for ci, cw in corner]\n+                n_indices = np.ravel_multi_index(corner_indices, shape,\n+                                                 mode='wrap')\n+                col_indices[i::n_src_values_per_result_value] = n_indices\n+                for ci, cw in corner:\n+                    weights[i::n_src_values_per_result_value] *= cw\n+\n+            n_src_values = np.prod(map(len, self.grid))\n+            sparse_matrix = csr_matrix((weights, col_indices, row_ptrs),\n+                                       shape=(n_result_values, n_src_values))\n+            if TIMINGS:\n+                print('Convert:', time.time() - t0)\n+\n+            # XXX Hacky-Mc-Hack-Hack\n+            prepared = (xi_shape, method, sparse_matrix, None, out_of_bounds)\n+\n+        return prepared\n+\n+    def interp_using_pre_computed_weights(self, computed_weights):\n+        \"\"\"\n+        Do the interpolation, given pre-computed interpolation weights.","path":"lib/iris/analysis/_scipy_interpolate.py","position":125,"original_position":129,"commit_id":"3d049b014b3fb74d3470e0658dfa492c4698b13e","original_commit_id":"c1d65d24f2f16cdf7918ce9fcd11141f9d755a64","user":{"login":"dkillick","id":3473068,"avatar_url":"https://avatars.githubusercontent.com/u/3473068?v=3","gravatar_id":"","url":"https://api.github.com/users/dkillick","html_url":"https://github.com/dkillick","followers_url":"https://api.github.com/users/dkillick/followers","following_url":"https://api.github.com/users/dkillick/following{/other_user}","gists_url":"https://api.github.com/users/dkillick/gists{/gist_id}","starred_url":"https://api.github.com/users/dkillick/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dkillick/subscriptions","organizations_url":"https://api.github.com/users/dkillick/orgs","repos_url":"https://api.github.com/users/dkillick/repos","events_url":"https://api.github.com/users/dkillick/events{/privacy}","received_events_url":"https://api.github.com/users/dkillick/received_events","type":"User","site_admin":false},"body":"You know what, the rest of the sentence isn't up to much either. How about...\r\n`Perform the interpolation using pre-computed interpolation weights.`","created_at":"2015-06-26T10:25:36Z","updated_at":"2015-06-26T10:25:36Z","html_url":"https://github.com/SciTools/iris/pull/1706#discussion_r33344447","pull_request_url":"https://api.github.com/repos/SciTools/iris/pulls/1706","_links":{"self":{"href":"https://api.github.com/repos/SciTools/iris/pulls/comments/33344447"},"html":{"href":"https://github.com/SciTools/iris/pull/1706#discussion_r33344447"},"pull_request":{"href":"https://api.github.com/repos/SciTools/iris/pulls/1706"}}},"pull_request":{"url":"https://api.github.com/repos/SciTools/iris/pulls/1706","id":38310811,"html_url":"https://github.com/SciTools/iris/pull/1706","diff_url":"https://github.com/SciTools/iris/pull/1706.diff","patch_url":"https://github.com/SciTools/iris/pull/1706.patch","issue_url":"https://api.github.com/repos/SciTools/iris/issues/1706","number":1706,"state":"open","locked":false,"title":"Rebase of Sparse-Matrix Interpolation from Decoupler Branch","user":{"login":"mo-g","id":10463172,"avatar_url":"https://avatars.githubusercontent.com/u/10463172?v=3","gravatar_id":"","url":"https://api.github.com/users/mo-g","html_url":"https://github.com/mo-g","followers_url":"https://api.github.com/users/mo-g/followers","following_url":"https://api.github.com/users/mo-g/following{/other_user}","gists_url":"https://api.github.com/users/mo-g/gists{/gist_id}","starred_url":"https://api.github.com/users/mo-g/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mo-g/subscriptions","organizations_url":"https://api.github.com/users/mo-g/orgs","repos_url":"https://api.github.com/users/mo-g/repos","events_url":"https://api.github.com/users/mo-g/events{/privacy}","received_events_url":"https://api.github.com/users/mo-g/received_events","type":"User","site_admin":false},"body":"Some tests and a small docstring change to the sparse-matrix changes implemented on the decoupler branch.","created_at":"2015-06-23T08:11:28Z","updated_at":"2015-06-26T10:25:36Z","closed_at":null,"merged_at":null,"merge_commit_sha":"bcaa358a6efc89bf8fce3b010426fdbed5cdaaf7","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/SciTools/iris/pulls/1706/commits","review_comments_url":"https://api.github.com/repos/SciTools/iris/pulls/1706/comments","review_comment_url":"https://api.github.com/repos/SciTools/iris/pulls/comments{/number}","comments_url":"https://api.github.com/repos/SciTools/iris/issues/1706/comments","statuses_url":"https://api.github.com/repos/SciTools/iris/statuses/3d049b014b3fb74d3470e0658dfa492c4698b13e","head":{"label":"mo-g:rebase-decoupler-sparse","ref":"rebase-decoupler-sparse","sha":"3d049b014b3fb74d3470e0658dfa492c4698b13e","user":{"login":"mo-g","id":10463172,"avatar_url":"https://avatars.githubusercontent.com/u/10463172?v=3","gravatar_id":"","url":"https://api.github.com/users/mo-g","html_url":"https://github.com/mo-g","followers_url":"https://api.github.com/users/mo-g/followers","following_url":"https://api.github.com/users/mo-g/following{/other_user}","gists_url":"https://api.github.com/users/mo-g/gists{/gist_id}","starred_url":"https://api.github.com/users/mo-g/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mo-g/subscriptions","organizations_url":"https://api.github.com/users/mo-g/orgs","repos_url":"https://api.github.com/users/mo-g/repos","events_url":"https://api.github.com/users/mo-g/events{/privacy}","received_events_url":"https://api.github.com/users/mo-g/received_events","type":"User","site_admin":false},"repo":{"id":31591328,"name":"iris","full_name":"mo-g/iris","owner":{"login":"mo-g","id":10463172,"avatar_url":"https://avatars.githubusercontent.com/u/10463172?v=3","gravatar_id":"","url":"https://api.github.com/users/mo-g","html_url":"https://github.com/mo-g","followers_url":"https://api.github.com/users/mo-g/followers","following_url":"https://api.github.com/users/mo-g/following{/other_user}","gists_url":"https://api.github.com/users/mo-g/gists{/gist_id}","starred_url":"https://api.github.com/users/mo-g/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mo-g/subscriptions","organizations_url":"https://api.github.com/users/mo-g/orgs","repos_url":"https://api.github.com/users/mo-g/repos","events_url":"https://api.github.com/users/mo-g/events{/privacy}","received_events_url":"https://api.github.com/users/mo-g/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mo-g/iris","description":"A powerful, easy to use, and community-driven Python library for analysing and visualising meteorological and oceanographic data sets.","fork":true,"url":"https://api.github.com/repos/mo-g/iris","forks_url":"https://api.github.com/repos/mo-g/iris/forks","keys_url":"https://api.github.com/repos/mo-g/iris/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mo-g/iris/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mo-g/iris/teams","hooks_url":"https://api.github.com/repos/mo-g/iris/hooks","issue_events_url":"https://api.github.com/repos/mo-g/iris/issues/events{/number}","events_url":"https://api.github.com/repos/mo-g/iris/events","assignees_url":"https://api.github.com/repos/mo-g/iris/assignees{/user}","branches_url":"https://api.github.com/repos/mo-g/iris/branches{/branch}","tags_url":"https://api.github.com/repos/mo-g/iris/tags","blobs_url":"https://api.github.com/repos/mo-g/iris/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mo-g/iris/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mo-g/iris/git/refs{/sha}","trees_url":"https://api.github.com/repos/mo-g/iris/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mo-g/iris/statuses/{sha}","languages_url":"https://api.github.com/repos/mo-g/iris/languages","stargazers_url":"https://api.github.com/repos/mo-g/iris/stargazers","contributors_url":"https://api.github.com/repos/mo-g/iris/contributors","subscribers_url":"https://api.github.com/repos/mo-g/iris/subscribers","subscription_url":"https://api.github.com/repos/mo-g/iris/subscription","commits_url":"https://api.github.com/repos/mo-g/iris/commits{/sha}","git_commits_url":"https://api.github.com/repos/mo-g/iris/git/commits{/sha}","comments_url":"https://api.github.com/repos/mo-g/iris/comments{/number}","issue_comment_url":"https://api.github.com/repos/mo-g/iris/issues/comments{/number}","contents_url":"https://api.github.com/repos/mo-g/iris/contents/{+path}","compare_url":"https://api.github.com/repos/mo-g/iris/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mo-g/iris/merges","archive_url":"https://api.github.com/repos/mo-g/iris/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mo-g/iris/downloads","issues_url":"https://api.github.com/repos/mo-g/iris/issues{/number}","pulls_url":"https://api.github.com/repos/mo-g/iris/pulls{/number}","milestones_url":"https://api.github.com/repos/mo-g/iris/milestones{/number}","notifications_url":"https://api.github.com/repos/mo-g/iris/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mo-g/iris/labels{/name}","releases_url":"https://api.github.com/repos/mo-g/iris/releases{/id}","created_at":"2015-03-03T09:54:07Z","updated_at":"2015-04-01T09:17:10Z","pushed_at":"2015-06-26T10:24:06Z","git_url":"git://github.com/mo-g/iris.git","ssh_url":"git@github.com:mo-g/iris.git","clone_url":"https://github.com/mo-g/iris.git","svn_url":"https://github.com/mo-g/iris","homepage":"http://scitools.org.uk/iris/","size":96970,"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":"SciTools:master","ref":"master","sha":"ee7f7c25d6e3faa3e948552423fa5054ccbcd9d6","user":{"login":"SciTools","id":1391487,"avatar_url":"https://avatars.githubusercontent.com/u/1391487?v=3","gravatar_id":"","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=3","gravatar_id":"","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":"2015-06-19T05:52:44Z","pushed_at":"2015-06-26T10:24:07Z","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":147182,"stargazers_count":92,"watchers_count":92,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":72,"mirror_url":null,"open_issues_count":166,"forks":72,"open_issues":166,"watchers":92,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/SciTools/iris/pulls/1706"},"html":{"href":"https://github.com/SciTools/iris/pull/1706"},"issue":{"href":"https://api.github.com/repos/SciTools/iris/issues/1706"},"comments":{"href":"https://api.github.com/repos/SciTools/iris/issues/1706/comments"},"review_comments":{"href":"https://api.github.com/repos/SciTools/iris/pulls/1706/comments"},"review_comment":{"href":"https://api.github.com/repos/SciTools/iris/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/SciTools/iris/pulls/1706/commits"},"statuses":{"href":"https://api.github.com/repos/SciTools/iris/statuses/3d049b014b3fb74d3470e0658dfa492c4698b13e"}}}}