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

Skip to content

Backport PR #15925 on branch v3.2.x (Optimize setting units to None when they're already None.) #15930

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
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 6 additions & 12 deletions lib/matplotlib/axis.py
Original file line number Diff line number Diff line change
Expand Up @@ -1584,18 +1584,12 @@ def set_units(self, u):
----------
u : units tag
"""
pchanged = False
if u is None:
self.units = None
pchanged = True
else:
if u != self.units:
self.units = u
pchanged = True
if pchanged:
self._update_axisinfo()
self.callbacks.process('units')
self.callbacks.process('units finalize')
if u == self.units:
return
self.units = u
self._update_axisinfo()
self.callbacks.process('units')
self.callbacks.process('units finalize')
self.stale = True

def get_units(self):
Expand Down