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

Skip to content

Commit 5dcab5e

Browse files
committed
If a value to convert doesn't have units, just return
1 parent 1f3699c commit 5dcab5e

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

lib/matplotlib/axis.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1498,6 +1498,10 @@ def have_units(self):
14981498
return self.converter is not None or self.units is not None
14991499

15001500
def convert_units(self, x):
1501+
# If x is already a number, doesn't need converting
1502+
if munits.ConversionInterface.is_numlike(x):
1503+
return x
1504+
15011505
if self.converter is None:
15021506
self.converter = munits.registry.get_converter(x)
15031507

lib/matplotlib/dates.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1738,8 +1738,6 @@ def convert(value, unit, axis):
17381738
17391739
The *unit* and *axis* arguments are not used.
17401740
"""
1741-
if units.ConversionInterface.is_numlike(value):
1742-
return value
17431741
return date2num(value)
17441742

17451743
@staticmethod

0 commit comments

Comments
 (0)