From 6598fad45e9aa0e181f25d039e1087573679b360 Mon Sep 17 00:00:00 2001 From: James Evans Date: Wed, 12 Aug 2015 11:30:18 -0700 Subject: [PATCH 1/2] Fixed a divide by zero error that happens if there is no space for both an arrow and a line. --- lib/matplotlib/patches.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/matplotlib/patches.py b/lib/matplotlib/patches.py index b3ff25658c78..b664d2444279 100644 --- a/lib/matplotlib/patches.py +++ b/lib/matplotlib/patches.py @@ -3308,7 +3308,9 @@ def transmute(self, path, mutation_size, linewidth): x0, y0 = path.vertices[0] x1, y1 = path.vertices[1] - if self.beginarrow: + # If there is no room for an arrow and a line, then skip the arrow + hasBeginArrow = self.beginArrow and not ((x0==x1) and (y0==y1)) + if hasBeginArrow: verticesA, codesA, ddxA, ddyA = \ self._get_arrow_wedge(x1, y1, x0, y0, head_dist, cos_t, sin_t, @@ -3321,7 +3323,9 @@ def transmute(self, path, mutation_size, linewidth): x2, y2 = path.vertices[-2] x3, y3 = path.vertices[-1] - if self.endarrow: + # If there is no room for an arrow and a line, then skip the arrow + hasEndArrow = self.endArrow and not ((x2==x3) and (y2==y3)) + if hasEndArrow: verticesB, codesB, ddxB, ddyB = \ self._get_arrow_wedge(x2, y2, x3, y3, head_dist, cos_t, sin_t, @@ -3338,7 +3342,7 @@ def transmute(self, path, mutation_size, linewidth): path.codes)] _fillable = [False] - if self.beginarrow: + if hasBeginArrow: if self.fillbegin: p = np.concatenate([verticesA, [verticesA[0], verticesA[0]], ]) @@ -3349,7 +3353,7 @@ def transmute(self, path, mutation_size, linewidth): _path.append(Path(verticesA, codesA)) _fillable.append(False) - if self.endarrow: + if hasEndArrow: if self.fillend: _fillable.append(True) p = np.concatenate([verticesB, [verticesB[0], From b89a2efadb3b0f8eb7cf3d4f9372b72348cc587f Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Thu, 13 Aug 2015 21:48:15 -0400 Subject: [PATCH 2/2] MNT: fix typos --- lib/matplotlib/patches.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/matplotlib/patches.py b/lib/matplotlib/patches.py index b664d2444279..c25a2bf8fb7f 100644 --- a/lib/matplotlib/patches.py +++ b/lib/matplotlib/patches.py @@ -3309,8 +3309,9 @@ def transmute(self, path, mutation_size, linewidth): x1, y1 = path.vertices[1] # If there is no room for an arrow and a line, then skip the arrow - hasBeginArrow = self.beginArrow and not ((x0==x1) and (y0==y1)) - if hasBeginArrow: + has_begin_arrow = (self.beginarrow and + not ((x0 == x1) and (y0 == y1))) + if has_begin_arrow: verticesA, codesA, ddxA, ddyA = \ self._get_arrow_wedge(x1, y1, x0, y0, head_dist, cos_t, sin_t, @@ -3324,8 +3325,8 @@ def transmute(self, path, mutation_size, linewidth): x3, y3 = path.vertices[-1] # If there is no room for an arrow and a line, then skip the arrow - hasEndArrow = self.endArrow and not ((x2==x3) and (y2==y3)) - if hasEndArrow: + has_end_arrow = (self.endarrow and not ((x2 == x3) and (y2 == y3))) + if has_end_arrow: verticesB, codesB, ddxB, ddyB = \ self._get_arrow_wedge(x2, y2, x3, y3, head_dist, cos_t, sin_t, @@ -3342,7 +3343,7 @@ def transmute(self, path, mutation_size, linewidth): path.codes)] _fillable = [False] - if hasBeginArrow: + if has_begin_arrow: if self.fillbegin: p = np.concatenate([verticesA, [verticesA[0], verticesA[0]], ]) @@ -3353,7 +3354,7 @@ def transmute(self, path, mutation_size, linewidth): _path.append(Path(verticesA, codesA)) _fillable.append(False) - if hasEndArrow: + if has_end_arrow: if self.fillend: _fillable.append(True) p = np.concatenate([verticesB, [verticesB[0],