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

Skip to content

Commit 46be108

Browse files
committed
test conversion: move old-style test to new-style test
svn path=/trunk/matplotlib/; revision=7690
1 parent 8a6632f commit 46be108

3 files changed

Lines changed: 46 additions & 54 deletions

File tree

test/test_plots/baseline/TestPlot/shaped_data.png renamed to lib/matplotlib/tests/baseline_images/test_axes/shaped_data.png

File renamed without changes.

lib/matplotlib/tests/test_axes.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,3 +197,49 @@ def test_single_date():
197197
pylab.plot( time1, data1, 'o', color='r' )
198198

199199
fig.savefig( 'single_date' )
200+
201+
@image_comparison(baseline_images=['single_date'])
202+
def test_shaped_data():
203+
"""Test numpy shaped data."""
204+
205+
xdata = np.array([[ 0.53295185, 0.23052951, 0.19057629, 0.66724975, 0.96577916,
206+
0.73136095, 0.60823287, 0.017921 , 0.29744742, 0.27164665],
207+
[ 0.2798012 , 0.25814229, 0.02818193, 0.12966456, 0.57446277,
208+
0.58167607, 0.71028245, 0.69112737, 0.89923072, 0.99072476],
209+
[ 0.81218578, 0.80464528, 0.76071809, 0.85616314, 0.12757994,
210+
0.94324936, 0.73078663, 0.09658102, 0.60703967, 0.77664978],
211+
[ 0.28332265, 0.81479711, 0.86985333, 0.43797066, 0.32540082,
212+
0.43819229, 0.92230363, 0.49414252, 0.68168256, 0.05922372],
213+
[ 0.10721335, 0.93904142, 0.79163075, 0.73232848, 0.90283839,
214+
0.68408046, 0.25502302, 0.95976614, 0.59214115, 0.13663711],
215+
[ 0.28087456, 0.33127607, 0.15530412, 0.76558121, 0.83389773,
216+
0.03735974, 0.98717738, 0.71432229, 0.54881366, 0.86893953],
217+
[ 0.77995937, 0.995556 , 0.29688434, 0.15646162, 0.051848 ,
218+
0.37161935, 0.12998491, 0.09377296, 0.36882507, 0.36583435],
219+
[ 0.37851836, 0.05315792, 0.63144617, 0.25003433, 0.69586032,
220+
0.11393988, 0.92362096, 0.88045438, 0.93530252, 0.68275072],
221+
[ 0.86486596, 0.83236675, 0.82960664, 0.5779663 , 0.25724233,
222+
0.84841095, 0.90862812, 0.64414887, 0.3565272 , 0.71026066],
223+
[ 0.01383268, 0.3406093 , 0.76084285, 0.70800694, 0.87634056,
224+
0.08213693, 0.54655021, 0.98123181, 0.44080053, 0.86815815]])
225+
226+
y1 = np.arange( 10 )
227+
y1.shape = 1, 10
228+
229+
y2 = np.arange( 10 )
230+
y2.shape = 10, 1
231+
232+
fig = pylab.figure()
233+
pylab.subplot( 411 )
234+
pylab.plot( y1 )
235+
pylab.subplot( 412 )
236+
pylab.plot( y2 )
237+
238+
pylab.subplot( 413 )
239+
from nose.tools import assert_raises
240+
assert_raises(ValueError,pylab.plot, (y1,y2))
241+
242+
pylab.subplot( 414 )
243+
pylab.plot( xdata[:,1], xdata[1,:], 'o' )
244+
245+
fig.savefig( 'shaped data' )

test/test_plots/TestPlot.py

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -40,60 +40,6 @@ def tearDown( self ):
4040
"""Clean-up any generated files here."""
4141
pass
4242

43-
#--------------------------------------------------------------------
44-
def test_shaped_data( self ):
45-
"""Test numpy shaped data."""
46-
47-
xdata = npy.array([[ 0.53295185, 0.23052951, 0.19057629, 0.66724975, 0.96577916,
48-
0.73136095, 0.60823287, 0.017921 , 0.29744742, 0.27164665],
49-
[ 0.2798012 , 0.25814229, 0.02818193, 0.12966456, 0.57446277,
50-
0.58167607, 0.71028245, 0.69112737, 0.89923072, 0.99072476],
51-
[ 0.81218578, 0.80464528, 0.76071809, 0.85616314, 0.12757994,
52-
0.94324936, 0.73078663, 0.09658102, 0.60703967, 0.77664978],
53-
[ 0.28332265, 0.81479711, 0.86985333, 0.43797066, 0.32540082,
54-
0.43819229, 0.92230363, 0.49414252, 0.68168256, 0.05922372],
55-
[ 0.10721335, 0.93904142, 0.79163075, 0.73232848, 0.90283839,
56-
0.68408046, 0.25502302, 0.95976614, 0.59214115, 0.13663711],
57-
[ 0.28087456, 0.33127607, 0.15530412, 0.76558121, 0.83389773,
58-
0.03735974, 0.98717738, 0.71432229, 0.54881366, 0.86893953],
59-
[ 0.77995937, 0.995556 , 0.29688434, 0.15646162, 0.051848 ,
60-
0.37161935, 0.12998491, 0.09377296, 0.36882507, 0.36583435],
61-
[ 0.37851836, 0.05315792, 0.63144617, 0.25003433, 0.69586032,
62-
0.11393988, 0.92362096, 0.88045438, 0.93530252, 0.68275072],
63-
[ 0.86486596, 0.83236675, 0.82960664, 0.5779663 , 0.25724233,
64-
0.84841095, 0.90862812, 0.64414887, 0.3565272 , 0.71026066],
65-
[ 0.01383268, 0.3406093 , 0.76084285, 0.70800694, 0.87634056,
66-
0.08213693, 0.54655021, 0.98123181, 0.44080053, 0.86815815]])
67-
68-
fname = self.outFile( "shaped_data.png" )
69-
70-
y1 = npy.arange( 10 )
71-
y1.shape = 1, 10
72-
73-
y2 = npy.arange( 10 )
74-
y2.shape = 10, 1
75-
76-
fig = pylab.figure()
77-
pylab.subplot( 411 )
78-
pylab.plot( y1 )
79-
pylab.subplot( 412 )
80-
pylab.plot( y2 )
81-
82-
pylab.subplot( 413 )
83-
try:
84-
pylab.plot( y1, y2 )
85-
except:
86-
# This should fail
87-
pass
88-
else:
89-
self.fail( "Failed to raise an exception for mis-matched dimensions." )
90-
91-
pylab.subplot( 414 )
92-
pylab.plot( xdata[:,1], xdata[1,:], 'o' )
93-
94-
fig.savefig( fname )
95-
self.checkImage( fname )
96-
9743
#--------------------------------------------------------------------
9844
def test_const_xy( self ):
9945
"""Test constant xy data."""

0 commit comments

Comments
 (0)