8000 FIX: do not try to interpolate empty paths · matplotlib/matplotlib@f24001a · GitHub
[go: up one dir, main page]

Skip to content

Commit f24001a

Browse files
committed
FIX: do not try to interpolate empty paths
1 parent 4c43570 commit f24001a

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

lib/matplotlib/path.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,7 @@ def interpolated(self, steps):
681681
Path
682682
The interpolated path.
683683
"""
684-
if steps == 1:
684+
if steps == 1 or len(self) == 0:
685685
return self
686686

687687
if self.codes is not None and self.MOVETO in self.codes[1:]:

lib/matplotlib/tests/test_path.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -617,3 +617,8 @@ def test_interpolated_moveto_closepoly():
617617

618618
np.testing.assert_allclose(result.vertices, expected_vertices)
619619
np.testing.assert_array_equal(result.codes, expected_codes)
620+
621+
622+
def test_interpolated_empty_path():
623+
path = Path(np.zeros((0, 2)))
624+
assert path.interpolated(42) is path

0 commit comments

Comments
 (0)
0