You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: boxplot_stats raises IndexError when all values are masked #32508
The code raises an IndexError when all elements of the masked array are masked.
Example error with NumPy 2.x:
IndexError: index -1 is out of bounds for axis 0 with size 0
The exact error message may vary depending on the NumPy version.
Expected outcome
The function should handle an array with all values masked gracefully, without raising an exception. It should return appropriate statistics for the empty data remaining after masked values are excluded, consistent with the function's existing empty-data behavior.
Confirmed, the exception came in at f8b3b27, though before that the mask was just ignored so you got spurious statistics. Looks like we just need to move the lines that get the unmasked values above the line that checks for zero-length input.
Thanks for confirming the issue and identifying the likely cause! I'd like to work on the fix and add a regression test for the all-masked input case. Could you please assign this issue to me? I'd also like to confirm that I'm welcome to submit a PR for this fix.
Activity
lucaznch commentedon Oct 20, 2026
Thanks for the report. I'm new to git bisect but assuming I used it correctly it points to f8b3b27
rcomer commentedon Oct 20, 2026
Confirmed, the exception came in at f8b3b27, though before that the mask was just ignored so you got spurious statistics. Looks like we just need to move the lines that get the unmasked values above the line that checks for zero-length input.
mansi-tomar-sudo commentedon Oct 20, 2026
Thanks for confirming the issue and identifying the likely cause! I'd like to work on the fix and add a regression test for the all-masked input case. Could you please assign this issue to me? I'd also like to confirm that I'm welcome to submit a PR for this fix.
rcomer commentedon Oct 20, 2026
@mansi-tomar-sudo you are welcome to submit a pull request for any issue, but we do not assign them. Please see our contributors’ guide:
https://matplotlib.org/devdocs/devel/index.html