Skip to content

Commit b76a868

Browse files
committed
Provide deprecation pathway
1 parent 3546b4b commit b76a868

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

lib/matplotlib/patches.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4817,3 +4817,11 @@ def draw(self, renderer):
48174817

48184818
# Just draw the rectangle
48194819
super().draw(renderer)
4820+
4821+
@_api.deprecated(
4822+
'3.10',
4823+
message=('Since Matplotlib 3.10 indicate_inset_[zoom] returns a single '
4824+
'IndicateInset patch with a connectors property. From 3.12 it will '
4825+
'no longer be possible to unpack the return value into two elements.'))
4826+
def __getitem__(self, key):
4827+
return [self, self.connectors][key]

lib/matplotlib/tests/test_axes.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7412,14 +7412,15 @@ def test_zoom_inset():
74127412
axin1.set_ylim([2, 2.5])
74137413
axin1.set_aspect(ax.get_aspect())
74147414

7415-
inset = ax.indicate_inset_zoom(axin1)
7415+
with pytest.warns(mpl.MatplotlibDeprecationWarning):
7416+
rec, connectors = ax.indicate_inset_zoom(axin1)
74167417
for _ in range(2):
74177418
# Drawing twice should not affect result
74187419
fig.canvas.draw()
7419-
assert len(inset.connectors) == 4
7420+
assert len(connectors) == 4
74207421
xx = np.array([[1.5, 2.],
74217422
[2.15, 2.5]])
7422-
assert np.all(inset.get_bbox().get_points() == xx)
7423+
assert np.all(rec.get_bbox().get_points() == xx)
74237424
xx = np.array([[0.6325, 0.692308],
74247425
[0.8425, 0.907692]])
74257426
np.testing.assert_allclose(
@@ -7520,7 +7521,6 @@ def test_indicate_inset_inverted(x_inverted, y_inverted):
75207521
ax1.invert_yaxis()
75217522

75227523
inset = ax1.indicate_inset([2, 2, 5, 4], ax2)
7523-
fig.draw_without_rendering()
75247524
lower_left, upper_left, lower_right, upper_right = inset.connectors
75257525

75267526
sign_x = -1 if x_inverted else 1

0 commit comments

Comments
 (0)