We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The function ax.errorbar raises a StopIteration error when yerr contains only NaN values.
ax.errorbar
StopIteration
yerr
NaN
import matplotlib.pyplot as plt import numpy as np fig, ax = plt.subplots(1, 1) ax.errorbar([0], [0], [np.nan])
Traceback (most recent call last): File "<stdin>", line 1, in <module> File "~/.local/share/virtualenvs/pipeline/lib/python3.9/site-packages/matplotlib/__init__.py", line 1423, in inner return func(ax, *map(sanitize_sequence, args), **kwargs) File "~.local/share/virtualenvs/pipeline/lib/python3.9/site-packages/matplotlib/axes/_axes.py", line 3488, in errorbar yerr = _upcast_err(yerr) File "~/.local/share/virtualenvs/pipeline/lib/python3.9/site-packages/matplotlib/axes/_axes.py", line 3470, in _upcast_err isinstance(cbook._safe_first_finite(err), np.ndarray) File "~/.local/share/virtualenvs/pipeline/lib/python3.9/site-packages/matplotlib/cbook/__init__.py", line 1749, in _safe_first_finite return next(val for val in obj if safe_isfinite(val)) StopIteration
No crash, similar to the case where only some values are NaN.
This happens because _upcast_err unconditionally looks for a first finite element in xerr and yerr.
_upcast_err
xerr
Debian
3.6.2
TkAgg
3.9.2
No response
pip
The text was updated successfully, but these errors were encountered:
Possible duplicate of #18294.
Sorry, something went wrong.
_safe_first_finite
Successfully merging a pull request may close this issue.
Bug summary
The function
ax.errorbar
raises aStopIteration
error whenyerr
contains onlyNaN
values.Code for reproduction
Actual outcome
Expected outcome
No crash, similar to the case where only some values are NaN.
Additional information
This happens because
_upcast_err
unconditionally looks for a first finite element inxerr
andyerr
.Operating system
Debian
Matplotlib Version
3.6.2
Matplotlib Backend
TkAgg
Python version
3.9.2
Jupyter version
No response
Installation
pip
The text was updated successfully, but these errors were encountered: