BUG:datetime list starting with none
PR Summary
#23580
- cbook/init.py
- modified safe_first_element() to obtain the first non-None element
- test_cbook.py
- added a test for safe_first_element()
PR Checklist
Tests and Styling
- [x] Has pytest style unit tests (and
pytestpasses). - [x] Is Flake 8 compliant (install
flake8-docstringsand runflake8 --docstring-convention=all).
Documentation
- [ N/A] New features are documented, with examples if plot related.
- [ N/A] New features have an entry in
doc/users/next_whats_new/(follow instructions in README.rst there). - [ N/A] API changes documented in
doc/api/next_api_changes/(follow instructions in README.rst there). - [ N/A] Documentation is sphinx and numpydoc compliant (the docs should build without error).
@MikiPWata Do you feel comfortable squashing this to one commit?
@MikiPWata Do you feel comfortable squashing this to one commit?
yes! I will squash them into 1 commit
Thank you, this is now waiting for a second reviewer to merge.
Please squash to one commit again.
Doing this as
return next(val for val in obj if not (skip_none and val is None)) # I _think_ this logic is correct
might be a bit more elegant.
not sure why many pytests are failing....
Test failures are likely unrelated https://gitter.im/matplotlib/matplotlib?at=62f2d60b9d3c186299235d4e
And with the suggested changes we need to find all our usage of safe_first_element and replace with _safe_first_non_none.
This way we (internally) always use the new behavior, if anyone is using this method for their own reasons they keep the same old behavior, and we only have one copy of the logic!
I think these test failures are real and caused by the changes in this PR.
And with the suggested changes we need to find all our usage of
safe_first_elementand replace with_safe_first_non_none.This way we (internally) always use the new behavior, if anyone is using this method for their own reasons they keep the same old behavior, and we only have one copy of the logic!
I have also changed all safe_first_element() in test files to _safe_first_none().
Thanks @MikiPWata!