diff --git a/lib/matplotlib/path.py b/lib/matplotlib/path.py index 93165dc684dc..7db416408e11 100644 --- a/lib/matplotlib/path.py +++ b/lib/matplotlib/path.py @@ -325,11 +325,13 @@ def make_compound_path_from_polys(cls, XY): @classmethod def make_compound_path(cls, *args): - """Make a compound path from a list of Path objects.""" + """ + Make a compound path from a list of Path objects. Blindly removes all + Path.STOP control points. + """ # Handle an empty list in args (i.e. no args). if not args: return Path(np.empty([0, 2], dtype=np.float32)) - vertices = np.concatenate([x.vertices for x in args]) codes = np.empty(len(vertices), dtype=cls.code_type) i = 0 @@ -340,6 +342,10 @@ def make_compound_path(cls, *args): else: codes[i:i + len(path.codes)] = path.codes i += len(path.vertices) + # remove STOP's, since internal STOPs are a bug + not_stop_mask = codes != cls.STOP + vertices = vertices[not_stop_mask, :] + codes = codes[not_stop_mask] return cls(vertices, codes) diff --git a/lib/matplotlib/tests/test_path.py b/lib/matplotlib/tests/test_path.py index 4435b2337bef..b61a92654dc3 100644 --- a/lib/matplotlib/tests/test_path.py +++ b/lib/matplotlib/tests/test_path.py @@ -147,6 +147,15 @@ def test_make_compound_path_empty(): assert r.vertices.shape == (0, 2) +def test_make_compound_path_stops(): + zero = [0, 0] + paths = 3*[Path([zero, zero], [Path.MOVETO, Path.STOP])] + compound_path = Path.make_compound_path(*paths) + # the choice to not preserve the terminal STOP is arbitrary, but + # documented, so we test that it is in fact respected here + assert np.sum(compound_path.codes == Path.STOP) == 0 + + @image_comparison(['xkcd.png'], remove_text=True) def test_xkcd(): np.random.seed(0)
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: