8000 Crash on zero-length FancyArrow · Issue #11217 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content
Crash on zero-length FancyArrow #11217
Closed
@anntzer

Description

@anntzer

Bug report

Bug summary

FancyArrow seemingly has code to specifically handle the case of a zero-sized arrow...

        if not length:
            verts = []  # display nothing if empty

but that code still causes a crash a bit later.

Code for reproduction

In [1]: matplotlib.patches.FancyArrow(1, 1, 0, 0, head_length=0)

Actual outcome

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-1-1e51c08a2311> in <module>()
----> 1 matplotlib.patches.FancyArrow(1, 1, 0, 0, head_length=0)

/usr/lib/python3.6/site-packages/matplotlib/patches.py in __init__(self, x, y, dx, dy, width, length_includes_head, head_width, head_length, shape, overhang, head_starts_at_zero, **kwargs)
   1295             verts = np.dot(coords, M) + (x + dx, y + dy)
   1296 
-> 1297         Polygon.__init__(self, list(map(tuple, verts)), closed=True, **kwargs)
   1298 
   1299 

/usr/lib/python3.6/site-packages/matplotlib/patches.py in __init__(self, xy, closed, **kwargs)
    958         Patch.__init__(self, **kwargs)
    959         self._closed = closed
--> 960         self.set_xy(xy)
    961 
    962     def get_path(self):

/usr/lib/python3.6/site-packages/matplotlib/patches.py in set_xy(self, xy)
   1027             if len(xy) > 2 and (xy[0] == xy[-1]).all():
   1028                 xy = xy[:-1]
-> 1029         self._path = Path(xy, closed=self._closed)
   1030         self.stale = True
   1031 

/usr/lib/python3.6/site-packages/matplotlib/path.py in __init__(self, vertices, codes, _interpolation_steps, closed, readonly)
    133         if (vertices.ndim != 2) or (vertices.shape[1] != 2):
    134             raise ValueError(
--> 135                 "'vertices' must be a 2D list or array with shape Nx2")
    136 
    137         if codes is not None:

ValueError: 'vertices' must be a 2D list or array with shape Nx2

Expected outcome

Either no crash, or at least remove the code that tries to handle zero-sized input but fails to do that :-)

Matplotlib version

  • Matplotlib version: 2.2/master

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0