Thanks to visit codestin.com
Credit goes to github.com

Skip to content

FIX: Only send one update signal when autoscaling norms #25079

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

Merged
merged 1 commit into from
Jan 25, 2023

Conversation

greglucas
Copy link
Contributor

PR Summary

Signal are sent for every vmin/vmax update, when autoscaling we were changing vmin/vmax to None, then updating them which would cause 4 update signals to be sent. We really don't care about the intermediate signals and only want a single one sent after all the updates are complete.

closes #25077

NOTE: The colorbar says "if not norm.scaled(): set vmin/vmax to 0, 1" which doesn't work for the LogNorm scales. Perhaps we should also change that arbitrary 0, 1 expansion. But, this at least makes sure we don't go through the vmin=None path here while we are actively updating the norm.

PR Checklist

Documentation and Tests

  • Has pytest style unit tests (and pytest passes)
  • [-] Documentation is sphinx and numpydoc compliant (the docs should build without error).
  • [-] New plotting related features are documented with examples.

Release Notes

  • [-] New features are marked with a .. versionadded:: directive in the docstring and documented in doc/users/next_whats_new/
  • [-] API changes are marked with a .. versionchanged:: directive in the docstring and documented in doc/api/next_api_changes/
  • [-] Release notes conform with instructions in next_whats_new/README.rst or next_api_changes/README.rst

Signal are sent for every vmin/vmax update, when autoscaling we were
changing vmin/vmax to None, then updating them which would cause 4
update signals to be sent. We really don't care about the intermediate
signals and only want a single one sent after all the udpates are complete.
Comment on lines +1365 to +1369
with self.callbacks.blocked():
# Pause callbacks while we are updating so we only get
# a single update signal at the end
self.vmin = self.vmax = None
self.autoscale_None(A)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe just?

Suggested change
with self.callbacks.blocked():
# Pause callbacks while we are updating so we only get
# a single update signal at the end
self.vmin = self.vmax = None
self.autoscale_None(A)
if A.size():
self.vmin = A.min()
self.vmax = A.max()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

subclasses overwrite autoscale_None() to handle that themselves, so I think we need to defer to their implementations. I'd save that for another PR if someone wants to tackle it.

@jklymak
Copy link
Member

jklymak commented Jan 25, 2023

I'm still a little grumpy about norm.vmin = None triggering a callback - it is certainly a case where I think an explicit setter is more clear than properties because you think to look for what set_vmin does rather than just expect it to assign a value, not also do a bunch of other things... But, this fix should go in ASAP, either my suggestion or the original is fine.

@ksunden ksunden merged commit 4f24e3c into matplotlib:main Jan 25, 2023
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull request Jan 25, 2023
QuLogic added a commit that referenced this pull request Jan 25, 2023
…079-on-v3.7.x

Backport PR #25079 on branch v3.7.x (FIX: Only send one update signal when autoscaling norms)
@greglucas greglucas deleted the norm-autoscale-signal branch January 31, 2023 17:32
@ksunden ksunden mentioned this pull request Feb 20, 2023
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Setting norm with existing colorbar fails with 3.6.3
3 participants