Closed
Description
- Description: When using
matplotlib.pyplot.pie()
with a list that includes aNaN
, the function raises aValueError
. This crash is not currently caught or documented.
import matplotlib.pyplot as plt
import numpy as np
fig, ax = plt.subplots()
data = [10, 20, float('nan'), 40]
ax.pie(data, labels=["A", "B", "C", "D"])
plt.show()
-
Error Message
ValueError: cannot convert float NaN to integer
-
Expected Behavior -
matplotlib.pie()
should either: Filter outNaNs
, or raise a clear and user-friendlyValueError
-
Environment:
-
Python: 3.11
-
Matplotlib: 3.8.x
-
OS: Windows 10
-
Found via: Fuzz testing
-
[@tacaswell edited to fix markdown markup]