8000 Don't crash on str(figimage(...)). · matplotlib/matplotlib@014c02b · GitHub
[go: up one dir, main page]

Skip to content

Commit 014c02b

Browse files
committed
Don't crash on str(figimage(...)).
`im = figimage(np.random.rand(100, 100), xo=100, yo=100); print(im)` Previously: ``` Traceback (most recent call last): File "<string>", line 4, in <module> File "/usr/lib/python3.7/site-packages/matplotlib/image.py", line 184, in __str__ return "AxesImage(%g,%g;%gx%g)" % tuple(self.axes.bbox.bounds) AttributeError: 'NoneType' object has no attribute 'bbox' ``` now: ``` <matplotlib.image.FigureImage object at 0x7fa97be63860> ``` Note that `AxesImage` actually already has the same `__str__` defined in its own body (which this PR leaves untouched). Defining a proper `__str__` for `FigureImage` (and other `_ImageBase` subclasses) is not the object of this PR.
1 parent dd18211 commit 014c02b

File tree

1 file changed

+0
-3
lines changed

1 file changed

+0
-3
lines changed

lib/matplotlib/image.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,6 @@ def _rgb_to_rgba(A):
177177
class _ImageBase(martist.Artist, cm.ScalarMappable):
178178
zorder = 0
179179

180-
def __str__(self):
181-
return "AxesImage(%g,%g;%gx%g)" % tuple(self.axes.bbox.bounds)
182-
183180
def __init__(self, ax,
184181
cmap=None,
185182
norm=None,

0 commit comments

Comments
 (0)
0