Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7b65f39

Browse filesBrowse files
anntzermeeseeksmachine
authored andcommitted
Backport PR #16682: Avoid floating point rounding causing bezier.get_parallels to fail
1 parent 71a13b0 commit 7b65f39
Copy full SHA for 7b65f39

File tree

Expand file treeCollapse file tree

1 file changed

+11
-11
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+11
-11
lines changed

‎lib/matplotlib/bezier.py

Copy file name to clipboardExpand all lines: lib/matplotlib/bezier.py
+11-11Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -429,23 +429,23 @@ def get_parallels(bezier2, width):
429429
# find cm_left which is the intersecting point of a line through
430430
# c1_left with angle t1 and a line through c2_left with angle
431431
# t2. Same with cm_right.
432-
if parallel_test != 0:
433-
# a special case for a straight line, i.e., angle between two
434-
# lines are smaller than some (arbitrary) value.
435-
cmx_left, cmy_left = (
436-
0.5 * (c1x_left + c2x_left), 0.5 * (c1y_left + c2y_left)
437-
)
438-
cmx_right, cmy_right = (
439-
0.5 * (c1x_right + c2x_right), 0.5 * (c1y_right + c2y_right)
440-
)
441-
else:
432+
try:
442433
cmx_left, cmy_left = get_intersection(c1x_left, c1y_left, cos_t1,
443434
sin_t1, c2x_left, c2y_left,
444435
cos_t2, sin_t2)
445-
446436
cmx_right, cmy_right = get_intersection(c1x_right, c1y_right, cos_t1,
447437
sin_t1, c2x_right, c2y_right,
448438
cos_t2, sin_t2)
439+
except ValueError:
440+
# Special case straight lines, i.e., angle between two lines is
441+
# less than the threshold used by get_intersection (we don't use
442+
# check_if_parallel as the threshold is not the same).
443+
cmx_left, cmy_left = (
444+
0.5 * (c1x_left + c2x_left), 0.5 * (c1y_left + c2y_left)
445+
)
446+
cmx_right, cmy_right = (
447+
0.5 * (c1x_right + c2x_right), 0.5 * (c1y_right + c2y_right)
448+
)
449449

450450
# the parallel Bezier lines are created with control points of
451451
# [c1_left, cm_left, c2_left] and [c1_right, cm_right, c2_right]

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.