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

Skip to content

Commit db7cd7e

Browse files
authored
Merge pull request #15925 from anntzer/units
Optimize setting units to None when they're already None.
2 parents bb64740 + 2990fd3 commit db7cd7e

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

lib/matplotlib/axis.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1508,18 +1508,12 @@ def set_units(self, u):
15081508
----------
15091509
u : units tag
15101510
"""
1511-
pchanged = False
1512-
if u is None:
1513-
self.units = None
1514-
pchanged = True
1515-
else:
1516-
if u != self.units:
1517-
self.units = u
1518-
pchanged = True
1519-
if pchanged:
1520-
self._update_axisinfo()
1521-
self.callbacks.process('units')
1522-
self.callbacks.process('units finalize')
1511+
if u == self.units:
1512+
return
1513+
self.units = u
1514+
self._update_axisinfo()
1515+
self.callbacks.process('units')
1516+
self.callbacks.process('units finalize')
15231517
self.stale = True
15241518

15251519
def get_units(self):

0 commit comments

Comments
 (0)