Skip to content

Commit 10efd2b

Browse files
committed
Add sharing guard.
1 parent 9b82dc2 commit 10efd2b

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

lib/matplotlib/axes/_base.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4338,12 +4338,16 @@ def unshare_axes(self, axes=None):
43384338
@staticmethod
43394339
def _share_axes_symmetric(A, B, shared_axes):
43404340
"""Share A -> B, and B -> A"""
4341+
if A is B:
4342+
return
43414343
_AxesBase._share_axes_asymmetric(A, B, shared_axes)
43424344
_AxesBase._share_axes_asymmetric(B, A, shared_axes)
43434345

43444346
@staticmethod
43454347
def _share_axes_asymmetric(A, B, shared_axes):
43464348
"""Share A -> B"""
4349+
if A is B:
4350+
return
43474351
getattr(A, "_shared_{}_axes".format(shared_axes)).add(B)
43484352
getattr(B, "_shared_{}_inv_axes".format(shared_axes)).add(A)
43494353

lib/matplotlib/tests/test_axes.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5918,5 +5918,4 @@ def test_share_unshare_3d_axes():
59185918
assert ax1 in sharedz
59195919

59205920
sharedz = ax1._shared_z_axes
5921-
assert ax2 in sharedz
5922-
5921+
assert ax2 in sharedz

0 commit comments

Comments
 (0)