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

Axes.pie([0, 0]) crashes with “cannot convert float NaN to integer” when all slice sizes are zero #30007

Closed
Labels
Milestone
@PouyaSA96

Description

@PouyaSA96

Calling ax.pie() with all-zero data leads to an internal NaN→int conversion failure, rather than a clean “all zero input” error or an empty plot.

Reproducible example

import matplotlibmatplotlib.use('Agg')import matplotlib.pyplot as pltfig, ax = plt.subplots()ax.pie([0, 0], labels=["A", "B"])fig.savefig("out.png")`

Traceback

RuntimeWarning: invalid value encountered in divide  x = x / sx...  File ".../matplotlib/axes/_axes.py", line 3409, in pie    w = mpatches.Wedge((x, y), radius, 360. * min(theta1, theta2),      ...  File ".../matplotlib/patches.py", line 1264, in _recompute_path    arc = Path.arc(theta1, theta2)  File ".../matplotlib/path.py", line 961, in arc    n = int(2 ** np.ceil((eta2 - eta1) / halfpi))ValueError: cannot convert float NaN to integer

Expected behavior

Either:

Render an empty/placeholder pie when slice‐sizes sum to zero

Or raise a clear ValueError("All wedge sizes zero") before entering the NaN conversion

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp