Repository navigation
MNT: Simplify imports - #22558
MNT: Simplify imports#22558
Conversation
74f9fd8 to
1eea8a8
Compare
1eea8a8 to
2652cc0
Compare
| # For clarity, names from _image are given explicitly in this module | ||
| from matplotlib import _image | ||
| # For user convenience, the names from _image are also imported into | ||
| # the image namespace |
There was a problem hiding this comment.
One can actually question this comment. At least, assuming that the whole idea of putting things into _image was to make these functions and classes "private".
There was a problem hiding this comment.
It's _image because it's a compiled extension, not necessarily to be private.
There was a problem hiding this comment.
_image contains C code (see image_wrapper.cpp). It's a standard but arguably confusing convention to use a leading underscore for C parts of of a python module.
OTOH it's questionable whether we need these wildcard imports. It's just the function resample() plus a number of constants. We don't uses these in image.py (only via the qualified _image.*). Users could use resample(), but it's rather low-level. The only use for the constants is as parameters to resample. The high-level image interface uses string versions of the constants instead.
There was a problem hiding this comment.
Thanks for the clarification!
I double-checked that nothing is imported from _image through image in the code base and unless I failed or there were some missing dependency not triggering the code, it should at least be OK from that perspective.
But probably safest to keep it as is for now.
PR Summary
is typically better (shorter) written as
Note that some of the existing ones are changed in #22148 so these should be (most) of the remaining ones.
PR Checklist
Tests and Styling
pytestpasses).flake8-docstringsand runflake8 --docstring-convention=all).Documentation
doc/users/next_whats_new/(follow instructions in README.rst there).doc/api/next_api_changes/(follow instructions in README.rst there).