{"action":"created","comment":{"url":"https://api.github.com/repos/odlgroup/odl/pulls/comments/48553485","id":48553485,"diff_hunk":"@@ -687,42 +790,185 @@ def _evaluate(self, indices, norm_distances, out=None):\n             return self.values[idx_res]\n \n \n-class _NearestMeshgridInterpolator(_MeshgridInterpolator,\n-                                   _NearestPointwiseInterpolator):\n+def _compute_nearest_weights_edge(idcs, ndist, variant):\n+    \"\"\"Helper for nearest interpolation mimicing the linear case.\"\"\"\n+    # Get out-of-bounds indices from the norm_distances. Negative\n+    # means \"too low\", larger than or equal to 1 means \"too high\"\n+    lo = np.where(ndist < 0)\n+    hi = np.where(ndist > 1)\n+    ones = np.ones_like(ndist)\n+    zeros = np.zeros_like(ndist)\n+\n+    # For \"too low\" nodes, the lower neighbor gets weight zero;\n+    # \"too high\" gets 1.\n+    if variant == 'left':\n+        w_lo = np.where(ndist <= 0.5, ones, zeros)\n+    else:\n+        w_lo = np.where(ndist < 0.5, ones, zeros)\n+\n+    w_lo[lo] = 0\n+    w_lo[hi] = 1\n+\n+    # For \"too high\" nodes, the upper neighbor gets weight zero;\n+    # \"too low\" gets 1.\n+    if variant == 'left':","path":"odl/discr/discr_mappings.py","position":651,"original_position":651,"commit_id":"b3b8ea8a396f3053626980a2f9de8ae8a023ab39","original_commit_id":"b3b8ea8a396f3053626980a2f9de8ae8a023ab39","user":{"login":"kohr-h","id":5030250,"avatar_url":"https://avatars.githubusercontent.com/u/5030250?v=3","gravatar_id":"","url":"https://api.github.com/users/kohr-h","html_url":"https://github.com/kohr-h","followers_url":"https://api.github.com/users/kohr-h/followers","following_url":"https://api.github.com/users/kohr-h/following{/other_user}","gists_url":"https://api.github.com/users/kohr-h/gists{/gist_id}","starred_url":"https://api.github.com/users/kohr-h/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kohr-h/subscriptions","organizations_url":"https://api.github.com/users/kohr-h/orgs","repos_url":"https://api.github.com/users/kohr-h/repos","events_url":"https://api.github.com/users/kohr-h/events{/privacy}","received_events_url":"https://api.github.com/users/kohr-h/received_events","type":"User","site_admin":false},"body":"I see the point. Maybe the situation can be rescued by changing the perspective in that case by checking for `ndist > 0.5` and change the implementation of `_evaluate`.","created_at":"2015-12-29T16:57:09Z","updated_at":"2015-12-29T16:57:09Z","html_url":"https://github.com/odlgroup/odl/pull/190#discussion_r48553485","pull_request_url":"https://api.github.com/repos/odlgroup/odl/pulls/190","_links":{"self":{"href":"https://api.github.com/repos/odlgroup/odl/pulls/comments/48553485"},"html":{"href":"https://github.com/odlgroup/odl/pull/190#discussion_r48553485"},"pull_request":{"href":"https://api.github.com/repos/odlgroup/odl/pulls/190"}}},"pull_request":{"url":"https://api.github.com/repos/odlgroup/odl/pulls/190","id":54602656,"html_url":"https://github.com/odlgroup/odl/pull/190","diff_url":"https://github.com/odlgroup/odl/pull/190.diff","patch_url":"https://github.com/odlgroup/odl/pull/190.patch","issue_url":"https://api.github.com/repos/odlgroup/odl/issues/190","number":190,"state":"open","locked":false,"title":"Issue 158  interpolation","user":{"login":"kohr-h","id":5030250,"avatar_url":"https://avatars.githubusercontent.com/u/5030250?v=3","gravatar_id":"","url":"https://api.github.com/users/kohr-h","html_url":"https://github.com/kohr-h","followers_url":"https://api.github.com/users/kohr-h/followers","following_url":"https://api.github.com/users/kohr-h/following{/other_user}","gists_url":"https://api.github.com/users/kohr-h/gists{/gist_id}","starred_url":"https://api.github.com/users/kohr-h/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kohr-h/subscriptions","organizations_url":"https://api.github.com/users/kohr-h/orgs","repos_url":"https://api.github.com/users/kohr-h/repos","events_url":"https://api.github.com/users/kohr-h/events{/privacy}","received_events_url":"https://api.github.com/users/kohr-h/received_events","type":"User","site_admin":false},"body":"This PR simplifies the interpolator structures significantly by using one class for both arrays and meshgrids and specifying the variant as init argument instead. The principle is to keep the private interpolator classes simple and implement the decision logic in the callers (the interpolation operators).\r\n\r\nSecondly, linear interpolation (#158) now works as specified in our internal discretization schemes. This means that all interpolators assume that the next \"virtual\" node outside the region has value zero. Hence, the value at the boundary is half the value at the last node in the region for linear interpolation. Proper boundary values are yet to be implemented.\r\n\r\nThirdly, interpolation schemes can now be specified per axis with the `PerAxisInterpolation` operator (#159). In fact, linear interpolation is just a special case of this operator. Nearest neighbor, however, has its own implementation for performance reasons (about 3x faster for arrays, about 2^(dim+1) times for meshes).\r\n\r\nAll new features and some old ones come with new tests.\r\n\r\nRemaining TODOs:\r\n- [ ] Cubic spline interpolation -> new issue?\r\n- [ ] Boundary values (grids with \"half basis functions\" at the ends)\r\n- [ ] Periodic interpolation\r\n- [ ] Add per-axis support to `DiscreteLp`\r\n- [ ] Adapt norm, inner product etc.\r\n- New issue: proper tessellations ","created_at":"2015-12-26T13:57:47Z","updated_at":"2015-12-29T16:57:09Z","closed_at":null,"merged_at":null,"merge_commit_sha":"925546c7533168ae28b23f2b17476e58968830f1","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/odlgroup/odl/pulls/190/commits","review_comments_url":"https://api.github.com/repos/odlgroup/odl/pulls/190/comments","review_comment_url":"https://api.github.com/repos/odlgroup/odl/pulls/comments{/number}","comments_url":"https://api.github.com/repos/odlgroup/odl/issues/190/comments","statuses_url":"https://api.github.com/repos/odlgroup/odl/statuses/b3b8ea8a396f3053626980a2f9de8ae8a023ab39","head":{"label":"odlgroup:issue-158__interpolation","ref":"issue-158__interpolation","sha":"b3b8ea8a396f3053626980a2f9de8ae8a023ab39","user":{"login":"odlgroup","id":15667171,"avatar_url":"https://avatars.githubusercontent.com/u/15667171?v=3","gravatar_id":"","url":"https://api.github.com/users/odlgroup","html_url":"https://github.com/odlgroup","followers_url":"https://api.github.com/users/odlgroup/followers","following_url":"https://api.github.com/users/odlgroup/following{/other_user}","gists_url":"https://api.github.com/users/odlgroup/gists{/gist_id}","starred_url":"https://api.github.com/users/odlgroup/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/odlgroup/subscriptions","organizations_url":"https://api.github.com/users/odlgroup/orgs","repos_url":"https://api.github.com/users/odlgroup/repos","events_url":"https://api.github.com/users/odlgroup/events{/privacy}","received_events_url":"https://api.github.com/users/odlgroup/received_events","type":"Organization","site_admin":false},"repo":{"id":45596393,"name":"odl","full_name":"odlgroup/odl","owner":{"login":"odlgroup","id":15667171,"avatar_url":"https://avatars.githubusercontent.com/u/15667171?v=3","gravatar_id":"","url":"https://api.github.com/users/odlgroup","html_url":"https://github.com/odlgroup","followers_url":"https://api.github.com/users/odlgroup/followers","following_url":"https://api.github.com/users/odlgroup/following{/other_user}","gists_url":"https://api.github.com/users/odlgroup/gists{/gist_id}","starred_url":"https://api.github.com/users/odlgroup/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/odlgroup/subscriptions","organizations_url":"https://api.github.com/users/odlgroup/orgs","repos_url":"https://api.github.com/users/odlgroup/repos","events_url":"https://api.github.com/users/odlgroup/events{/privacy}","received_events_url":"https://api.github.com/users/odlgroup/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/odlgroup/odl","description":"Operator Discretization Library","fork":false,"url":"https://api.github.com/repos/odlgroup/odl","forks_url":"https://api.github.com/repos/odlgroup/odl/forks","keys_url":"https://api.github.com/repos/odlgroup/odl/keys{/key_id}","collaborators_url":"https://api.github.com/repos/odlgroup/odl/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/odlgroup/odl/teams","hooks_url":"https://api.github.com/repos/odlgroup/odl/hooks","issue_events_url":"https://api.github.com/repos/odlgroup/odl/issues/events{/number}","events_url":"https://api.github.com/repos/odlgroup/odl/events","assignees_url":"https://api.github.com/repos/odlgroup/odl/assignees{/user}","branches_url":"https://api.github.com/repos/odlgroup/odl/branches{/branch}","tags_url":"https://api.github.com/repos/odlgroup/odl/tags","blobs_url":"https://api.github.com/repos/odlgroup/odl/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/odlgroup/odl/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/odlgroup/odl/git/refs{/sha}","trees_url":"https://api.github.com/repos/odlgroup/odl/git/trees{/sha}","statuses_url":"https://api.github.com/repos/odlgroup/odl/statuses/{sha}","languages_url":"https://api.github.com/repos/odlgroup/odl/languages","stargazers_url":"https://api.github.com/repos/odlgroup/odl/stargazers","contributors_url":"https://api.github.com/repos/odlgroup/odl/contributors","subscribers_url":"https://api.github.com/repos/odlgroup/odl/subscribers","subscription_url":"https://api.github.com/repos/odlgroup/odl/subscription","commits_url":"https://api.github.com/repos/odlgroup/odl/commits{/sha}","git_commits_url":"https://api.github.com/repos/odlgroup/odl/git/commits{/sha}","comments_url":"https://api.github.com/repos/odlgroup/odl/comments{/number}","issue_comment_url":"https://api.github.com/repos/odlgroup/odl/issues/comments{/number}","contents_url":"https://api.github.com/repos/odlgroup/odl/contents/{+path}","compare_url":"https://api.github.com/repos/odlgroup/odl/compare/{base}...{head}","merges_url":"https://api.github.com/repos/odlgroup/odl/merges","archive_url":"https://api.github.com/repos/odlgroup/odl/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/odlgroup/odl/downloads","issues_url":"https://api.github.com/repos/odlgroup/odl/issues{/number}","pulls_url":"https://api.github.com/repos/odlgroup/odl/pulls{/number}","milestones_url":"https://api.github.com/repos/odlgroup/odl/milestones{/number}","notifications_url":"https://api.github.com/repos/odlgroup/odl/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/odlgroup/odl/labels{/name}","releases_url":"https://api.github.com/repos/odlgroup/odl/releases{/id}","created_at":"2015-11-05T07:57:55Z","updated_at":"2015-12-08T12:12:11Z","pushed_at":"2015-12-28T16:47:37Z","git_url":"git://github.com/odlgroup/odl.git","ssh_url":"git@github.com:odlgroup/odl.git","clone_url":"https://github.com/odlgroup/odl.git","svn_url":"https://github.com/odlgroup/odl","homepage":null,"size":14045,"stargazers_count":2,"watchers_count":2,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":61,"forks":2,"open_issues":61,"watchers":2,"default_branch":"master"}},"base":{"label":"odlgroup:master","ref":"master","sha":"618d6e2780d0ac25275cc3eb2af1404fb1d8b693","user":{"login":"odlgroup","id":15667171,"avatar_url":"https://avatars.githubusercontent.com/u/15667171?v=3","gravatar_id":"","url":"https://api.github.com/users/odlgroup","html_url":"https://github.com/odlgroup","followers_url":"https://api.github.com/users/odlgroup/followers","following_url":"https://api.github.com/users/odlgroup/following{/other_user}","gists_url":"https://api.github.com/users/odlgroup/gists{/gist_id}","starred_url":"https://api.github.com/users/odlgroup/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/odlgroup/subscriptions","organizations_url":"https://api.github.com/users/odlgroup/orgs","repos_url":"https://api.github.com/users/odlgroup/repos","events_url":"https://api.github.com/users/odlgroup/events{/privacy}","received_events_url":"https://api.github.com/users/odlgroup/received_events","type":"Organization","site_admin":false},"repo":{"id":45596393,"name":"odl","full_name":"odlgroup/odl","owner":{"login":"odlgroup","id":15667171,"avatar_url":"https://avatars.githubusercontent.com/u/15667171?v=3","gravatar_id":"","url":"https://api.github.com/users/odlgroup","html_url":"https://github.com/odlgroup","followers_url":"https://api.github.com/users/odlgroup/followers","following_url":"https://api.github.com/users/odlgroup/following{/other_user}","gists_url":"https://api.github.com/users/odlgroup/gists{/gist_id}","starred_url":"https://api.github.com/users/odlgroup/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/odlgroup/subscriptions","organizations_url":"https://api.github.com/users/odlgroup/orgs","repos_url":"https://api.github.com/users/odlgroup/repos","events_url":"https://api.github.com/users/odlgroup/events{/privacy}","received_events_url":"https://api.github.com/users/odlgroup/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/odlgroup/odl","description":"Operator Discretization Library","fork":false,"url":"https://api.github.com/repos/odlgroup/odl","forks_url":"https://api.github.com/repos/odlgroup/odl/forks","keys_url":"https://api.github.com/repos/odlgroup/odl/keys{/key_id}","collaborators_url":"https://api.github.com/repos/odlgroup/odl/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/odlgroup/odl/teams","hooks_url":"https://api.github.com/repos/odlgroup/odl/hooks","issue_events_url":"https://api.github.com/repos/odlgroup/odl/issues/events{/number}","events_url":"https://api.github.com/repos/odlgroup/odl/events","assignees_url":"https://api.github.com/repos/odlgroup/odl/assignees{/user}","branches_url":"https://api.github.com/repos/odlgroup/odl/branches{/branch}","tags_url":"https://api.github.com/repos/odlgroup/odl/tags","blobs_url":"https://api.github.com/repos/odlgroup/odl/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/odlgroup/odl/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/odlgroup/odl/git/refs{/sha}","trees_url":"https://api.github.com/repos/odlgroup/odl/git/trees{/sha}","statuses_url":"https://api.github.com/repos/odlgroup/odl/statuses/{sha}","languages_url":"https://api.github.com/repos/odlgroup/odl/languages","stargazers_url":"https://api.github.com/repos/odlgroup/odl/stargazers","contributors_url":"https://api.github.com/repos/odlgroup/odl/contributors","subscribers_url":"https://api.github.com/repos/odlgroup/odl/subscribers","subscription_url":"https://api.github.com/repos/odlgroup/odl/subscription","commits_url":"https://api.github.com/repos/odlgroup/odl/commits{/sha}","git_commits_url":"https://api.github.com/repos/odlgroup/odl/git/commits{/sha}","comments_url":"https://api.github.com/repos/odlgroup/odl/comments{/number}","issue_comment_url":"https://api.github.com/repos/odlgroup/odl/issues/comments{/number}","contents_url":"https://api.github.com/repos/odlgroup/odl/contents/{+path}","compare_url":"https://api.github.com/repos/odlgroup/odl/compare/{base}...{head}","merges_url":"https://api.github.com/repos/odlgroup/odl/merges","archive_url":"https://api.github.com/repos/odlgroup/odl/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/odlgroup/odl/downloads","issues_url":"https://api.github.com/repos/odlgroup/odl/issues{/number}","pulls_url":"https://api.github.com/repos/odlgroup/odl/pulls{/number}","milestones_url":"https://api.github.com/repos/odlgroup/odl/milestones{/number}","notifications_url":"https://api.github.com/repos/odlgroup/odl/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/odlgroup/odl/labels{/name}","releases_url":"https://api.github.com/repos/odlgroup/odl/releases{/id}","created_at":"2015-11-05T07:57:55Z","updated_at":"2015-12-08T12:12:11Z","pushed_at":"2015-12-28T16:47:37Z","git_url":"git://github.com/odlgroup/odl.git","ssh_url":"git@github.com:odlgroup/odl.git","clone_url":"https://github.com/odlgroup/odl.git","svn_url":"https://github.com/odlgroup/odl","homepage":null,"size":14045,"stargazers_count":2,"watchers_count":2,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":61,"forks":2,"open_issues":61,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/odlgroup/odl/pulls/190"},"html":{"href":"https://github.com/odlgroup/odl/pull/190"},"issue":{"href":"https://api.github.com/repos/odlgroup/odl/issues/190"},"comments":{"href":"https://api.github.com/repos/odlgroup/odl/issues/190/comments"},"review_comments":{"href":"https://api.github.com/repos/odlgroup/odl/pulls/190/comments"},"review_comment":{"href":"https://api.github.com/repos/odlgroup/odl/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/odlgroup/odl/pulls/190/commits"},"statuses":{"href":"https://api.github.com/repos/odlgroup/odl/statuses/b3b8ea8a396f3053626980a2f9de8ae8a023ab39"}}}}