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

Skip to content

Commit b52adc2

Browse files
author
bakes
committed
Cleaning up test_spy_box in test_image.py
1 parent 951bcaa commit b52adc2

1 file changed

Lines changed: 24 additions & 58 deletions

File tree

lib/matplotlib/tests/test_image.py

Lines changed: 24 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1227,61 +1227,27 @@ def test_spy_box(fig_test, fig_ref):
12271227
ax_test = fig_test.subplots(1, 3)
12281228
ax_ref = fig_ref.subplots(1, 3)
12291229

1230-
# plotting with spy
1231-
ax_test[0].set_title("ones")
1232-
ax_test[0].spy([[1, 1], [1, 1], ])
1233-
ax_test[1].set_title("zeros")
1234-
ax_test[1].spy([[0, 0], [0, 0], ])
1235-
ax_test[2].set_title("mixed")
1236-
ax_test[2].spy([[0, 1], [1, 0], ])
1237-
1238-
# plotting with imshow
1239-
ax_ref[0].set_title("ones")
1240-
ax_ref[0].imshow([[1, 1], [1, 1], ], interpolation='nearest',
1241-
aspect='equal', origin='upper', cmap='Greys',
1242-
vmin=0, vmax=1)
1243-
ax_ref[0].set_xlim(-0.5, 1.5)
1244-
ax_ref[0].set_ylim(1.5, -0.5)
1245-
ax_ref[0].xaxis.tick_top()
1246-
ax_ref[0].title.set_y(1.05)
1247-
ax_ref[0].xaxis.set_ticks_position('both')
1248-
ax_ref[0].xaxis.set_major_locator(
1249-
mticker.MaxNLocator(nbins=9, steps=[1, 2, 5, 10], integer=True)
1250-
)
1251-
ax_ref[0].yaxis.set_major_locator(
1252-
mticker.MaxNLocator(nbins=9, steps=[1, 2, 5, 10], integer=True)
1253-
)
1254-
1255-
ax_ref[1].set_title("zeros")
1256-
ax_ref[1].imshow([[0, 0], [0, 0], ], interpolation='nearest',
1257-
aspect='equal', origin='upper', cmap='Greys',
1258-
vmin=0, vmax=1)
1259-
ax_ref[1].set_xlim(-0.5, 1.5)
1260-
ax_ref[1].set_ylim(1.5, -0.5)
1261-
ax_ref[1].xaxis.tick_top()
1262-
ax_ref[1].title.set_y(1.05)
1263-
ax_ref[1].xaxis.set_ticks_position('both')
1264-
ax_ref[1].xaxis.set_major_locator(
1265-
mticker.MaxNLocator(nbins=9, steps=[1, 2, 5, 10], integer=True)
1266-
)
1267-
ax_ref[1].yaxis.set_major_locator(
1268-
mticker.MaxNLocator(nbins=9, steps=[1, 2, 5, 10], integer=True)
1269-
)
1270-
1271-
ax_ref[2].set_title("mixed")
1272-
ax_ref[2].imshow([[0, 1], [1, 0], ], interpolation='nearest',
1273-
aspect='equal', origin='upper', cmap='Greys',
1274-
vmin=0, vmax=1)
1275-
ax_ref[2].set_xlim(-0.5, 1.5)
1276-
ax_ref[2].set_ylim(1.5, -0.5)
1277-
ax_ref[2].xaxis.tick_top()
1278-
ax_ref[2].title.set_y(1.05)
1279-
ax_ref[2].xaxis.set_ticks_position('both')
1280-
ax_ref[2].xaxis.set_major_locator(
1281-
mticker.MaxNLocator(nbins=9, steps=[1, 2, 5, 10], integer=True)
1282-
)
1283-
ax_ref[2].yaxis.set_major_locator(
1284-
mticker.MaxNLocator(nbins=9, steps=[1, 2, 5, 10], integer=True)
1285-
)
1286-
1287-
1230+
i = 0
1231+
1232+
plot_data = [[1, 1], [1, 1], ], [[0, 0], [0, 0], ], [[0, 1], [1, 0], ]
1233+
1234+
for z, title in zip((plot_data), ["ones", "zeros", "mixed"]):
1235+
print(i, z, title)
1236+
ax_test[i].set_title(title)
1237+
ax_test[i].spy(z)
1238+
ax_ref[i].set_title(title)
1239+
ax_ref[i].imshow(z, interpolation='nearest',
1240+
aspect='equal', origin='upper', cmap='Greys',
1241+
vmin=0, vmax=1)
1242+
ax_ref[i].set_xlim(-0.5, 1.5)
1243+
ax_ref[i].set_ylim(1.5, -0.5)
1244+
ax_ref[i].xaxis.tick_top()
1245+
ax_ref[i].title.set_y(1.05)
1246+
ax_ref[i].xaxis.set_ticks_position('both')
1247+
ax_ref[i].xaxis.set_major_locator(
1248+
mticker.MaxNLocator(nbins=9, steps=[1, 2, 5, 10], integer=True)
1249+
)
1250+
ax_ref[i].yaxis.set_major_locator(
1251+
mticker.MaxNLocator(nbins=9, steps=[1, 2, 5, 10], integer=True)
1252+
)
1253+
i += 1

0 commit comments

Comments
 (0)