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

Skip to content

Commit 4e46968

Browse files
committed
TST: Axes.indicate_inset failure
See #14275 inset_ax argument is meant to be optional, but currently fails if not given.
1 parent 0654800 commit 4e46968

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

lib/matplotlib/tests/test_axes.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5959,6 +5959,35 @@ def test_tick_padding_tightbbox():
59595959
assert bb.y0 < bb2.y0
59605960

59615961

5962+
def test_inset():
5963+
"""
5964+
Ensure that inset_ax argument is indeed optional
5965+
"""
5966+
dx, dy = 0.05, 0.05
5967+
# generate 2 2d grids for the x & y bounds
5968+
y, x = np.mgrid[slice(1, 5 + dy, dy),
5969+
slice(1, 5 + dx, dx)]
5970+
z = np.sin(x) ** 10 + np.cos(10 + y * x) * np.cos(x)
5971+
5972+
fig, ax = plt.subplots()
5973+
ax.pcolormesh(x, y, z)
5974+
ax.set_aspect(1.)
5975+
ax.apply_aspect()
5976+
# we need to apply_aspect to make the drawing below work.
5977+
5978+
xlim = [1.5, 2.15]
5979+
ylim = [2, 2.5]
5980+
5981+
rect = [xlim[0], ylim[0], xlim[1] - xlim[0], ylim[1] - ylim[0]]
5982+
5983+
rec, connectors = ax.indicate_inset(bounds=rect)
5984+
assert connectors is None
5985+
fig.canvas.draw()
5986+
xx = np.array([[1.5, 2.],
5987+
[2.15, 2.5]])
5988+
assert np.all(rec.get_bbox().get_points() == xx)
5989+
5990+
59625991
def test_zoom_inset():
59635992
dx, dy = 0.05, 0.05
59645993
# generate 2 2d grids for the x & y bounds
@@ -5981,6 +6010,7 @@ def test_zoom_inset():
59816010
axin1.set_aspect(ax.get_aspect())
59826011

59836012
rec, connectors = ax.indicate_inset_zoom(axin1)
6013+
assert len(connectors) == 4
59846014
fig.canvas.draw()
59856015
xx = np.array([[1.5, 2.],
59866016
[2.15, 2.5]])

0 commit comments

Comments
 (0)