|
1 | 1 | from __future__ import (absolute_import, division, print_function, |
2 | 2 | unicode_literals) |
3 | 3 |
|
4 | | -import six |
5 | | - |
6 | 4 | import io |
7 | | -import os |
8 | | - |
9 | | -from distutils.version import LooseVersion as V |
| 5 | +from distutils.version import LooseVersion |
10 | 6 |
|
11 | 7 | import numpy as np |
12 | 8 | from numpy.testing import assert_array_almost_equal |
|
16 | 12 | from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas |
17 | 13 | from matplotlib.figure import Figure |
18 | 14 | from matplotlib.testing import skip |
19 | | -from matplotlib.testing.decorators import ( |
20 | | - cleanup, image_comparison, knownfailureif) |
| 15 | +from matplotlib.testing.decorators import cleanup, image_comparison |
21 | 16 | from matplotlib import pyplot as plt |
22 | 17 | from matplotlib import collections |
23 | 18 | from matplotlib import path |
@@ -72,71 +67,6 @@ def test_large_single_path_collection(): |
72 | 67 | plt.savefig(buff) |
73 | 68 |
|
74 | 69 |
|
75 | | -def report_memory(i): |
76 | | - pid = os.getpid() |
77 | | - a2 = os.popen('ps -p %d -o rss,sz' % pid).readlines() |
78 | | - print(i, ' ', a2[1], end=' ') |
79 | | - return int(a2[1].split()[0]) |
80 | | - |
81 | | -# This test is disabled -- it uses old API. -ADS 2009-09-07 |
82 | | -## def test_memleak(): |
83 | | -## """Test agg backend for memory leaks.""" |
84 | | -## from matplotlib.ft2font import FT2Font |
85 | | -## from numpy.random import rand |
86 | | -## from matplotlib.backend_bases import GraphicsContextBase |
87 | | -## from matplotlib.backends._backend_agg import RendererAgg |
88 | | - |
89 | | -## fontname = '/usr/local/share/matplotlib/Vera.ttf' |
90 | | - |
91 | | -## N = 200 |
92 | | -## for i in range( N ): |
93 | | -## gc = GraphicsContextBase() |
94 | | -## gc.set_clip_rectangle( [20, 20, 20, 20] ) |
95 | | -## o = RendererAgg( 400, 400, 72 ) |
96 | | - |
97 | | -## for j in range( 50 ): |
98 | | -## xs = [ 400*int(rand()) for k in range(8) ] |
99 | | -## ys = [ 400*int(rand()) for k in range(8) ] |
100 | | -## rgb = (1, 0, 0) |
101 | | -## pnts = zip( xs, ys ) |
102 | | -## o.draw_polygon( gc, rgb, pnts ) |
103 | | -## o.draw_polygon( gc, None, pnts ) |
104 | | - |
105 | | -## for j in range( 50 ): |
106 | | -## x = [ 400*int(rand()) for k in range(4) ] |
107 | | -## y = [ 400*int(rand()) for k in range(4) ] |
108 | | -## o.draw_lines( gc, x, y ) |
109 | | - |
110 | | -## for j in range( 50 ): |
111 | | -## args = [ 400*int(rand()) for k in range(4) ] |
112 | | -## rgb = (1, 0, 0) |
113 | | -## o.draw_rectangle( gc, rgb, *args ) |
114 | | - |
115 | | -## if 1: # add text |
116 | | -## font = FT2Font( fontname ) |
117 | | -## font.clear() |
118 | | -## font.set_text( 'hi mom', 60 ) |
119 | | -## font.set_size( 12, 72 ) |
120 | | -## o.draw_text_image( font.get_image(), 30, 40, gc ) |
121 | | - |
122 | | -## fname = "agg_memleak_%05d.png" |
123 | | -## o.write_png( fname % i ) |
124 | | -## val = report_memory( i ) |
125 | | -## if i==1: start = val |
126 | | - |
127 | | -## end = val |
128 | | -## avgMem = (end - start) / float(N) |
129 | | -## print 'Average memory consumed per loop: %1.4f\n' % (avgMem) |
130 | | - |
131 | | -## #TODO: Verify the expected mem usage and approximate tolerance that |
132 | | -## # should be used |
133 | | -## #self.checkClose( 0.32, avgMem, absTol = 0.1 ) |
134 | | - |
135 | | -## # w/o text and w/o write_png: Average memory consumed per loop: 0.02 |
136 | | -## # w/o text and w/ write_png : Average memory consumed per loop: 0.3400 |
137 | | -## # w/ text and w/ write_png : Average memory consumed per loop: 0.32 |
138 | | - |
139 | | - |
140 | 70 | @cleanup |
141 | 71 | def test_marker_with_nan(): |
142 | 72 | # This creates a marker with nans in it, which was segfaulting the |
@@ -250,7 +180,7 @@ def process_image(self, padded_src, dpi): |
250 | 180 | t2 = self.offset_filter.process_image(t1, dpi) |
251 | 181 | return t2 |
252 | 182 |
|
253 | | - if V(np.__version__) < V('1.7.0'): |
| 183 | + if LooseVersion(np.__version__) < LooseVersion('1.7.0'): |
254 | 184 | skip('Disabled on Numpy < 1.7.0') |
255 | 185 |
|
256 | 186 | fig = plt.figure() |
|
0 commit comments