GitHub PullRequestReviewCommentEvent at 2014-11-29 22:06:05
Repository: matplotlib
Actor: tacaswell
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/matplotlib/matplotlib/pulls/comments/21056582","id":21056582,"diff_hunk":"@@ -969,6 +970,88 @@ def scaled(self):\n         return (self.vmin is not None and self.vmax is not None)\n \n \n+class OffsetNorm(Normalize):\n+    def __init__(self, vmin=None, vcenter=None, vmax=None, clip=False):\n+        self.vmin = vmin\n+        self.vcenter = vcenter\n+        self.vmax = vmax\n+        self.clip = clip\n+\n+    def __call__(self, value, clip=False):\n+        if clip is None:\n+            clip = self.clip\n+\n+        result, is_scalar = self.process_value(value)\n+\n+        self.autoscale_None(result)\n+        vmin, vcenter, vmax = self.vmin, self.vcenter, self.vmax\n+        if vmin == vmax == vcenter:\n+            result.fill(0)\n+        elif not vmin <= vcenter <= vmax:\n+            raise ValueError(\"minvalue must be less than or equal to \"\n+                             \"centervalue which must be less than or \"\n+                             \"equal to maxvalue\")\n+        else:\n+            vmin = float(vmin)\n+            vcenter = float(vcenter)\n+            vmax = float(vmax)\n+            if clip:\n+                mask = ma.getmask(result)\n+                result = ma.array(np.clip(result.filled(vmax), vmin, vmax),\n+                                  mask=mask)\n+\n+            resdat = result.data\n+            lower = resdat[resdat < vcenter]\n+            upper = resdat[resdat >= vcenter]\n+\n+            lower -= vmin\n+            lower /= ((vcenter-vmin) * 2)\n+\n+            upper -= vcenter\n+            upper /= ((vmax-vcenter) * 2)\n+            upper += 0.5\n+\n+            resdat = np.hstack([lower, upper])\n+\n+            result = np.ma.array(resdat, mask=result.mask, copy=False)\n+\n+        if is_scalar:\n+            result = result[0]\n+\n+        return result\n+\n+    def inverse(self, value):\n+        midpoint = 0.5\n+        if not self.scaled():\n+            raise ValueError(\"Not invertible until scaled\")\n+\n+        vmin = float(self.vmin)\n+        vcenter = float(self.vcenter)","path":"lib/matplotlib/colors.py","position":68,"original_position":68,"commit_id":"2d4166415ef6168693a4d3efb4e53a12ca346f5c","original_commit_id":"2d4166415ef6168693a4d3efb4e53a12ca346f5c","user":{"login":"tacaswell","id":199813,"avatar_url":"https://avatars.githubusercontent.com/u/199813?v=3","gravatar_id":"","url":"https://api.github.com/users/tacaswell","html_url":"https://github.com/tacaswell","followers_url":"https://api.github.com/users/tacaswell/followers","following_url":"https://api.github.com/users/tacaswell/following{/other_user}","gists_url":"https://api.github.com/users/tacaswell/gists{/gist_id}","starred_url":"https://api.github.com/users/tacaswell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tacaswell/subscriptions","organizations_url":"https://api.github.com/users/tacaswell/orgs","repos_url":"https://api.github.com/users/tacaswell/repos","events_url":"https://api.github.com/users/tacaswell/events{/privacy}","received_events_url":"https://api.github.com/users/tacaswell/received_events","type":"User","site_admin":false},"body":"I think there is a code path that will end up with `self.vcenter` to be `None`?  I think you need to also override `autoscale_None` to make sure it gets set.","created_at":"2014-11-29T22:06:05Z","updated_at":"2014-11-29T22:06:05Z","html_url":"https://github.com/matplotlib/matplotlib/pull/3858#discussion_r21056582","pull_request_url":"https://api.github.com/repos/matplotlib/matplotlib/pulls/3858","_links":{"self":{"href":"https://api.github.com/repos/matplotlib/matplotlib/pulls/comments/21056582"},"html":{"href":"https://github.com/matplotlib/matplotlib/pull/3858#discussion_r21056582"},"pull_request":{"href":"https://api.github.com/repos/matplotlib/matplotlib/pulls/3858"}}},"pull_request":{"url":"https://api.github.com/repos/matplotlib/matplotlib/pulls/3858","id":25161212,"html_url":"https://github.com/matplotlib/matplotlib/pull/3858","diff_url":"https://github.com/matplotlib/matplotlib/pull/3858.diff","patch_url":"https://github.com/matplotlib/matplotlib/pull/3858.patch","issue_url":"https://api.github.com/repos/matplotlib/matplotlib/issues/3858","number":3858,"state":"open","locked":false,"title":"WIP: Add offset, symmetrical normalizers","user":{"login":"phobson","id":1163939,"avatar_url":"https://avatars.githubusercontent.com/u/1163939?v=3","gravatar_id":"","url":"https://api.github.com/users/phobson","html_url":"https://github.com/phobson","followers_url":"https://api.github.com/users/phobson/followers","following_url":"https://api.github.com/users/phobson/following{/other_user}","gists_url":"https://api.github.com/users/phobson/gists{/gist_id}","starred_url":"https://api.github.com/users/phobson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phobson/subscriptions","organizations_url":"https://api.github.com/users/phobson/orgs","repos_url":"https://api.github.com/users/phobson/repos","events_url":"https://api.github.com/users/phobson/events{/privacy}","received_events_url":"https://api.github.com/users/phobson/received_events","type":"User","site_admin":false},"body":"Trying to close https://github.com/matplotlib/matplotlib/issues/1806\r\n\r\nNot currently on  a good machine for development, but I think this pretty straight-forward, so hopefully Travis a test runner will suffice...\r\n\r\n`OffsetNorm`: This let's you set vmin, vcenter, and vmax. The use case for this is when you have data ranging from e.g., -1, to +2, and you  want the the white/gray part at 0, but would also like to use the full range of the red scale. So:\r\n\r\n```python\r\noffset = mcolors.OffsetNorm(vmin=-1, vcenter=0, vmax=2)\r\noffset([-1.0, -0.5, 0.0, 1.0, 2.,])\r\n\r\n#prints\r\n[0, 0.25, 0.5, 0.75, 1.0]\r\n```\r\n\r\nNext I'll add `SymNorm`, that will look at the absolute values of vmin and vmax to produce:\r\n```python\r\nsym = mcolors.SymNorm(vmin=-1, vcenter=0, vmax=2)\r\nsym([-1.0, -0.5, 0.0, 1.0, 2.,])\r\n\r\n#prints\r\n[0.25, 0.325, 0.5, 0.75, 1.0]\r\n```","created_at":"2014-11-27T16:31:23Z","updated_at":"2014-11-29T22:06:05Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a0b67a5dfe0af507c3e7fe82749f63c6c135c574","assignee":null,"milestone":{"url":"https://api.github.com/repos/matplotlib/matplotlib/milestones/12","labels_url":"https://api.github.com/repos/matplotlib/matplotlib/milestones/12/labels","id":534144,"number":12,"title":"v1.5.x","description":null,"creator":{"login":"tacaswell","id":199813,"avatar_url":"https://avatars.githubusercontent.com/u/199813?v=3","gravatar_id":"","url":"https://api.github.com/users/tacaswell","html_url":"https://github.com/tacaswell","followers_url":"https://api.github.com/users/tacaswell/followers","following_url":"https://api.github.com/users/tacaswell/following{/other_user}","gists_url":"https://api.github.com/users/tacaswell/gists{/gist_id}","starred_url":"https://api.github.com/users/tacaswell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tacaswell/subscriptions","organizations_url":"https://api.github.com/users/tacaswell/orgs","repos_url":"https://api.github.com/users/tacaswell/repos","events_url":"https://api.github.com/users/tacaswell/events{/privacy}","received_events_url":"https://api.github.com/users/tacaswell/received_events","type":"User","site_admin":false},"open_issues":227,"closed_issues":119,"state":"open","created_at":"2014-01-13T03:21:09Z","updated_at":"2014-11-29T22:00:52Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/matplotlib/matplotlib/pulls/3858/commits","review_comments_url":"https://api.github.com/repos/matplotlib/matplotlib/pulls/3858/comments","review_comment_url":"https://api.github.com/repos/matplotlib/matplotlib/pulls/comments/{number}","comments_url":"https://api.github.com/repos/matplotlib/matplotlib/issues/3858/comments","statuses_url":"https://api.github.com/repos/matplotlib/matplotlib/statuses/2d4166415ef6168693a4d3efb4e53a12ca346f5c","head":{"label":"phobson:add-asym-norm","ref":"add-asym-norm","sha":"2d4166415ef6168693a4d3efb4e53a12ca346f5c","user":{"login":"phobson","id":1163939,"avatar_url":"https://avatars.githubusercontent.com/u/1163939?v=3","gravatar_id":"","url":"https://api.github.com/users/phobson","html_url":"https://github.com/phobson","followers_url":"https://api.github.com/users/phobson/followers","following_url":"https://api.github.com/users/phobson/following{/other_user}","gists_url":"https://api.github.com/users/phobson/gists{/gist_id}","starred_url":"https://api.github.com/users/phobson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phobson/subscriptions","organizations_url":"https://api.github.com/users/phobson/orgs","repos_url":"https://api.github.com/users/phobson/repos","events_url":"https://api.github.com/users/phobson/events{/privacy}","received_events_url":"https://api.github.com/users/phobson/received_events","type":"User","site_admin":false},"repo":{"id":4459660,"name":"matplotlib","full_name":"phobson/matplotlib","owner":{"login":"phobson","id":1163939,"avatar_url":"https://avatars.githubusercontent.com/u/1163939?v=3","gravatar_id":"","url":"https://api.github.com/users/phobson","html_url":"https://github.com/phobson","followers_url":"https://api.github.com/users/phobson/followers","following_url":"https://api.github.com/users/phobson/following{/other_user}","gists_url":"https://api.github.com/users/phobson/gists{/gist_id}","starred_url":"https://api.github.com/users/phobson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phobson/subscriptions","organizations_url":"https://api.github.com/users/phobson/orgs","repos_url":"https://api.github.com/users/phobson/repos","events_url":"https://api.github.com/users/phobson/events{/privacy}","received_events_url":"https://api.github.com/users/phobson/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/phobson/matplotlib","description":"","fork":true,"url":"https://api.github.com/repos/phobson/matplotlib","forks_url":"https://api.github.com/repos/phobson/matplotlib/forks","keys_url":"https://api.github.com/repos/phobson/matplotlib/keys{/key_id}","collaborators_url":"https://api.github.com/repos/phobson/matplotlib/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/phobson/matplotlib/teams","hooks_url":"https://api.github.com/repos/phobson/matplotlib/hooks","issue_events_url":"https://api.github.com/repos/phobson/matplotlib/issues/events{/number}","events_url":"https://api.github.com/repos/phobson/matplotlib/events","assignees_url":"https://api.github.com/repos/phobson/matplotlib/assignees{/user}","branches_url":"https://api.github.com/repos/phobson/matplotlib/branches{/branch}","tags_url":"https://api.github.com/repos/phobson/matplotlib/tags","blobs_url":"https://api.github.com/repos/phobson/matplotlib/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/phobson/matplotlib/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/phobson/matplotlib/git/refs{/sha}","trees_url":"https://api.github.com/repos/phobson/matplotlib/git/trees{/sha}","statuses_url":"https://api.github.com/repos/phobson/matplotlib/statuses/{sha}","languages_url":"https://api.github.com/repos/phobson/matplotlib/languages","stargazers_url":"https://api.github.com/repos/phobson/matplotlib/stargazers","contributors_url":"https://api.github.com/repos/phobson/matplotlib/contributors","subscribers_url":"https://api.github.com/repos/phobson/matplotlib/subscribers","subscription_url":"https://api.github.com/repos/phobson/matplotlib/subscription","commits_url":"https://api.github.com/repos/phobson/matplotlib/commits{/sha}","git_commits_url":"https://api.github.com/repos/phobson/matplotlib/git/commits{/sha}","comments_url":"https://api.github.com/repos/phobson/matplotlib/comments{/number}","issue_comment_url":"https://api.github.com/repos/phobson/matplotlib/issues/comments/{number}","contents_url":"https://api.github.com/repos/phobson/matplotlib/contents/{+path}","compare_url":"https://api.github.com/repos/phobson/matplotlib/compare/{base}...{head}","merges_url":"https://api.github.com/repos/phobson/matplotlib/merges","archive_url":"https://api.github.com/repos/phobson/matplotlib/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/phobson/matplotlib/downloads","issues_url":"https://api.github.com/repos/phobson/matplotlib/issues{/number}","pulls_url":"https://api.github.com/repos/phobson/matplotlib/pulls{/number}","milestones_url":"https://api.github.com/repos/phobson/matplotlib/milestones{/number}","notifications_url":"https://api.github.com/repos/phobson/matplotlib/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/phobson/matplotlib/labels{/name}","releases_url":"https://api.github.com/repos/phobson/matplotlib/releases{/id}","created_at":"2012-05-27T03:36:20Z","updated_at":"2014-11-27T16:46:07Z","pushed_at":"2014-11-27T23:38:42Z","git_url":"git://github.com/phobson/matplotlib.git","ssh_url":"git@github.com:phobson/matplotlib.git","clone_url":"https://github.com/phobson/matplotlib.git","svn_url":"https://github.com/phobson/matplotlib","homepage":"","size":197522,"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":"matplotlib:master","ref":"master","sha":"df3530de9b67b9b35ce0a8f68a1417949f34dffa","user":{"login":"matplotlib","id":215947,"avatar_url":"https://avatars.githubusercontent.com/u/215947?v=3","gravatar_id":"","url":"https://api.github.com/users/matplotlib","html_url":"https://github.com/matplotlib","followers_url":"https://api.github.com/users/matplotlib/followers","following_url":"https://api.github.com/users/matplotlib/following{/other_user}","gists_url":"https://api.github.com/users/matplotlib/gists{/gist_id}","starred_url":"https://api.github.com/users/matplotlib/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matplotlib/subscriptions","organizations_url":"https://api.github.com/users/matplotlib/orgs","repos_url":"https://api.github.com/users/matplotlib/repos","events_url":"https://api.github.com/users/matplotlib/events{/privacy}","received_events_url":"https://api.github.com/users/matplotlib/received_events","type":"Organization","site_admin":false},"repo":{"id":1385122,"name":"matplotlib","full_name":"matplotlib/matplotlib","owner":{"login":"matplotlib","id":215947,"avatar_url":"https://avatars.githubusercontent.com/u/215947?v=3","gravatar_id":"","url":"https://api.github.com/users/matplotlib","html_url":"https://github.com/matplotlib","followers_url":"https://api.github.com/users/matplotlib/followers","following_url":"https://api.github.com/users/matplotlib/following{/other_user}","gists_url":"https://api.github.com/users/matplotlib/gists{/gist_id}","starred_url":"https://api.github.com/users/matplotlib/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matplotlib/subscriptions","organizations_url":"https://api.github.com/users/matplotlib/orgs","repos_url":"https://api.github.com/users/matplotlib/repos","events_url":"https://api.github.com/users/matplotlib/events{/privacy}","received_events_url":"https://api.github.com/users/matplotlib/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/matplotlib/matplotlib","description":"matplotlib: plotting with Python","fork":false,"url":"https://api.github.com/repos/matplotlib/matplotlib","forks_url":"https://api.github.com/repos/matplotlib/matplotlib/forks","keys_url":"https://api.github.com/repos/matplotlib/matplotlib/keys{/key_id}","collaborators_url":"https://api.github.com/repos/matplotlib/matplotlib/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/matplotlib/matplotlib/teams","hooks_url":"https://api.github.com/repos/matplotlib/matplotlib/hooks","issue_events_url":"https://api.github.com/repos/matplotlib/matplotlib/issues/events{/number}","events_url":"https://api.github.com/repos/matplotlib/matplotlib/events","assignees_url":"https://api.github.com/repos/matplotlib/matplotlib/assignees{/user}","branches_url":"https://api.github.com/repos/matplotlib/matplotlib/branches{/branch}","tags_url":"https://api.github.com/repos/matplotlib/matplotlib/tags","blobs_url":"https://api.github.com/repos/matplotlib/matplotlib/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/matplotlib/matplotlib/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/matplotlib/matplotlib/git/refs{/sha}","trees_url":"https://api.github.com/repos/matplotlib/matplotlib/git/trees{/sha}","statuses_url":"https://api.github.com/repos/matplotlib/matplotlib/statuses/{sha}","languages_url":"https://api.github.com/repos/matplotlib/matplotlib/languages","stargazers_url":"https://api.github.com/repos/matplotlib/matplotlib/stargazers","contributors_url":"https://api.github.com/repos/matplotlib/matplotlib/contributors","subscribers_url":"https://api.github.com/repos/matplotlib/matplotlib/subscribers","subscription_url":"https://api.github.com/repos/matplotlib/matplotlib/subscription","commits_url":"https://api.github.com/repos/matplotlib/matplotlib/commits{/sha}","git_commits_url":"https://api.github.com/repos/matplotlib/matplotlib/git/commits{/sha}","comments_url":"https://api.github.com/repos/matplotlib/matplotlib/comments{/number}","issue_comment_url":"https://api.github.com/repos/matplotlib/matplotlib/issues/comments/{number}","contents_url":"https://api.github.com/repos/matplotlib/matplotlib/contents/{+path}","compare_url":"https://api.github.com/repos/matplotlib/matplotlib/compare/{base}...{head}","merges_url":"https://api.github.com/repos/matplotlib/matplotlib/merges","archive_url":"https://api.github.com/repos/matplotlib/matplotlib/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/matplotlib/matplotlib/downloads","issues_url":"https://api.github.com/repos/matplotlib/matplotlib/issues{/number}","pulls_url":"https://api.github.com/repos/matplotlib/matplotlib/pulls{/number}","milestones_url":"https://api.github.com/repos/matplotlib/matplotlib/milestones{/number}","notifications_url":"https://api.github.com/repos/matplotlib/matplotlib/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/matplotlib/matplotlib/labels{/name}","releases_url":"https://api.github.com/repos/matplotlib/matplotlib/releases{/id}","created_at":"2011-02-19T03:17:12Z","updated_at":"2014-11-29T21:35:58Z","pushed_at":"2014-11-27T19:08:31Z","git_url":"git://github.com/matplotlib/matplotlib.git","ssh_url":"git@github.com:matplotlib/matplotlib.git","clone_url":"https://github.com/matplotlib/matplotlib.git","svn_url":"https://github.com/matplotlib/matplotlib","homepage":"http://matplotlib.org/","size":257611,"stargazers_count":2060,"watchers_count":2060,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":996,"mirror_url":null,"open_issues_count":425,"forks":996,"open_issues":425,"watchers":2060,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/matplotlib/matplotlib/pulls/3858"},"html":{"href":"https://github.com/matplotlib/matplotlib/pull/3858"},"issue":{"href":"https://api.github.com/repos/matplotlib/matplotlib/issues/3858"},"comments":{"href":"https://api.github.com/repos/matplotlib/matplotlib/issues/3858/comments"},"review_comments":{"href":"https://api.github.com/repos/matplotlib/matplotlib/pulls/3858/comments"},"review_comment":{"href":"https://api.github.com/repos/matplotlib/matplotlib/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/matplotlib/matplotlib/pulls/3858/commits"},"statuses":{"href":"https://api.github.com/repos/matplotlib/matplotlib/statuses/2d4166415ef6168693a4d3efb4e53a12ca346f5c"}}}}