| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
I see that a different approach was taken to handle the change in behaviour for bar #24149. |
Sorry, something went wrong.
|
I think that this approach is quite a bit simpler than the one used in #24149. On the other hand it is a bit more explicit what happens there. My suggestions:
|
Sorry, something went wrong.
|
Thanks @oscargus your suggestions make sense to me. I’ll put this in draft until I have time to implement them. |
Sorry, something went wrong.
|
|
||
| try: | ||
| x = cbook._safe_first_finite(xconv) | ||
| except (TypeError, IndexError, KeyError): |
There was a problem hiding this comment.
I think there a few other places where StopIteration is try/excepted for _safe_first_element? Did you check all those?
Sorry, something went wrong.
There was a problem hiding this comment.
I hadn't, but I have now. I only found these two:
matplotlib/lib/matplotlib/dates.py
Lines 1828 to 1831 in 7103779
matplotlib/lib/matplotlib/units.py
Lines 182 to 185 in 7103779
These both predate the change that led to StopIteration being thrown for all-nan arrays. The commit that introduced the first says it was for zero length objects, and these will still trigger a StopIteration when the logic arrives here. I'm not sure about the second - should units.Registry.get_converter also be able to handle zero length objects?
Sorry, something went wrong.
There was a problem hiding this comment.
I don't really know - just noted that it happens a few other places, and the more logic we can move into a consistent helper function, the better in my opinion.
Sorry, something went wrong.
There was a problem hiding this comment.
the more logic we can move into a consistent helper function, the better in my opinion.
I certainly agree with that. I wonder if further consolidation should wait for a separate PR though, given recent clarifications about what should and should not be backported
Sorry, something went wrong.
…547-on-v3.7.x Backport PR #25547 on branch v3.7.x (FIX: `_safe_first_finite` on all non-finite array)
| Back | FazBrowse Home | New Git URL |
PR Summary
This function used to be named _safe_first_non_none (#23751), and at v3.6.0 we have
So this PR reinstates previous behaviour. Currently on main, _safe_first_finite raises StopIteration when passed an all-nan array.
Fixes #18294 and fixes #24818. The examples from both those issues now successfully produce empty plots. The example from #18294 no longer throws the originally reported warning, but the example from #24818 does throw
PR Checklist
Documentation and Tests
Release Notes