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

Skip to content

Commit 22b614b

Browse files
committed
Fix invalid checks for axes_class parameter in ImageGrid.
The validation of the axes_class parameter in the Grid and ImageGrid class have been wrong ever since they were merged in in f44235e (relevant followup commits: 7482fdc, a5e67b9). - In Grid, self._defaultAxesClass has never been a class with its own .Axes attribute, so the subclass check would fail with an AttributeError. - In ImageGrid, the `isinstance(axes_class, Axes)` check should be `issubclass(...)` instead. (The code later calls `axes_class(...)` to build an axes instance so if one really passed an axes instance, the call would raise an exception as axes are not callable.) Fix these checks. As a consequence, there was no previously valid path where axes_class_args would have been set, and passing a `(class, args)` pair is not documented anyways, so drop that "functionality" (which never worked).
1 parent cfd52eb commit 22b614b

File tree

1 file changed

+2
-19
lines changed

1 file changed

+2
-19
lines changed

lib/mpl_toolkits/axes_grid1/axes_grid.py

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import matplotlib as mpl
44
from matplotlib import cbook
5-
import matplotlib.axes as maxes
65
import matplotlib.ticker as ticker
76
from matplotlib.gridspec import SubplotSpec
87

@@ -191,14 +190,6 @@ def __init__(self, fig,
191190

192191
if axes_class is None:
193192
axes_class = self._defaultAxesClass
194-
axes_class_args = {}
195-
else:
196-
if (isinstance(axes_class, type)
197-
and issubclass(axes_class,
198-
self._defaultAxesClass.Axes)):
199-
axes_class_args = {}
200-
else:
201-
axes_class, axes_class_args = axes_class
202193

203194
self.axes_all = []
204195
self.axes_column = [[] for _ in range(self._ncols)]
@@ -246,8 +237,7 @@ def __init__(self, fig,
246237
else:
247238
sharey = None
248239

249-
ax = axes_class(fig, rect, sharex=sharex, sharey=sharey,
250-
**axes_class_args)
240+
ax = axes_class(fig, rect, sharex=sharex, sharey=sharey)
251241

252242
if share_all:
253243
if self._refax is None:
@@ -529,12 +519,6 @@ def __init__(self, fig,
529519

530520
if axes_class is None:
531521
axes_class = self._defaultAxesClass
532-
axes_class_args = {}
533-
else:
534-
if isinstance(axes_class, maxes.Axes):
535-
axes_class_args = {}
536-
else:
537-
axes_class, axes_class_args = axes_class
538522

539523
self.axes_all = []
540524
self.axes_column = [[] for _ in range(self._ncols)]
@@ -581,8 +565,7 @@ def __init__(self, fig,
581565
sharex = self._column_refax[col]
582566
sharey = self._row_refax[row]
583567

584-
ax = axes_class(fig, rect, sharex=sharex, sharey=sharey,
585-
**axes_class_args)
568+
ax = axes_class(fig, rect, sharex=sharex, sharey=sharey)
586569

587570
self.axes_all.append(ax)
588571
self.axes_column[col].append(ax)

0 commit comments

Comments
 (0)