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

Skip to content

Commit 5c19e89

Browse files
committed
Cleanup previous test_[ab]* files for flake8.
1 parent 675424c commit 5c19e89

6 files changed

Lines changed: 16 additions & 96 deletions

File tree

lib/matplotlib/tests/test_agg.py

Lines changed: 3 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
from __future__ import (absolute_import, division, print_function,
22
unicode_literals)
33

4-
import six
5-
64
import io
7-
import os
8-
9-
from distutils.version import LooseVersion as V
5+
from distutils.version import LooseVersion
106

117
import numpy as np
128
from numpy.testing import assert_array_almost_equal
@@ -16,8 +12,7 @@
1612
from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
1713
from matplotlib.figure import Figure
1814
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
2116
from matplotlib import pyplot as plt
2217
from matplotlib import collections
2318
from matplotlib import path
@@ -72,71 +67,6 @@ def test_large_single_path_collection():
7267
plt.savefig(buff)
7368

7469

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-
14070
@cleanup
14171
def test_marker_with_nan():
14272
# This creates a marker with nans in it, which was segfaulting the
@@ -250,7 +180,7 @@ def process_image(self, padded_src, dpi):
250180
t2 = self.offset_filter.process_image(t1, dpi)
251181
return t2
252182

253-
if V(np.__version__) < V('1.7.0'):
183+
if LooseVersion(np.__version__) < LooseVersion('1.7.0'):
254184
skip('Disabled on Numpy < 1.7.0')
255185

256186
fig = plt.figure()

lib/matplotlib/tests/test_arrow_patches.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
from __future__ import (absolute_import, division, print_function,
22
unicode_literals)
33

4-
import six
5-
64
import matplotlib.pyplot as plt
75
from matplotlib.testing.decorators import image_comparison
86
import matplotlib.patches as mpatches

lib/matplotlib/tests/test_artist.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
from __future__ import (absolute_import, division, print_function,
22
unicode_literals)
3-
import warnings
4-
import six
53

64
import io
5+
import warnings
76
from itertools import chain
7+
88
import numpy as np
99

1010
import matplotlib.pyplot as plt
@@ -14,7 +14,6 @@
1414
import matplotlib.transforms as mtrans
1515
import matplotlib.collections as mcollections
1616
import matplotlib.artist as martist
17-
import matplotlib as mpl
1817
from matplotlib.testing.decorators import image_comparison, cleanup
1918

2019

@@ -70,7 +69,7 @@ def test_collection_transform_of_none():
7069
ax.set_xlim([1, 3])
7170
ax.set_ylim([1, 3])
7271

73-
#draw an ellipse over data coord (2,2) by specifying device coords
72+
# draw an ellipse over data coord (2,2) by specifying device coords
7473
xy_data = (2, 2)
7574
xy_pix = ax.transData.transform_point(xy_data)
7675

@@ -219,8 +218,8 @@ def test_default_edges():
219218
ax3.set_ylim((-1, 1))
220219
pp1 = mpatches.PathPatch(
221220
mpath.Path([(0, 0), (1, 0), (1, 1), (0, 0)],
222-
[mpath.Path.MOVETO, mpath.Path.CURVE3,
223-
mpath.Path.CURVE3, mpath.Path.CLOSEPOLY]),
221+
[mpath.Path.MOVETO, mpath.Path.CURVE3,
222+
mpath.Path.CURVE3, mpath.Path.CLOSEPOLY]),
224223
fc="none", transform=ax4.transData)
225224
ax4.add_patch(pp1)
226225

lib/matplotlib/tests/test_basic.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
import six
55
import sys
66

7-
import warnings
8-
97
from ..testing.decorators import knownfailureif, skipif
108

119

lib/matplotlib/tests/test_bbox_tight.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
from __future__ import (absolute_import, division, print_function,
22
unicode_literals)
33

4-
import six
5-
from six.moves import xrange
6-
74
import numpy as np
85

9-
from matplotlib import rcParams
106
from matplotlib.testing.decorators import image_comparison
117
import matplotlib.pyplot as plt
128
import matplotlib.path as mpath
@@ -18,11 +14,11 @@
1814
savefig_kwarg=dict(bbox_inches='tight'))
1915
def test_bbox_inches_tight():
2016
#: Test that a figure saved using bbox_inches='tight' is clipped correctly
21-
data = [[ 66386, 174296, 75131, 577908, 32015],
22-
[ 58230, 381139, 78045, 99308, 160454],
23-
[ 89135, 80552, 152558, 497981, 603535],
24-
[ 78415, 81858, 150656, 193263, 69638],
25-
[139361, 331509, 343164, 781380, 52269]]
17+
data = [[66386, 174296, 75131, 577908, 32015],
18+
[58230, 381139, 78045, 99308, 160454],
19+
[89135, 80552, 152558, 497981, 603535],
20+
[78415, 81858, 150656, 193263, 69638],
21+
[139361, 331509, 343164, 781380, 52269]]
2622

2723
colLabels = rowLabels = [''] * 5
2824

@@ -33,7 +29,7 @@ def test_bbox_inches_tight():
3329
yoff = np.array([0.0] * len(colLabels))
3430
# the bottom values for stacked bar chart
3531
fig, ax = plt.subplots(1, 1)
36-
for row in xrange(rows):
32+
for row in range(rows):
3733
ax.bar(ind, data[row], width, bottom=yoff, color='b')
3834
yoff = yoff + data[row]
3935
cellText.append([''])
@@ -49,7 +45,7 @@ def test_bbox_inches_tight():
4945
@image_comparison(baseline_images=['bbox_inches_tight_suptile_legend'],
5046
remove_text=False, savefig_kwarg={'bbox_inches': 'tight'})
5147
def test_bbox_inches_tight_suptile_legend():
52-
plt.plot(list(xrange(10)), label='a straight line')
48+
plt.plot(np.arange(10), label='a straight line')
5349
plt.legend(bbox_to_anchor=(0.9, 1), loc=2, )
5450
plt.title('Axis title')
5551
plt.suptitle('Figure title')
@@ -70,7 +66,7 @@ def y_formatter(y, pos):
7066
def test_bbox_inches_tight_clipping():
7167
# tests bbox clipping on scatter points, and path clipping on a patch
7268
# to generate an appropriately tight bbox
73-
plt.scatter(list(xrange(10)), list(xrange(10)))
69+
plt.scatter(np.arange(10), np.arange(10))
7470
ax = plt.gca()
7571
ax.set_xlim([0, 5])
7672
ax.set_ylim([0, 5])

lib/matplotlib/tests/test_coding_standards.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,6 @@ def test_pep8_conformance_installed_files():
204204
'testing/jpl_units/__init__.py',
205205
'tri/triinterpolate.py',
206206
'tests/test_axes.py',
207-
'tests/test_bbox_tight.py',
208207
'tests/test_image.py',
209208
'tests/test_lines.py',
210209
'tests/test_mathtext.py',

0 commit comments

Comments
 (0)