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 c39207d

Browse filesBrowse files
committed
FIX: if we have already subclassed mixin class just return
If subplot_class_factory is passed a base class that already sub-classes the mixin class, simply return the base class. This will allow third-party packages to derive from maxes.Subplot rather than maxes.Axes which will allow easier (by ensuring that our classes and the third-party classes do not mix in the mro).
1 parent f4c518e commit c39207d
Copy full SHA for c39207d

File tree

Expand file treeCollapse file tree

2 files changed

+10
-0
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+10
-0
lines changed

‎lib/matplotlib/cbook/__init__.py

Copy file name to clipboardExpand all lines: lib/matplotlib/cbook/__init__.py
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2211,6 +2211,10 @@ def _make_class_factory(mixin_class, fmt, attr_name=None):
22112211

22122212
@functools.lru_cache(None)
22132213
def class_factory(axes_class):
2214+
# if we have already wrapped this class, declare victory!
2215+
if issubclass(axes_class, mixin_class):
2216+
return axes_class
2217+
22142218
# The parameter is named "axes_class" for backcompat but is really just
22152219
# a base class; no axes semantics are used.
22162220
base_class = axes_class

‎lib/matplotlib/tests/test_subplots.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_subplots.py
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import matplotlib.pyplot as plt
77
from matplotlib.testing.decorators import image_comparison
8+
import matplotlib.axes as maxes
89

910

1011
def check_shared(axs, x_shared, y_shared):
@@ -219,3 +220,8 @@ def test_dont_mutate_kwargs():
219220
gridspec_kw=gridspec_kw)
220221
assert subplot_kw == {'sharex': 'all'}
221222
assert gridspec_kw == {'width_ratios': [1, 2]}
223+
224+
225+
def test_subplot_factory_reapplication():
226+
assert maxes.subplot_class_factory(maxes.Axes) is maxes.Subplot
227+
assert maxes.subplot_class_factory(maxes.Subplot) is maxes.Subplot

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.