Skip to content

Commit e9ed519

Browse files
committed
Address review: extract is_full_circle and clarify arc snap comment
1 parent bd946aa commit e9ed519

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

lib/matplotlib/path.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -995,15 +995,15 @@ def arc(cls, theta1, theta2, n=None, is_wedge=False):
995995
eta1 = theta1
996996
n_turns = (theta2 - theta1) / 360
997997
nearest_turn = np.rint(n_turns)
998-
# If the span is within floating-point tolerance of a non-zero whole
999-
# number of turns, draw a complete circle; otherwise unwrap *theta2*
1000-
# to the shortest arc within 360 degrees. Without the snap, a span of
1001-
# 360*n plus a tiny rounding error is reduced modulo 360 to a
1002-
# near-empty arc (the polar gridline/spine collapse). The error from
1003-
# the polar transform pipeline is at the machine-epsilon level (under
1004-
# 1e-15 turns in practice), so this tolerance reliably snaps genuine
1005-
# full turns while leaving any intentionally non-integer span alone.
1006-
if nearest_turn != 0 and abs(n_turns - nearest_turn) <= 1e-12:
998+
is_full_circle = nearest_turn != 0 and abs(n_turns - nearest_turn) <= 1e-12
999+
# We unwrap *theta2* to the shortest arc within 360 degrees.
1000+
# Full circles need special handling as floating point errors can
1001+
# make a full circle have 360° + eps, which would be unwrapped
1002+
# to eps only, i.e. collapsing the full circle to an infinitesimal arc.
1003+
# The threshold of 1e-12 is a defensive choice: Much larger than
1004+
# numeric precision errors (~1e-15) but still smaller than any
1005+
# expected real-world arcs.
1006+
if is_full_circle:
10071007
eta2 = theta1 + 360
10081008
else:
10091009
eta2 = theta2 - 360 * np.floor(n_turns)

0 commit comments

Comments
 (0)