Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit db7cd7e

Browse filesBrowse 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
Copy full SHA for db7cd7e

File tree

Expand file treeCollapse file tree

1 file changed

+6
-12
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+6
-12
lines changed

‎lib/matplotlib/axis.py

Copy file name to clipboardExpand all lines: lib/matplotlib/axis.py
+6-12Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.