Skip to content

Commit 860abd2

Browse files
Add more tests...
1 parent 33baa3b commit 860abd2

File tree

3 files changed

+37
-5
lines changed

3 files changed

+37
-5
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
venv/
22
.idea
3-
__pycache__
3+
__pycache__
4+
result_images

matplotview/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,5 +67,7 @@ def inset_zoom_axes(axes, bounds, *, image_interpolation="nearest", transform=No
6767
--------
6868
See `Axes.inset_axes` method for examples.
6969
"""
70-
inset_ax = axes.inset_axes(bounds, transform, zorder, **kwargs)
70+
inset_ax = axes.inset_axes(
71+
bounds, transform=transform, zorder=zorder, **kwargs
72+
)
7173
return view(inset_ax, axes, image_interpolation)

matplotview/tests/test_inset_zoom.py

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,39 @@
33
from matplotlib.testing.decorators import check_figures_equal
44
from matplotview import view, inset_zoom_axes
55

6+
@check_figures_equal(tol=3)
7+
def test_double_plot(fig_test, fig_ref):
8+
np.random.seed(1)
9+
im_data = np.random.rand(30, 30)
10+
11+
# Test case...
12+
ax_test1, ax_test2 = fig_test.subplots(1, 2)
13+
14+
ax_test1.plot([i for i in range(10)], "r")
15+
ax_test1.add_patch(plt.Circle((3, 3), 1, ec="black", fc="blue"))
16+
ax_test1.imshow(im_data, origin="lower", cmap="Blues", alpha=0.5,
17+
interpolation="nearest")
18+
ax_test2 = view(ax_test2, ax_test1)
19+
ax_test2.set_aspect(ax_test1.get_aspect())
20+
ax_test2.set_xlim(ax_test1.get_xlim())
21+
ax_test2.set_ylim(ax_test1.get_ylim())
22+
23+
# Reference...
24+
ax_ref1, ax_ref2 = fig_ref.subplots(1, 2)
25+
26+
ax_ref1.plot([i for i in range(10)], "r")
27+
ax_ref1.add_patch(plt.Circle((3, 3), 1, ec="black", fc="blue"))
28+
ax_ref1.imshow(im_data, origin="lower", cmap="Blues", alpha=0.5,
29+
interpolation="nearest")
30+
ax_ref2.plot([i for i in range(10)], "r")
31+
ax_ref2.add_patch(plt.Circle((3, 3), 1, ec="black", fc="blue"))
32+
ax_ref2.imshow(im_data, origin="lower", cmap="Blues", alpha=0.5,
33+
interpolation="nearest")
34+
35+
636
# Tolerance needed because the way the auto-zoom axes handles images is
737
# entirely different, leading to a slightly different result.
8-
@check_figures_equal(tol=3)
38+
@check_figures_equal(tol=3.5)
939
def test_auto_zoom_inset(fig_test, fig_ref):
1040
np.random.seed(1)
1141
im_data = np.random.rand(30, 30)
@@ -35,5 +65,4 @@ def test_auto_zoom_inset(fig_test, fig_ref):
3565
axins_ref.add_patch(plt.Circle((3, 3), 1, ec="black", fc="blue"))
3666
axins_ref.imshow(im_data, origin="lower", cmap="Blues", alpha=0.5,
3767
interpolation="nearest")
38-
ax_ref.indicate_inset_zoom(axins_ref, edgecolor="black")
39-
68+
ax_ref.indicate_inset_zoom(axins_ref, edgecolor="black")

0 commit comments

Comments
 (0)