diff --git a/lib/matplotlib/image.py b/lib/matplotlib/image.py index f2d9984a3429..e46b949425bb 100644 --- a/lib/matplotlib/image.py +++ b/lib/matplotlib/image.py @@ -620,7 +620,7 @@ def _check_unsampled_image(self, renderer): if renderer.option_scale_image(): return True else: - warnings.warn("The backend (%s) does not support interpolation='none'. The image will be interpolated with 'nearest` mode." % (str(type(renderer)))) + warnings.warn("The backend (%s) does not support interpolation='none'. The image will be interpolated with 'nearest` mode." % renderer.__class__) return False diff --git a/lib/matplotlib/tests/test_axes.py b/lib/matplotlib/tests/test_axes.py index 5c67dc88de40..4f390f4da9d7 100644 --- a/lib/matplotlib/tests/test_axes.py +++ b/lib/matplotlib/tests/test_axes.py @@ -41,6 +41,7 @@ def test_formatter_ticker(): ax.set_xlabel( "x-label 005" ) ax.autoscale_view() fig.savefig( 'formatter_ticker_005' ) + plt.close() @image_comparison(baseline_images=['offset_points']) def test_basic_annotate(): @@ -58,6 +59,7 @@ def test_basic_annotate(): xytext=(3, 3), textcoords='offset points' ) fig.savefig( 'offset_points' ) + plt.close() @image_comparison(baseline_images=['polar_axes']) def test_polar_annotations(): @@ -92,6 +94,7 @@ def test_polar_annotations(): ) fig.savefig( 'polar_axes' ) + plt.close() #-------------------------------------------------------------------- @image_comparison(baseline_images=['polar_coords']) @@ -123,6 +126,7 @@ def test_polar_coord_annotations(): ax.set_xlim( -20, 20 ) ax.set_ylim( -20, 20 ) fig.savefig( 'polar_coords' ) + plt.close() @image_comparison(baseline_images=['fill_units']) def test_fill_units(): @@ -164,6 +168,7 @@ def test_fill_units(): fig.autofmt_xdate() fig.savefig( 'fill_units' ) + plt.close() @image_comparison(baseline_images=['single_point']) def test_single_point(): @@ -175,6 +180,7 @@ def test_single_point(): plt.plot( [1], [1], 'o' ) fig.savefig( 'single_point' ) + plt.close() @image_comparison(baseline_images=['single_date']) def test_single_date(): @@ -189,6 +195,7 @@ def test_single_date(): plt.plot( time1, data1, 'o', color='r' ) fig.savefig( 'single_date' ) + plt.close() @image_comparison(baseline_images=['shaped_data']) def test_shaped_data(): @@ -233,6 +240,7 @@ def test_shaped_data(): plt.plot( xdata[:,1], xdata[1,:], 'o' ) fig.savefig( 'shaped_data' ) + plt.close() @image_comparison(baseline_images=['const_xy']) def test_const_xy(): @@ -248,6 +256,7 @@ def test_const_xy(): plt.plot( np.ones( (10,) ), np.ones( (10,) ), 'o' ) fig.savefig( 'const_xy' ) + plt.close() @image_comparison(baseline_images=['polar_wrap_180', 'polar_wrap_360', @@ -264,6 +273,7 @@ def test_polar_wrap(): plt.rgrids( [0.05, 0.1, 0.15, 0.2, 0.25, 0.3] ) fig.savefig( 'polar_wrap_180' ) + plt.close() fig = plt.figure() @@ -275,6 +285,7 @@ def test_polar_wrap(): plt.rgrids( [0.05, 0.1, 0.15, 0.2, 0.25, 0.3] ) fig.savefig( 'polar_wrap_360' ) + plt.close() @image_comparison(baseline_images=['polar_units']) def test_polar_units(): @@ -305,6 +316,7 @@ def test_polar_units(): y1 = [ y*km for y in y1 ] plt.polar( x2, y1, color = "blue", thetaunits="rad", runits="km" ) assert_true( isinstance(plt.gca().get_xaxis().get_major_formatter(), units.UnitDblFormatter) ) + plt.close() @image_comparison(baseline_images=['polar_rmin']) @@ -319,6 +331,7 @@ def test_polar_rmin(): ax.set_rmin(0.5) fig.savefig('polar_rmin') + plt.close() @image_comparison(baseline_images=['axvspan_epoch']) def test_axvspan_epoch(): @@ -340,6 +353,7 @@ def test_axvspan_epoch(): ax.set_xlim( t0 - 5.0*dt, tf + 5.0*dt ) fig.savefig( 'axvspan_epoch' ) + plt.close() @image_comparison(baseline_images=['axhspan_epoch']) def test_axhspan_epoch(): @@ -361,6 +375,7 @@ def test_axhspan_epoch(): ax.set_ylim( t0 - 5.0*dt, tf + 5.0*dt ) fig.savefig( 'axhspan_epoch' ) + plt.close() @image_comparison(baseline_images=['hexbin_extent']) @@ -375,6 +390,7 @@ def test_hexbin_extent(): ax.hexbin(x, y, extent=[.1, .3, .6, .7]) fig.savefig('hexbin_extent') + plt.close() @image_comparison(baseline_images=['nonfinite_limits']) def test_nonfinite_limits(): @@ -385,6 +401,7 @@ def test_nonfinite_limits(): ax = fig.add_subplot(111) ax.plot(x, y) fig.savefig('nonfinite_limits') + plt.close() @image_comparison(baseline_images=['imshow']) def test_imshow(): @@ -401,6 +418,7 @@ def test_imshow(): ax.imshow(r) fig.savefig('imshow') + plt.close() @image_comparison(baseline_images=['imshow_clip'], tol=1e-2) def test_imshow_clip(): @@ -428,6 +446,7 @@ def test_imshow_clip(): #Plot the image clipped by the contour ax.imshow(r, clip_path=clip_path) fig.savefig('imshow_clip') + plt.close() @image_comparison(baseline_images=['polycollection_joinstyle']) def test_polycollection_joinstyle(): @@ -446,6 +465,7 @@ def test_polycollection_joinstyle(): ax.set_yticks([]) fig.savefig('polycollection_joinstyle') + plt.close() @image_comparison(baseline_images=['fill_between_interpolate'], tol=1e-2) def test_fill_between_interpolate(): @@ -467,6 +487,7 @@ def test_fill_between_interpolate(): ax1.fill_between(x, y1, y2, where=y2<=y1, facecolor='red', interpolate=True) fig.savefig('fill_between_interpolate') + plt.close() @image_comparison(baseline_images=['symlog']) def test_symlog(): @@ -481,6 +502,7 @@ def test_symlog(): ax.set_ylim(-1,10000000) fig.savefig('symlog') + plt.close() @image_comparison(baseline_images=['pcolormesh'], tol=0.02) def test_pcolormesh(): @@ -511,6 +533,7 @@ def test_pcolormesh(): ax.set_yticks([]) fig.savefig('pcolormesh') + plt.close() @image_comparison(baseline_images=['canonical']) @@ -518,6 +541,7 @@ def test_canonical(): fig, ax = plt.subplots() ax.plot([1,2,3]) fig.savefig('canonical') + plt.close() @image_comparison(baseline_images=['arc_ellipse']) @@ -558,6 +582,7 @@ def test_arc_ellipse(): ax.add_patch(e2) fig.savefig('arc_ellipse') + plt.close() @image_comparison(baseline_images=['units_strings']) def test_units_strings(): @@ -569,6 +594,7 @@ def test_units_strings(): ax = fig.add_subplot(111) ax.plot(Id, pout) fig.savefig('units_strings') + plt.close() @image_comparison(baseline_images=['markevery']) def test_markevery(): @@ -584,6 +610,7 @@ def test_markevery(): ax.plot(x, y, '+', markevery=(5, 20), label='mark every 5 starting at 10') ax.legend() fig.savefig('markevery') + plt.close() @image_comparison(baseline_images=['markevery_line']) def test_markevery_line(): @@ -599,6 +626,7 @@ def test_markevery_line(): ax.plot(x, y, '-+', markevery=(5, 20), label='mark every 5 starting at 10') ax.legend() fig.savefig('markevery_line') + plt.close() if __name__=='__main__': import nose diff --git a/lib/matplotlib/tests/test_backend_pdf.py b/lib/matplotlib/tests/test_backend_pdf.py index 1d9b7b0ed12f..5031c8f820d3 100644 --- a/lib/matplotlib/tests/test_backend_pdf.py +++ b/lib/matplotlib/tests/test_backend_pdf.py @@ -27,5 +27,6 @@ def test_use14corefonts(): plt.text(0.5, 0.5, text, horizontalalignment='center', fontsize=24) plt.axhline(0.5, linewidth=0.5) plt.savefig('pdf_use14corefonts.pdf') + plt.close() finally: rcParams.update(original_rcParams) diff --git a/lib/matplotlib/tests/test_backend_svg.py b/lib/matplotlib/tests/test_backend_svg.py index c99c480981da..2c338680fc3e 100644 --- a/lib/matplotlib/tests/test_backend_svg.py +++ b/lib/matplotlib/tests/test_backend_svg.py @@ -20,6 +20,7 @@ def test_visibility(): fd = StringIO.StringIO() fig.savefig(fd,format='svg') + plt.close() fd.seek(0) buf = fd.read() diff --git a/lib/matplotlib/tests/test_dates.py b/lib/matplotlib/tests/test_dates.py index 04f491c597fa..68e7091a216b 100644 --- a/lib/matplotlib/tests/test_dates.py +++ b/lib/matplotlib/tests/test_dates.py @@ -13,6 +13,7 @@ def test_date_empty(): ax = fig.add_subplot(1,1,1) ax.xaxis_date() fig.savefig('date_empty') + plt.close() @image_comparison(baseline_images=['date_axhspan']) def test_date_axhspan(): @@ -26,6 +27,7 @@ def test_date_axhspan(): tf+datetime.timedelta(days=5)) fig.subplots_adjust(left=0.25) fig.savefig('date_axhspan') + plt.close() @image_comparison(baseline_images=['date_axvspan']) def test_date_axvspan(): @@ -39,6 +41,7 @@ def test_date_axvspan(): tf+datetime.timedelta(days=720)) fig.autofmt_xdate() fig.savefig('date_axvspan') + plt.close() @image_comparison(baseline_images=['date_axhline']) @@ -53,6 +56,7 @@ def test_date_axhline(): tf+datetime.timedelta(days=5)) fig.subplots_adjust(left=0.25) fig.savefig('date_axhline') + plt.close() @image_comparison(baseline_images=['date_axvline']) def test_date_axvline(): @@ -66,6 +70,7 @@ def test_date_axvline(): tf+datetime.timedelta(days=5)) fig.autofmt_xdate() fig.savefig('date_axvline') + plt.close() def test_too_many_date_ticks(): # Attempt to test SF 2715172, see @@ -82,6 +87,7 @@ def test_too_many_date_ticks(): from matplotlib.dates import DayLocator, DateFormatter, HourLocator ax.xaxis.set_major_locator(DayLocator()) assert_raises(RuntimeError, fig.savefig, 'junk.png') + plt.close() @image_comparison(baseline_images=['RRuleLocator_bounds']) def test_RRuleLocator(): @@ -112,6 +118,7 @@ def test_RRuleLocator(): fig.autofmt_xdate() fig.savefig( 'RRuleLocator_bounds' ) + plt.close() @image_comparison(baseline_images=['DateFormatter_fractionalSeconds']) def test_DateFormatter(): @@ -140,6 +147,7 @@ def test_DateFormatter(): fig.autofmt_xdate() fig.savefig( 'DateFormatter_fractionalSeconds' ) + plt.close() #@image_comparison(baseline_images=['empty_date_bug']) @knownfailureif(True) @@ -158,6 +166,7 @@ def test_empty_date_with_year_formatter(): ax.xaxis.set_major_formatter(yearFmt) fig.savefig('empty_date_bug') + plt.close() if __name__=='__main__': import nose diff --git a/lib/matplotlib/tests/test_image.py b/lib/matplotlib/tests/test_image.py index 23faf6c6b28f..75f1ba6f95eb 100644 --- a/lib/matplotlib/tests/test_image.py +++ b/lib/matplotlib/tests/test_image.py @@ -29,6 +29,7 @@ def test_image_interps(): ax3.set_ylabel('bicubic') fig.savefig('image_interps') + plt.close() @image_comparison(baseline_images=['figimage-0', 'figimage-1'], extensions=['png'], tol=1.5e-3) def test_figimage(): @@ -48,6 +49,7 @@ def test_figimage(): fig.figimage(img[::-1,::-1], xo=100, yo=100, origin='lower') fig.savefig('figimage-%d' % int(suppressComposite), dpi=100) + plt.close() def test_image_python_io(): fig = plt.figure() @@ -57,6 +59,7 @@ def test_image_python_io(): fig.savefig(buffer) buffer.seek(0) plt.imread(buffer) + plt.close() # def test_image_unicode_io(): # fig = plt.figure() @@ -108,6 +111,7 @@ def test_image_clip(): im = ax.imshow(d, extent=(-pi,pi,-pi/2,pi/2)) fig.savefig('image_clip') + plt.close() @image_comparison(baseline_images=['imshow']) def test_imshow(): @@ -122,6 +126,7 @@ def test_imshow(): ax.set_ylim(0,3) fig.savefig('imshow') + plt.close() if __name__=='__main__': import nose diff --git a/lib/matplotlib/tests/test_legend.py b/lib/matplotlib/tests/test_legend.py index 2cf7702244a2..6819fc64203f 100644 --- a/lib/matplotlib/tests/test_legend.py +++ b/lib/matplotlib/tests/test_legend.py @@ -15,6 +15,7 @@ def test_legend_auto1(): ax.plot(x, x-50, 'o', label='y=-1') ax.legend(loc=0) fig.savefig('legend_auto1') + plt.close() @image_comparison(baseline_images=['legend_auto2']) def test_legend_auto2(): @@ -26,4 +27,5 @@ def test_legend_auto2(): b2 = ax.bar(x, x[::-1], color='g') ax.legend([b1[0], b2[0]], ['up', 'down'], loc=0) fig.savefig('legend_auto2') + plt.close() diff --git a/lib/matplotlib/tests/test_mathtext.py b/lib/matplotlib/tests/test_mathtext.py index 0c37f6b9d602..078edc7b5f3c 100644 --- a/lib/matplotlib/tests/test_mathtext.py +++ b/lib/matplotlib/tests/test_mathtext.py @@ -143,6 +143,7 @@ def single_test(): fig.text(0.5, 0.5, test, horizontalalignment='center', verticalalignment='center') fig.savefig(filename) fig.clf() + plt.close() matplotlib.rcParams['mathtext.fontset'] = 'cm' return single_test diff --git a/lib/matplotlib/tests/test_png.py b/lib/matplotlib/tests/test_png.py index 58213c4aeb28..43c5ef777877 100644 --- a/lib/matplotlib/tests/test_png.py +++ b/lib/matplotlib/tests/test_png.py @@ -27,3 +27,4 @@ def test_pngsuite(): plt.gca().set_xlim(0, len(files)) fig.savefig('pngsuite') + plt.close() diff --git a/lib/matplotlib/tests/test_simplification.py b/lib/matplotlib/tests/test_simplification.py index b38ad48673db..56ea5ab36cda 100644 --- a/lib/matplotlib/tests/test_simplification.py +++ b/lib/matplotlib/tests/test_simplification.py @@ -28,6 +28,7 @@ def test_clipping(): ax.set_xticks([]) ax.set_yticks([]) fig.savefig('clipping') + plt.close() @image_comparison(baseline_images=['overflow'], tol=1e-2) def test_overflow(): @@ -42,6 +43,7 @@ def test_overflow(): ax.set_yticks([]) fig.savefig('overflow') + plt.close() @image_comparison(baseline_images=['clipping_diamond']) def test_diamond(): @@ -57,6 +59,7 @@ def test_diamond(): ax.set_yticks([]) fig.savefig('clipping_diamond') + plt.close() def test_noise(): np.random.seed(0) @@ -72,6 +75,7 @@ def test_noise(): transform = p1[0].get_transform() path = transform.transform_path(path) simplified = list(path.iter_segments(simplify=(800, 600))) + plt.close() print len(simplified) @@ -91,6 +95,7 @@ def test_sine_plus_noise(): transform = p1[0].get_transform() path = transform.transform_path(path) simplified = list(path.iter_segments(simplify=(800, 600))) + plt.close() print len(simplified) @@ -112,6 +117,7 @@ def test_simplify_curve(): ax.set_ylim((0, 2)) fig.savefig('simplify_curve') + plt.close() @image_comparison(baseline_images=['hatch_simplify']) def test_hatch(): @@ -122,6 +128,7 @@ def test_hatch(): ax.set_ylim((0.45, 0.55)) fig.savefig('hatch_simplify') + plt.close() @image_comparison(baseline_images=['fft_peaks']) def test_fft_peaks(): @@ -138,6 +145,7 @@ def test_fft_peaks(): transform = p1[0].get_transform() path = transform.transform_path(path) simplified = list(path.iter_segments(simplify=(800, 600))) + plt.close() print len(simplified) @@ -185,12 +193,13 @@ def test_throw_rendering_complexity_exceeded(): fig = plt.figure() ax = fig.add_subplot(111) ax.plot(xx, yy) + rcParams['path.simplify'] = True try: fig.savefig(cStringIO.StringIO()) except e: raise e - else: - rcParams['path.simplify'] = True + finally: + plt.close() @image_comparison(baseline_images=['clipper_edge']) def test_clipper(): @@ -209,6 +218,7 @@ def test_clipper(): ax.set_xlim(5, 9) fig.savefig('clipper_edge') + plt.close() @image_comparison(baseline_images=['para_equal_perp']) def test_para_equal_perp(): @@ -220,6 +230,7 @@ def test_para_equal_perp(): ax.plot(x + 1, y + 1) ax.plot(x + 1, y + 1, 'ro') fig.savefig('para_equal_perp') + plt.close() if __name__=='__main__': import nose diff --git a/lib/matplotlib/tests/test_spines.py b/lib/matplotlib/tests/test_spines.py index adebc44a4b84..1d49bd179fe5 100644 --- a/lib/matplotlib/tests/test_spines.py +++ b/lib/matplotlib/tests/test_spines.py @@ -19,3 +19,4 @@ def test_spines_axes_positions(): ax.spines['left'].set_color('none') ax.spines['bottom'].set_color('none') fig.savefig('spines_axes_positions') + plt.close() diff --git a/lib/matplotlib/tests/test_text.py b/lib/matplotlib/tests/test_text.py index 9ef688e1015e..e824e4f457d8 100644 --- a/lib/matplotlib/tests/test_text.py +++ b/lib/matplotlib/tests/test_text.py @@ -63,6 +63,7 @@ def test_font_styles(): ax.set_yticks([]) fig.savefig('font_styles') + plt.close() @image_comparison(baseline_images=['multiline']) def test_multiline(): @@ -74,3 +75,4 @@ def test_multiline(): ax.set_yticks([]) fig.savefig('multiline') + plt.close()