{"action":"closed","number":10710,"pull_request":{"url":"https://api.github.com/repos/matplotlib/matplotlib/pulls/10710","id":173566531,"html_url":"https://github.com/matplotlib/matplotlib/pull/10710","diff_url":"https://github.com/matplotlib/matplotlib/pull/10710.diff","patch_url":"https://github.com/matplotlib/matplotlib/pull/10710.patch","issue_url":"https://api.github.com/repos/matplotlib/matplotlib/issues/10710","number":10710,"state":"closed","locked":false,"title":"BUG: Fix UnboundLocalError in contour labelling","user":{"login":"dopplershift","id":221526,"avatar_url":"https://avatars2.githubusercontent.com/u/221526?v=4","gravatar_id":"","url":"https://api.github.com/users/dopplershift","html_url":"https://github.com/dopplershift","followers_url":"https://api.github.com/users/dopplershift/followers","following_url":"https://api.github.com/users/dopplershift/following{/other_user}","gists_url":"https://api.github.com/users/dopplershift/gists{/gist_id}","starred_url":"https://api.github.com/users/dopplershift/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dopplershift/subscriptions","organizations_url":"https://api.github.com/users/dopplershift/orgs","repos_url":"https://api.github.com/users/dopplershift/repos","events_url":"https://api.github.com/users/dopplershift/events{/privacy}","received_events_url":"https://api.github.com/users/dopplershift/received_events","type":"User","site_admin":false},"body":"This fixes hitting the following traceback with 2.2.0 (problem also exists on master):\r\n```pytb\r\n  File \"/home/travis/miniconda/envs/gallery/lib/python3.5/site-packages/matplotlib/pyplot.py\", line 2790, in clabel\r\n    ret = ax.clabel(CS, *args, **kwargs)\r\n  File \"/home/travis/miniconda/envs/gallery/lib/python3.5/site-packages/matplotlib/axes/_axes.py\", line 6173, in clabel\r\n    return CS.clabel(*args, **kwargs)\r\n  File \"/home/travis/miniconda/envs/gallery/lib/python3.5/site-packages/matplotlib/contour.py\", line 213, in clabel\r\n    self.labels(inline, inline_spacing)\r\n  File \"/home/travis/miniconda/envs/gallery/lib/python3.5/site-packages/matplotlib/contour.py\", line 646, in labels\r\n    inline_spacing)\r\n  File \"/home/travis/miniconda/envs/gallery/lib/python3.5/site-packages/matplotlib/contour.py\", line 445, in calc_label_rot_and_inline\r\n    nlc.append(np.row_stack([xy2, lc[I[1]:I[0]+1], xy1]))\r\nUnboundLocalError: local variable 'xy2' referenced before assignment\r\n```\r\n\r\nThat traces back to this block:\r\nhttps://github.com/matplotlib/matplotlib/blob/d2f7bb1d5b7c9de3498741276c4dd0ef57848ba5/lib/matplotlib/contour.py#L433-L444\r\n\r\nThe code was trying to protect the access of xy1 and xy2 to valid cases, using `np.all()`. Unfortunately, in this case `I` is a list, so `I != -1` doesn't do element-by-element or\r\nreturn an error--it just always returns `True`. That caused the if to not actually guard anything. Replaced with `all` and a generator expression.\r\n\r\nI tried making a test, but I couldn't find any sensible set of data to reproduce. We hit this in an example of ours that was using cartopy incorrectly (fixing that problem makes the error disappear). It appears to only trigger when you have a really tiny contour (in display coords) that can't be properly interpolated to create a spot for the contour label.\r\n\r\ncc @anntzer since you introduced this code according to git.","created_at":"2018-03-07T20:36:46Z","updated_at":"2018-03-07T21:26:18Z","closed_at":"2018-03-07T21:26:18Z","merged_at":"2018-03-07T21:26:18Z","merge_commit_sha":"ef5d01a4888e8726be66450d494fa1dc14eca843","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":155360,"url":"https://api.github.com/repos/matplotlib/matplotlib/labels/Release%20critical","name":"Release critical","color":"b60205","default":false}],"milestone":{"url":"https://api.github.com/repos/matplotlib/matplotlib/milestones/32","html_url":"https://github.com/matplotlib/matplotlib/milestone/32","labels_url":"https://api.github.com/repos/matplotlib/matplotlib/milestones/32/labels","id":3106572,"number":32,"title":"v2.2.1","description":"First bugfix release for 2.2.x series.\r\n\r\non-merge: backport to v2.2.x","creator":{"login":"tacaswell","id":199813,"avatar_url":"https://avatars3.githubusercontent.com/u/199813?v=4","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":9,"closed_issues":14,"state":"open","created_at":"2018-02-12T03:21:43Z","updated_at":"2018-03-07T21:26:18Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/matplotlib/matplotlib/pulls/10710/commits","review_comments_url":"https://api.github.com/repos/matplotlib/matplotlib/pulls/10710/comments","review_comment_url":"https://api.github.com/repos/matplotlib/matplotlib/pulls/comments{/number}","comments_url":"https://api.github.com/repos/matplotlib/matplotlib/issues/10710/comments","statuses_url":"https://api.github.com/repos/matplotlib/matplotlib/statuses/ca9502eac8ca3bfacec66b74365d96481262dc1e","head":{"label":"dopplershift:fix-error","ref":"fix-error","sha":"ca9502eac8ca3bfacec66b74365d96481262dc1e","user":{"login":"dopplershift","id":221526,"avatar_url":"https://avatars2.githubusercontent.com/u/221526?v=4","gravatar_id":"","url":"https://api.github.com/users/dopplershift","html_url":"https://github.com/dopplershift","followers_url":"https://api.github.com/users/dopplershift/followers","following_url":"https://api.github.com/users/dopplershift/following{/other_user}","gists_url":"https://api.github.com/users/dopplershift/gists{/gist_id}","starred_url":"https://api.github.com/users/dopplershift/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dopplershift/subscriptions","organizations_url":"https://api.github.com/users/dopplershift/orgs","repos_url":"https://api.github.com/users/dopplershift/repos","events_url":"https://api.github.com/users/dopplershift/events{/privacy}","received_events_url":"https://api.github.com/users/dopplershift/received_events","type":"User","site_admin":false},"repo":{"id":1409412,"name":"matplotlib","full_name":"dopplershift/matplotlib","owner":{"login":"dopplershift","id":221526,"avatar_url":"https://avatars2.githubusercontent.com/u/221526?v=4","gravatar_id":"","url":"https://api.github.com/users/dopplershift","html_url":"https://github.com/dopplershift","followers_url":"https://api.github.com/users/dopplershift/followers","following_url":"https://api.github.com/users/dopplershift/following{/other_user}","gists_url":"https://api.github.com/users/dopplershift/gists{/gist_id}","starred_url":"https://api.github.com/users/dopplershift/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dopplershift/subscriptions","organizations_url":"https://api.github.com/users/dopplershift/orgs","repos_url":"https://api.github.com/users/dopplershift/repos","events_url":"https://api.github.com/users/dopplershift/events{/privacy}","received_events_url":"https://api.github.com/users/dopplershift/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/dopplershift/matplotlib","description":null,"fork":true,"url":"https://api.github.com/repos/dopplershift/matplotlib","forks_url":"https://api.github.com/repos/dopplershift/matplotlib/forks","keys_url":"https://api.github.com/repos/dopplershift/matplotlib/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dopplershift/matplotlib/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dopplershift/matplotlib/teams","hooks_url":"https://api.github.com/repos/dopplershift/matplotlib/hooks","issue_events_url":"https://api.github.com/repos/dopplershift/matplotlib/issues/events{/number}","events_url":"https://api.github.com/repos/dopplershift/matplotlib/events","assignees_url":"https://api.github.com/repos/dopplershift/matplotlib/assignees{/user}","branches_url":"https://api.github.com/repos/dopplershift/matplotlib/branches{/branch}","tags_url":"https://api.github.com/repos/dopplershift/matplotlib/tags","blobs_url":"https://api.github.com/repos/dopplershift/matplotlib/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dopplershift/matplotlib/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dopplershift/matplotlib/git/refs{/sha}","trees_url":"https://api.github.com/repos/dopplershift/matplotlib/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dopplershift/matplotlib/statuses/{sha}","languages_url":"https://api.github.com/repos/dopplershift/matplotlib/languages","stargazers_url":"https://api.github.com/repos/dopplershift/matplotlib/stargazers","contributors_url":"https://api.github.com/repos/dopplershift/matplotlib/contributors","subscribers_url":"https://api.github.com/repos/dopplershift/matplotlib/subscribers","subscription_url":"https://api.github.com/repos/dopplershift/matplotlib/subscription","commits_url":"https://api.github.com/repos/dopplershift/matplotlib/commits{/sha}","git_commits_url":"https://api.github.com/repos/dopplershift/matplotlib/git/commits{/sha}","comments_url":"https://api.github.com/repos/dopplershift/matplotlib/comments{/number}","issue_comment_url":"https://api.github.com/repos/dopplershift/matplotlib/issues/comments{/number}","contents_url":"https://api.github.com/repos/dopplershift/matplotlib/contents/{+path}","compare_url":"https://api.github.com/repos/dopplershift/matplotlib/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dopplershift/matplotlib/merges","archive_url":"https://api.github.com/repos/dopplershift/matplotlib/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dopplershift/matplotlib/downloads","issues_url":"https://api.github.com/repos/dopplershift/matplotlib/issues{/number}","pulls_url":"https://api.github.com/repos/dopplershift/matplotlib/pulls{/number}","milestones_url":"https://api.github.com/repos/dopplershift/matplotlib/milestones{/number}","notifications_url":"https://api.github.com/repos/dopplershift/matplotlib/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dopplershift/matplotlib/labels{/name}","releases_url":"https://api.github.com/repos/dopplershift/matplotlib/releases{/id}","deployments_url":"https://api.github.com/repos/dopplershift/matplotlib/deployments","created_at":"2011-02-25T02:55:48Z","updated_at":"2015-04-20T16:20:50Z","pushed_at":"2018-03-07T20:32:57Z","git_url":"git://github.com/dopplershift/matplotlib.git","ssh_url":"git@github.com:dopplershift/matplotlib.git","clone_url":"https://github.com/dopplershift/matplotlib.git","svn_url":"https://github.com/dopplershift/matplotlib","homepage":"","size":324046,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":2,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"matplotlib:master","ref":"master","sha":"d2f7bb1d5b7c9de3498741276c4dd0ef57848ba5","user":{"login":"matplotlib","id":215947,"avatar_url":"https://avatars0.githubusercontent.com/u/215947?v=4","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://avatars0.githubusercontent.com/u/215947?v=4","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}","deployments_url":"https://api.github.com/repos/matplotlib/matplotlib/deployments","created_at":"2011-02-19T03:17:12Z","updated_at":"2018-03-07T20:21:04Z","pushed_at":"2018-03-07T21:26:18Z","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":323954,"stargazers_count":6858,"watchers_count":6858,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3235,"mirror_url":null,"archived":false,"open_issues_count":1353,"license":null,"forks":3235,"open_issues":1353,"watchers":6858,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/matplotlib/matplotlib/pulls/10710"},"html":{"href":"https://github.com/matplotlib/matplotlib/pull/10710"},"issue":{"href":"https://api.github.com/repos/matplotlib/matplotlib/issues/10710"},"comments":{"href":"https://api.github.com/repos/matplotlib/matplotlib/issues/10710/comments"},"review_comments":{"href":"https://api.github.com/repos/matplotlib/matplotlib/pulls/10710/comments"},"review_comment":{"href":"https://api.github.com/repos/matplotlib/matplotlib/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/matplotlib/matplotlib/pulls/10710/commits"},"statuses":{"href":"https://api.github.com/repos/matplotlib/matplotlib/statuses/ca9502eac8ca3bfacec66b74365d96481262dc1e"}},"author_association":"CONTRIBUTOR","merged":true,"mergeable":null,"rebaseable":null,"mergeable_state":"unknown","merged_by":{"login":"jklymak","id":1562854,"avatar_url":"https://avatars0.githubusercontent.com/u/1562854?v=4","gravatar_id":"","url":"https://api.github.com/users/jklymak","html_url":"https://github.com/jklymak","followers_url":"https://api.github.com/users/jklymak/followers","following_url":"https://api.github.com/users/jklymak/following{/other_user}","gists_url":"https://api.github.com/users/jklymak/gists{/gist_id}","starred_url":"https://api.github.com/users/jklymak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jklymak/subscriptions","organizations_url":"https://api.github.com/users/jklymak/orgs","repos_url":"https://api.github.com/users/jklymak/repos","events_url":"https://api.github.com/users/jklymak/events{/privacy}","received_events_url":"https://api.github.com/users/jklymak/received_events","type":"User","site_admin":false},"comments":0,"review_comments":0,"maintainer_can_modify":false,"commits":1,"additions":1,"deletions":1,"changed_files":1}}
{"actor":{"display_login":"jklymak"}}