Skip to content

Fix: Axes.bar StopIteration on all-NaN x (regression) — swev-id: matplotlib__matplotlib-24149#39

Open
casey-brooks wants to merge 1 commit intomatplotlib__matplotlib-24149from
fix/bar-all-nan-stopiteration
Open

Fix: Axes.bar StopIteration on all-NaN x (regression) — swev-id: matplotlib__matplotlib-24149#39
casey-brooks wants to merge 1 commit intomatplotlib__matplotlib-24149from
fix/bar-all-nan-stopiteration

Conversation

@casey-brooks
Copy link

Summary

  • fall back to safe_first_element when _safe_first_finite raises StopIteration in Axes._convert_dx
  • add regression coverage for NaN-only bar inputs

Testing

Resolves #34

@casey-brooks
Copy link
Author

Test & Lint Summary

  • PYTEST_ADDOPTS='-W default::DeprecationWarning' MPLBACKEND=Agg LD_LIBRARY_PATH=/root/.nix-profile/lib:/nix/store/qipd93x9gjyiygqk673rd2ssnf8y7jj0-gcc-14.3.0-lib/lib:/nix/store/f8w1i7yisixb9hivzbk0l4ixmf67fjqr-gcc-14.3.0-libgcc/lib: .venv/bin/pytest -q lib/matplotlib/tests/test_axes.py::test_bar_all_nan_x_and_height_no_stopiteration (passed, 1 warning)
  • PYTEST_ADDOPTS='-W default::DeprecationWarning' MPLBACKEND=Agg LD_LIBRARY_PATH=/root/.nix-profile/lib:/nix/store/qipd93x9gjyiygqk673rd2ssnf8y7jj0-gcc-14.3.0-lib/lib:/nix/store/f8w1i7yisixb9hivzbk0l4ixmf67fjqr-gcc-14.3.0-libgcc/lib: .venv/bin/pytest -q lib/matplotlib/tests/test_axes.py::test_bar_nan_x_zero_height_no_stopiteration (passed, 1 warning)
  • PYTEST_ADDOPTS='-W default::DeprecationWarning' MPLBACKEND=Agg LD_LIBRARY_PATH=/root/.nix-profile/lib:/nix/store/qipd93x9gjyiygqk673rd2ssnf8y7jj0-gcc-14.3.0-lib/lib:/nix/store/f8w1i7yisixb9hivzbk0l4ixmf67fjqr-gcc-14.3.0-libgcc/lib: .venv/bin/pytest -q lib/matplotlib/tests/test_axes.py::test_bar_zero_x_nan_height_baseline_ok (passed, 1 warning)
  • .venv/bin/flake8 lib/matplotlib/axes/_axes.py (passed)
  • .venv/bin/flake8 lib/matplotlib/tests/test_axes.py --extend-ignore=E721 (passed)

@rowan-stein rowan-stein changed the title [Task 268] Handle StopIteration for NaN bar widths Fix: Axes.bar StopIteration on all-NaN x (regression) — swev-id: matplotlib__matplotlib-24149 Dec 25, 2025
@rowan-stein rowan-stein changed the base branch from main to matplotlib__matplotlib-24149 December 25, 2025 09:39
@rowan-stein rowan-stein requested a review from a team December 25, 2025 09:39
Copy link

@noa-lucent noa-lucent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: ax.bar raises for all-nan data on matplotlib 3.6.1 — Task 268 — matplotlib__matplotlib-24149

2 participants