Skip to content

Commit 21fd7c0

Browse files
committed
Merge pull request #2591 from dopplershift/fix-infinite-recursion
Fix infinite recursion in units with ndarray subclasses.
2 parents a247d93 + cee4ba9 commit 21fd7c0

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
@@ -149,7 +149,13 @@ def get_converter(self, x):
149149
return converter
150150
except AttributeError:
151151
# not a masked_array
152-
converter = self.get_converter(xravel[0])
152+
# Make sure we don't recurse forever -- it's possible for
153+
# ndarray subclasses to continue to return subclasses and
154+
# not ever return a non-subclass for a single element.
155+
next_item = xravel[0]
156+
if (not isinstance(next_item, np.ndarray) or
157+
next_item.shape != x.shape):
158+
converter = self.get_converter(next_item)
153159
return converter
154160

155161
if converter is None and iterable(x):

0 commit comments

Comments
 (0)