Skip to content

Commit

Permalink
Change parametric tests to normal tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanv committed Aug 30, 2007
1 parent fee312b commit e4d9ba9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 23 deletions.
19 changes: 8 additions & 11 deletions scipy/misc/tests/test_pilutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
import os.path
import numpy as N

datapath = os.path.dirname(__file__)
datapath = os.path.join(os.path.dirname(__file__),'data')

class test_pilutil(ParametricTestCase):
class test_pilutil(NumpyTestCase):
def test_imresize(self):
im = N.random.random((10,20))
for T in N.sctypes['float'] + [float]:
Expand All @@ -23,19 +23,16 @@ def test_bytescale(self):
assert_equal(pilutil.bytescale(x),x)
assert_equal(pilutil.bytescale(y),[0,127,255])

def tst_fromimage(self,filename,irange):
img = pilutil.fromimage(PIL.Image.open(filename))
imin,imax = irange
assert img.min() >= imin
assert img.max() <= imax

def testip_fromimage(self):
def test_fromimage(self):
data = {'icon.png':(0,255),
'icon_mono.png':(0,2),
'icon_mono_flat.png':(0,1)}

return ((self.tst_fromimage,os.path.join(datapath,'data',fn),irange)
for fn,irange in data.iteritems())
for fn,irange in data.iteritems():
img = pilutil.fromimage(PIL.Image.open(os.path.join(datapath,fn)))
imin,imax = irange
assert img.min() >= imin
assert img.max() <= imax

if __name__ == "__main__":
NumpyTest().run()
21 changes: 9 additions & 12 deletions scipy/sparse/tests/test_sparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -789,8 +789,7 @@ def check_set_slice(self):
assert_equal(caught,5)


class test_lil(_test_cs, _test_horiz_slicing, NumpyTestCase,
ParametricTestCase):
class test_lil(_test_cs, _test_horiz_slicing, NumpyTestCase):
spmatrix = lil_matrix

B = lil_matrix((4,3))
Expand Down Expand Up @@ -840,14 +839,7 @@ def check_lil_lil_assignment(self):
B[0,:] = A[0,:]
assert_array_equal(A[0,:].A, B[0,:].A)

def tst_inplace_op(self,op,arr,other,result):
cpy = arr
getattr(arr,"__i%s__" % op)(other)

assert_array_equal(cpy.todense(),arr.todense())
assert_array_equal(arr.todense(),result)

def testip_inplace_ops(self):
def test_inplace_ops(self):
B = self.B[:3,:3].copy()
B[:,:] = B-B
C = B.todense()
Expand All @@ -856,8 +848,13 @@ def testip_inplace_ops(self):
'sub':(B,zeros(B.shape)),
'mul':(3,C*3)}

return [(self.tst_inplace_op,op,B,other,result)
for op,(other,result) in data.iteritems()]
for op,(other,result) in data.iteritems():
arr = B.copy()
cpy = arr
getattr(arr,"__i%s__" % op)(other)

assert_array_equal(cpy.todense(),arr.todense())
assert_array_equal(arr.todense(),result)

def check_lil_slice_assignment(self):
B = lil_matrix((4,3))
Expand Down

0 comments on commit e4d9ba9

Please sign in to comment.