-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
MNT: Simplify imports #22558
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's _image
because it's a compiled extension, not necessarily to be private.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
pytest
passes).flake8-docstrings
and 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).