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

Skip to content

Commit 8fe199b

Browse files
committed
Add a test based on @pelson's example in matplotlib#1591.
1 parent c48afe4 commit 8fe199b

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

lib/matplotlib/tests/test_image.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,37 @@ def test_image_shift():
195195
extent=(tMin, tMax, 1, 100))
196196
ax.set_aspect('auto')
197197

198+
@cleanup
199+
def test_image_edges():
200+
f = plt.figure(figsize=[1, 1])
201+
ax = f.add_axes([0, 0, 1, 1], frameon=False)
202+
203+
data = np.tile(np.arange(12), 15).reshape(20, 9)
204+
205+
im = ax.imshow(data, origin='upper',
206+
extent=[-10, 10, -10, 10], interpolation='none',
207+
cmap='gray'
208+
)
209+
210+
x = y = 2
211+
ax.set_xlim([-x, x])
212+
ax.set_ylim([-y, y])
213+
214+
ax.set_xticks([])
215+
ax.set_yticks([])
216+
217+
buf = io.BytesIO()
218+
f.savefig(buf, facecolor=(0, 1, 0))
219+
220+
buf.seek(0)
221+
222+
im = plt.imread(buf)
223+
r, g, b, a = sum(im[:, 0])
224+
r, g, b, a = sum(im[:, -1])
225+
226+
assert g != 100, 'Expected a non-green edge - but sadly, it was.'
227+
228+
198229
if __name__=='__main__':
199230
import nose
200231
nose.runmodule(argv=['-s','--with-doctest'], exit=False)

0 commit comments

Comments
 (0)