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 cee4ba9

Browse filesBrowse files
committed
Fix infinite recursion in units with ndarray subclasses.
This was partially addressed for masked arrays in #2290. However, this does not work for all ndarray sub-classes, like the quantities package. The fix here is to make sure ravel is actually succeeding in changing the shape of the object. If it doesn't just return what we've got.
1 parent c91589c commit cee4ba9
Copy full SHA for cee4ba9

File tree

Expand file treeCollapse file tree

1 file changed

+7
-1
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+7
-1
lines changed

‎lib/matplotlib/units.py

Copy file name to clipboardExpand all lines: lib/matplotlib/units.py
+7-1Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.