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 2990fd3

Browse filesBrowse files
committed
Optimize setting units to None when they're already None.
Previously, we skipped the axis update when replacing a non-None unit by the same unit, but (needlessly) not when replacing None by itself. Also the newer implementation is simpler.
1 parent c221853 commit 2990fd3
Copy full SHA for 2990fd3

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.