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

Skip to content

Commit 6e43e72

Browse files
authored
Merge pull request #6997 from maahn/fixPandas
FIX: Only try to find unit converter for first element of sequence
2 parents a9c9012 + 2a1b1f2 commit 6e43e72

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

lib/matplotlib/units.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def default_units(x, axis):
4444
from __future__ import (absolute_import, division, print_function,
4545
unicode_literals)
4646

47-
from matplotlib.cbook import iterable, is_numlike
47+
from matplotlib.cbook import iterable, is_numlike, safe_first_element
4848
import numpy as np
4949

5050

@@ -155,14 +155,11 @@ def get_converter(self, x):
155155
converter = self.get_converter(next_item)
156156
return converter
157157

158-
if converter is None and iterable(x):
159-
for thisx in x:
160-
# Make sure that recursing might actually lead to a solution,
161-
# if we are just going to re-examine another item of the same
162-
# kind, then do not look at it.
163-
if classx and classx != getattr(thisx, '__class__', None):
164-
converter = self.get_converter(thisx)
165-
return converter
158+
if converter is None and iterable(x) and (len(x) > 0):
159+
thisx = safe_first_element(x)
160+
if classx and classx != getattr(thisx, '__class__', None):
161+
converter = self.get_converter(thisx)
162+
return converter
166163

167164
# DISABLED self._cached[idx] = converter
168165
return converter

0 commit comments

Comments
 (0)