-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Deprecate selector visible
attribute
#22167
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
Deprecate selector visible
attribute
#22167
Conversation
b093bde
to
369ea27
Compare
It's reasonable to add
So overall, I'd recommend adding the property without deprecation for now. We can always deprecate later if we want to. |
This sounds good, but we have one issue here:
This is the main reason that I went for deprecating the
We could keep the property, but I think that we should at least break its behaviour, because it currently can lead to inconsistent state of the selector: import matplotlib.pyplot as plt
from matplotlib.widgets import RectangleSelector
fig, ax = plt.subplots()
selector = RectangleSelector(ax, lambda *args: None, interactive=True)
selector.extents = (0.4, 0.7, 0.3, 0.4)
assert selector.visible
selector.visible = False
print(f'is the selector visible? {selector.visible}')
for artist in selector.artists:
print(f'is artist {artist} visible? {artist.get_visible()}') |
Agreed. I see it this way:
|
Yes, I don't think that there other sensible options. I would prefer the second one. Option 1 can break user code: for example, when an user is changing the |
Agreed, option 2 it is then. |
369ea27
to
c54a3b3
Compare
@timhoffm, this is ready for review! |
@timhoffm I thought you were hoping to add (or at least seemed to be fine with) more properties in widgets? |
c54a3b3
to
d906c5c
Compare
Sorry for coming back on this only now. I rebased and deprecated the setter only, not the property. |
Ping @timhoffm |
34e3a77
to
f084ed2
Compare
lib/matplotlib/widgets.py
Outdated
"3.6", message="The visible setter was deprecated since %(since)s" | ||
" and will be removed in %(removal)s. Use set_visible 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.
No need to write the whole message; just set alternative="set_visible"
.
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, done!
f084ed2
to
a2540ac
Compare
PR Summary
As noticed in #22146, the use of the selector
visible
attribute is ambiguous. This PR deprecate thevisible
attribute in favour of usingset_visible
/get_visible
to be consistent with other matplotlib objects.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).