Skip to content

Commit 66647b0

Browse files
committed
Merge pull request matplotlib#2591 from dopplershift/fix-infinite-recursion
Fix infinite recursion in units with ndarray subclasses.
1 parent c8a26aa commit 66647b0

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/matplotlib/units.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,13 @@ def get_converter(self, x):
145145
return converter
146146
except AttributeError:
147147
# not a masked_array
148-
converter = self.get_converter(xravel[0])
148+
# Make sure we don't recurse forever -- it's possible for
149+
# ndarray subclasses to continue to return subclasses and
150+
# not ever return a non-subclass for a single element.
151+
next_item = xravel[0]
152+
if (not isinstance(next_item, np.ndarray) or
153+
next_item.shape != x.shape):
154+
converter = self.get_converter(next_item)
149155
return converter
150156

151157
if converter is None and iterable(x):

0 commit comments

Comments
 (0)