diff --git a/lib/matplotlib/bezier.py b/lib/matplotlib/bezier.py index f310f287e2c0..069e20d05916 100644 --- a/lib/matplotlib/bezier.py +++ b/lib/matplotlib/bezier.py @@ -171,9 +171,17 @@ def find_bezier_t_intersecting_with_closedpath( if start_inside ^ middle_inside: t1 = middle_t + if end == middle: + # Edge case where infinite loop is possible + # Caused by large numbers relative to tolerance + return t0, t1 end = middle else: t0 = middle_t + if start == middle: + # Edge case where infinite loop is possible + # Caused by large numbers relative to tolerance + return t0, t1 start = middle start_inside = middle_inside diff --git a/lib/matplotlib/tests/test_bezier.py b/lib/matplotlib/tests/test_bezier.py new file mode 100644 index 000000000000..65e2c616e738 --- /dev/null +++ b/lib/matplotlib/tests/test_bezier.py @@ -0,0 +1,17 @@ +""" +Tests specific to the bezier module. +""" + +from matplotlib.bezier import inside_circle, split_bezier_intersecting_with_closedpath + + +def test_split_bezier_with_large_values(): + # These numbers come from gh-27753 + arrow_path = [(96950809781500.0, 804.7503795623779), + (96950809781500.0, 859.6242585800646), + (96950809781500.0, 914.4981375977513)] + in_f = inside_circle(96950809781500.0, 804.7503795623779, 0.06) + split_bezier_intersecting_with_closedpath(arrow_path, in_f) + # All we are testing is that this completes + # The failure case is an infinite loop resulting from floating point precision + # pytest will timeout if that occurs pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy