8000 Ensure that Path.arc works for any full circle. · matplotlib/matplotlib@5162f37 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5162f37

Browse files
committed
Ensure that Path.arc works for any full circle.
Depending on the inputs, the range may get squashed down to ~0 when trying to remove extra 2pi revolutions. Fixes #8992.
1 parent 87c668a commit 5162f37

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

lib/matplotlib/path.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -868,6 +868,10 @@ def arc(cls, theta1, theta2, n=None, is_wedge=False):
868868

869869
eta1 = theta1
870870
eta2 = theta2 - 360 * np.floor((theta2 - theta1) / 360)
871+
# Ensure 2pi range is not flattened to 0 due to floating-point errors,
872+
# but don't try to expand existing 0 range.
873+
if theta2 != theta1 and eta2 <= eta1:
874+
eta2 += 360
871875
eta1, eta2 = np.deg2rad([eta1, eta2])
872876

873877
# number of curve segments to make

lib/matplotlib/tests/test_path.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,3 +205,15 @@ def test_path_deepcopy():
205205
path2 = Path(verts, codes)
206206
copy.deepcopy(path1)
207207
copy.deepcopy(path2)
208+
209+
210+
@pytest.mark.parametrize('offset', range(-720, 361, 45))
211+
def test_full_arc(offset):
212+
low = offset
213+
high = 360 + offset
214+
215+
path = Path.arc(low, high)
216+
mins = np.min(path.vertices, axis=0)
217+
maxs = np.max(path.vertices, axis=0)
218+
np.testing.assert_allclose(mins, -1)
219+
assert np.allclose(maxs, 1)

0 commit comments

Comments
 (0)
0