Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

[Bug]: Cannot create empty FancyArrow (expired numpy deprecation) #30242

Closed
Milestone
@ap2468

Description

@ap2468

Bug summary

Creating an empty FancyArrow throws an exception:

>>> import matplotlib.pyplot as plt>>> plt.arrow([], [], [], [])matplotlib/axes/_axes.py", line 5509, in arrow    a = mpatches.FancyArrow(x, y, dx, dy, **kwargs)matplotlib/patches.py", line 1459, in __init__    self._make_verts()matplotlib/patches.py", line 1518, in _make_verts    if not length:           ^^^^^^ValueError: The truth value of an empty array is ambiguous. Use `array.size > 0` to check that an array is not empty.

That exception used to throw a numpy deprecation warning, but that deprecationhas recently expired and now throws an exception.

That section appears to intend to properly handle zero-length input (matplotlib/patches.py", line 1518),

ifnotlength:self.verts=np.empty([0,2])# display nothing if empty

The fix appears to be to change theif not length toif length.size == 0.

Code for reproduction

importmatplotlib.pyplotaspltplt.arrow([], [], [], [])

Actual outcome

matplotlib/axes/_axes.py", line 5509, in arrow    a = mpatches.FancyArrow(x, y, dx, dy, **kwargs)matplotlib/patches.py", line 1459, in __init__    self._make_verts()matplotlib/patches.py", line 1518, in _make_verts    if not length:           ^^^^^^ValueError: The truth value of an empty array is ambiguous. Use `array.size > 0` to check that an array is not empty.

Expected outcome

Return a validFancyArrow

Additional information

python version 3.12
matplotlib version: 3.10.3 (latest release)
numpy version: 2.2.6 (deprecation above expired in 2.2.0, released Dec 2024)

Operating system

No response

Matplotlib Version

3.10.3

Matplotlib Backend

No response

Python version

3.12.8

Jupyter version

No response

Installation

pip

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp