[Scipy-svn] r3799 - in branches/testing_cleanup/scipy: . cluster/tests fftpack/tests lib/lapack/tests linalg/tests ndimage optimize/tests sparse/tests stats stats/tests testing

scipy-svn@scip... scipy-svn@scip...
Tue Jan 8 04:16:26 CST 2008


Author: matthew.brett@gmail.com
Date: 2008-01-08 04:16:05 -0600 (Tue, 08 Jan 2008)
New Revision: 3799

Added:
   branches/testing_cleanup/scipy/sparse/tests/test_spfuncs.py
Modified:
   branches/testing_cleanup/scipy/__init__.py
   branches/testing_cleanup/scipy/cluster/tests/test_vq.py
   branches/testing_cleanup/scipy/fftpack/tests/test_basic.py
   branches/testing_cleanup/scipy/fftpack/tests/test_pseudo_diffs.py
   branches/testing_cleanup/scipy/lib/lapack/tests/esv_tests.py
   branches/testing_cleanup/scipy/lib/lapack/tests/gesv_tests.py
   branches/testing_cleanup/scipy/linalg/tests/test_basic.py
   branches/testing_cleanup/scipy/linalg/tests/test_decomp.py
   branches/testing_cleanup/scipy/ndimage/__init__.py
   branches/testing_cleanup/scipy/optimize/tests/test_cobyla.py
   branches/testing_cleanup/scipy/optimize/tests/test_zeros.py
   branches/testing_cleanup/scipy/sparse/tests/test_base.py
   branches/testing_cleanup/scipy/sparse/tests/test_construct.py
   branches/testing_cleanup/scipy/sparse/tests/test_sparse.py
   branches/testing_cleanup/scipy/stats/info.py
   branches/testing_cleanup/scipy/stats/morestats.py
   branches/testing_cleanup/scipy/stats/tests/test_distributions.py
   branches/testing_cleanup/scipy/stats/tests/test_morestats.py
   branches/testing_cleanup/scipy/testing/decorators.py
   branches/testing_cleanup/scipy/testing/nosetester.py
   branches/testing_cleanup/scipy/testing/pkgtester.py
Log:
Module level tests working, change in interface for binomial test in stats to prevent running under nose test default

Modified: branches/testing_cleanup/scipy/__init__.py
===================================================================
--- branches/testing_cleanup/scipy/__init__.py	2008-01-08 06:19:19 UTC (rev 3798)
+++ branches/testing_cleanup/scipy/__init__.py	2008-01-08 10:16:05 UTC (rev 3799)
@@ -62,14 +62,9 @@
 """
 __doc__ += pkgload.get_pkgdocs()
 
+from testing.pkgtester import Tester
+test = Tester().test
 
-def test(level=1, verbosity=1):
-    """ Run Scipy tests suite with level and verbosity."""
-    from numpy.testing import NumpyTest
-    import scipy
-    scipy.pkgload()
-    return NumpyTest(scipy).test(level, verbosity)
-
 __doc__ += """
 
 Utility tools

Modified: branches/testing_cleanup/scipy/cluster/tests/test_vq.py
===================================================================
--- branches/testing_cleanup/scipy/cluster/tests/test_vq.py	2008-01-08 06:19:19 UTC (rev 3798)
+++ branches/testing_cleanup/scipy/cluster/tests/test_vq.py	2008-01-08 10:16:05 UTC (rev 3799)
@@ -40,19 +40,19 @@
 LABEL1  = N.array([0, 1, 2, 2, 2, 2, 1, 2, 1, 1, 1])
 
 class TestVq(TestCase):
-    def test_py_vq(self, level=1):
+    def test_py_vq(self):
         initc = N.concatenate(([[X[0]], [X[1]], [X[2]]]))
         code = initc.copy()
         label1 = py_vq(X, initc)[0]
         assert_array_equal(label1, LABEL1)
 
-    def test_py_vq2(self, level=1):
+    def test_py_vq2(self):
         initc = N.concatenate(([[X[0]], [X[1]], [X[2]]]))
         code = initc.copy()
         label1 = py_vq2(X, initc)[0]
         assert_array_equal(label1, LABEL1)
 
-    def test_vq(self, level=1):
+    def test_vq(self):
         initc = N.concatenate(([[X[0]], [X[1]], [X[2]]]))
         code = initc.copy()
         if TESTC:
@@ -62,7 +62,7 @@
         else:
             print "== not testing C imp of vq =="
 
-    #def test_py_vq_1d(self, level=1):
+    #def test_py_vq_1d(self):
     #    """Test special rank 1 vq algo, python implementation."""
     #    data = X[:, 0]
     #    initc = data[:3]
@@ -72,7 +72,7 @@
     #    assert_array_equal(a, ta)
     #    assert_array_equal(b, tb)
 
-    def test_vq_1d(self, level=1):
+    def test_vq_1d(self):
         """Test special rank 1 vq algo, python implementation."""
         data = X[:, 0]
         initc = data[:3]
@@ -86,14 +86,14 @@
             print "== not testing C imp of vq (rank 1) =="
 
 class TestKMean(TestCase):
-    def test_kmeans_simple(self, level=1):
+    def test_kmeans_simple(self):
         initc = N.concatenate(([[X[0]], [X[1]], [X[2]]]))
         code = initc.copy()
         code1 = kmeans(X, code, iter = 1)[0]
 
         assert_array_almost_equal(code1, CODET2)
 
-    def test_kmeans_lost_cluster(self, level=1):
+    def test_kmeans_lost_cluster(self):
         """This will cause kmean to have a cluster with no points."""
         data = N.fromfile(open(DATAFILE1), sep = ", ")
         data = data.reshape((200, 2))
@@ -109,7 +109,7 @@
         except ClusterError, e:
             print "exception raised as expected: " + str(e)
 
-    def test_kmeans2_simple(self, level=1):
+    def test_kmeans2_simple(self):
         """Testing simple call to kmeans2 and its results."""
         initc = N.concatenate(([[X[0]], [X[1]], [X[2]]]))
         code = initc.copy()
@@ -119,7 +119,7 @@
         assert_array_almost_equal(code1, CODET1)
         assert_array_almost_equal(code2, CODET2)
 
-    def test_kmeans2_rank1(self, level=1):
+    def test_kmeans2_rank1(self):
         """Testing simple call to kmeans2 with rank 1 data."""
         data = N.fromfile(open(DATAFILE1), sep = ", ")
         data = data.reshape((200, 2))

Modified: branches/testing_cleanup/scipy/fftpack/tests/test_basic.py
===================================================================
--- branches/testing_cleanup/scipy/fftpack/tests/test_basic.py	2008-01-08 06:19:19 UTC (rev 3798)
+++ branches/testing_cleanup/scipy/fftpack/tests/test_basic.py	2008-01-08 10:16:05 UTC (rev 3799)
@@ -6,9 +6,9 @@
 Build fftpack:
   python setup_fftpack.py build
 Run tests if scipy is installed:
-  python -c 'import scipy;scipy.fftpack.test(<level>)'
+  python -c 'import scipy;scipy.fftpack.test()'
 Run tests if fftpack is not installed:
-  python tests/test_basic.py [<level>]
+  python tests/test_basic.py
 """
 import sys
 from scipy.testing import *
@@ -124,7 +124,8 @@
             y = fftpack.zrfft(x)
             assert_array_almost_equal(y,y2)
 
-    def bench_random(self,level=5):
+    @dec.bench
+    def test_random(self):
         from numpy.fft import fft as numpy_fft
         print
         print '                 Fast Fourier Transform'
@@ -150,11 +151,11 @@
                 if size > 500: y = fft(x)
                 else: y = direct_dft(x)
                 assert_array_almost_equal(fft(x),y)
-                print '|%8.2f' % self.measure('fft(x)',repeat),
+                print '|%8.2f' % measure('fft(x)',repeat),
                 sys.stdout.flush()
 
                 assert_array_almost_equal(numpy_fft(x),y)
-                print '|%8.2f' % self.measure('numpy_fft(x)',repeat),
+                print '|%8.2f' % measure('numpy_fft(x)',repeat),
                 sys.stdout.flush()
 
             print ' (secs for %s calls)' % (repeat)
@@ -199,7 +200,8 @@
             assert_array_almost_equal (ifft(fft(x)),x)
             assert_array_almost_equal (fft(ifft(x)),x)
 
-    def bench_random(self,level=5):
+    @dec.bench
+    def test_random(self):
         from numpy.fft import ifft as numpy_ifft
         print
         print '       Inverse Fast Fourier Transform'
@@ -225,11 +227,11 @@
                 if size > 500: y = ifft(x)
                 else: y = direct_idft(x)
                 assert_array_almost_equal(ifft(x),y)
-                print '|%8.2f' % self.measure('ifft(x)',repeat),
+                print '|%8.2f' % measure('ifft(x)',repeat),
                 sys.stdout.flush()
 
                 assert_array_almost_equal(numpy_ifft(x),y)
-                print '|%8.2f' % self.measure('numpy_ifft(x)',repeat),
+                print '|%8.2f' % measure('numpy_ifft(x)',repeat),
                 sys.stdout.flush()
 
             print ' (secs for %s calls)' % (repeat)
@@ -262,7 +264,8 @@
             y = fftpack.drfft(x)
             assert_array_almost_equal(y,y1)
 
-    def bench_random(self,level=5):
+    @dec.bench
+    def test_random(self):
         from numpy.fft import rfft as numpy_rfft
         print
         print 'Fast Fourier Transform (real data)'
@@ -281,10 +284,10 @@
             sys.stdout.flush()
 
             x = random([size]).astype(double)
-            print '|%8.2f' % self.measure('rfft(x)',repeat),
+            print '|%8.2f' % measure('rfft(x)',repeat),
             sys.stdout.flush()
 
-            print '|%8.2f' % self.measure('numpy_rfft(x)',repeat),
+            print '|%8.2f' % measure('numpy_rfft(x)',repeat),
             sys.stdout.flush()
 
             print ' (secs for %s calls)' % (repeat)
@@ -327,7 +330,8 @@
             assert_array_almost_equal (irfft(rfft(x)),x)
             assert_array_almost_equal (rfft(irfft(x)),x)
 
-    def bench_random(self,level=5):
+    @dec.bench
+    def test_random(self):
         from numpy.fft import irfft as numpy_irfft
 
         print
@@ -355,11 +359,11 @@
                 x1[-1] = x[-1]
             y = irfft(x)
 
-            print '|%8.2f' % self.measure('irfft(x)',repeat),
+            print '|%8.2f' % measure('irfft(x)',repeat),
             sys.stdout.flush()
 
             assert_array_almost_equal(numpy_irfft(x1,size),y)
-            print '|%8.2f' % self.measure('numpy_irfft(x1,size)',repeat),
+            print '|%8.2f' % measure('numpy_irfft(x1,size)',repeat),
             sys.stdout.flush()
 
             print ' (secs for %s calls)' % (repeat)
@@ -493,7 +497,8 @@
         assert_array_almost_equal (y,swapaxes(\
             fftn(swapaxes(large_x1,-1,-2)),-1,-2))
 
-    def bench_random(self,level=5):
+    @dec.bench
+    def test_random(self):
         from numpy.fft import fftn as numpy_fftn
         print
         print '    Multi-dimensional Fast Fourier Transform'
@@ -516,11 +521,11 @@
                 #if size > 500: y = fftn(x)
                 #else: y = direct_dft(x)
                 assert_array_almost_equal(fftn(x),y)
-                print '|%8.2f' % self.measure('fftn(x)',repeat),
+                print '|%8.2f' % measure('fftn(x)',repeat),
                 sys.stdout.flush()
 
                 assert_array_almost_equal(numpy_fftn(x),y)
-                print '|%8.2f' % self.measure('numpy_fftn(x)',repeat),
+                print '|%8.2f' % measure('numpy_fftn(x)',repeat),
                 sys.stdout.flush()
 
             print ' (secs for %s calls)' % (repeat)

Modified: branches/testing_cleanup/scipy/fftpack/tests/test_pseudo_diffs.py
===================================================================
--- branches/testing_cleanup/scipy/fftpack/tests/test_pseudo_diffs.py	2008-01-08 06:19:19 UTC (rev 3798)
+++ branches/testing_cleanup/scipy/fftpack/tests/test_pseudo_diffs.py	2008-01-08 10:16:05 UTC (rev 3799)
@@ -184,7 +184,8 @@
                 assert_array_almost_equal(diff(diff(f,k),-k),f)
                 assert_array_almost_equal(diff(diff(f,-k),k),f)
 
-    def bench_random(self,level=5):
+    @dec.bench
+    def test_random(self):
         print
         print 'Differentiation of periodic functions'
         print '====================================='
@@ -207,9 +208,9 @@
                 f = sin(x)*cos(4*x)
             assert_array_almost_equal(diff(f,1),direct_diff(f,1))
             assert_array_almost_equal(diff(f,2),direct_diff(f,2))
-            print '| %9.2f' % self.measure('diff(f,3)',repeat),
+            print '| %9.2f' % measure('diff(f,3)',repeat),
             sys.stdout.flush()
-            print '| %9.2f' % self.measure('direct_diff(f,3)',repeat),
+            print '| %9.2f' % measure('direct_diff(f,3)',repeat),
             sys.stdout.flush()
             print ' (secs for %s calls)' % (repeat)
 
@@ -247,7 +248,8 @@
                 assert_array_almost_equal(itilbert(tilbert(f,h),h),f)
                 assert_array_almost_equal(tilbert(itilbert(f,h),h),f)
 
-    def bench_random(self,level=5):
+    @dec.bench
+    def test_random(self):
         print
         print ' Tilbert transform of periodic functions'
         print '========================================='
@@ -269,9 +271,9 @@
             else:
                 f = sin(x)*cos(4*x)
             assert_array_almost_equal(tilbert(f,1),direct_tilbert(f,1))
-            print '| %9.2f' % self.measure('tilbert(f,1)',repeat),
+            print '| %9.2f' % measure('tilbert(f,1)',repeat),
             sys.stdout.flush()
-            print '| %9.2f' % self.measure('direct_tilbert(f,1)',repeat),
+            print '| %9.2f' % measure('direct_tilbert(f,1)',repeat),
             sys.stdout.flush()
             print ' (secs for %s calls)' % (repeat)
 
@@ -330,7 +332,8 @@
             assert_array_almost_equal(direct_hilbert(direct_ihilbert(f)),f)
             assert_array_almost_equal(hilbert(ihilbert(f)),f)
 
-    def bench_random(self,level=5):
+    @dec.bench
+    def test_random(self):
         print
         print ' Hilbert transform of periodic functions'
         print '========================================='
@@ -352,9 +355,9 @@
             else:
                 f = sin(x)*cos(4*x)
             assert_array_almost_equal(hilbert(f),direct_hilbert(f))
-            print '| %9.2f' % self.measure('hilbert(f)',repeat),
+            print '| %9.2f' % measure('hilbert(f)',repeat),
             sys.stdout.flush()
-            print '| %9.2f' % self.measure('direct_hilbert(f)',repeat),
+            print '| %9.2f' % measure('direct_hilbert(f)',repeat),
             sys.stdout.flush()
             print ' (secs for %s calls)' % (repeat)
 
@@ -395,7 +398,8 @@
             assert_array_almost_equal(shift(sin(x),pi),-sin(x))
             assert_array_almost_equal(shift(sin(x),pi/2),cos(x))
 
-    def bench_random(self,level=5):
+    @dec.bench
+    def test_random(self):
         print
         print ' Shifting periodic functions'
         print '=============================='
@@ -421,9 +425,9 @@
                 sf = sin(x+a)*cos(4*(x+a))
             assert_array_almost_equal(direct_shift(f,1),sf)
             assert_array_almost_equal(shift(f,1),sf)
-            print '| %9.2f' % self.measure('shift(f,a)',repeat),
+            print '| %9.2f' % measure('shift(f,a)',repeat),
             sys.stdout.flush()
-            print '| %9.2f' % self.measure('direct_shift(f,a)',repeat),
+            print '| %9.2f' % measure('direct_shift(f,a)',repeat),
             sys.stdout.flush()
             print ' (secs for %s calls)' % (repeat)
 

Modified: branches/testing_cleanup/scipy/lib/lapack/tests/esv_tests.py
===================================================================
--- branches/testing_cleanup/scipy/lib/lapack/tests/esv_tests.py	2008-01-08 06:19:19 UTC (rev 3798)
+++ branches/testing_cleanup/scipy/lib/lapack/tests/esv_tests.py	2008-01-08 10:16:05 UTC (rev 3799)
@@ -4,7 +4,7 @@
 
 class _test_ev(object):
 
-    def check_syev(self,level=1,sym='sy',suffix=''):
+    def check_syev(self,sym='sy',suffix=''):
         a = [[1,2,3],[2,2,3],[3,3,6]]
         exact_w = [-0.6699243371851365,0.4876938861533345,9.182230451031804]
         f = getattr(self.lapack,sym+'ev'+suffix)
@@ -20,7 +20,7 @@
 
     #def check_heevd(self): self.check_syev(sym='he',suffix='d')
 
-##    def check_heev_complex(self,level=1,suffix=''):
+##    def check_heev_complex(self,suffix=''):
 ##        a= [[1,2-2j,3+7j],[2+2j,2,3],[3-7j,3,5]]
 ##        exact_w=[-6.305141710654834,2.797880950890922,11.50726075976392]
 ##        f = getattr(self.lapack,'heev'+suffix)
@@ -32,7 +32,7 @@
 
     #def check_heevd_complex(self): self.check_heev_complex(suffix='d')
 
-    def check_syevr(self,level=1,sym='sy'):
+    def check_syevr(self,sym='sy'):
         a = [[1,2,3],[2,2,3],[3,3,6]]
         exact_w = [-0.6699243371851365,0.4876938861533345,9.182230451031804]
         f = getattr(self.lapack,sym+'evr')
@@ -42,7 +42,7 @@
         for i in range(3):
             assert_array_almost_equal(dot(a,v[:,i]),w[i]*v[:,i])
 
-##    def check_heevr_complex(self,level=1):
+##    def check_heevr_complex(self):
 ##        a= [[1,2-2j,3+7j],[2+2j,2,3],[3-7j,3,5]]
 ##        exact_w=[-6.305141710654834,2.797880950890922,11.50726075976392]
 ##        f = self.lapack.heevr
@@ -54,7 +54,7 @@
 
 ##    def check_heevr(self): self.check_syevr(sym='he')
 
-    def check_syevr_irange(self,level=1,sym='sy',irange=[0,2]):
+    def check_syevr_irange(self,sym='sy',irange=[0,2]):
         a = [[1,2,3],[2,2,3],[3,3,6]]
         exact_w = [-0.6699243371851365,0.4876938861533345,9.182230451031804]
         f = getattr(self.lapack,sym+'evr')
@@ -79,7 +79,7 @@
 
 ##    def check_heevr_irange_high(self): self.check_syevr_irange(sym='he',irange=[1,2])
 
-    def check_syevr_vrange(self,level=1,sym='sy',vrange=None):
+    def check_syevr_vrange(self,sym='sy',vrange=None):
         a = [[1,2,3],[2,2,3],[3,3,6]]
         exact_w = [-0.6699243371851365,0.4876938861533345,9.182230451031804]
         if vrange is None:

Modified: branches/testing_cleanup/scipy/lib/lapack/tests/gesv_tests.py
===================================================================
--- branches/testing_cleanup/scipy/lib/lapack/tests/gesv_tests.py	2008-01-08 06:19:19 UTC (rev 3798)
+++ branches/testing_cleanup/scipy/lib/lapack/tests/gesv_tests.py	2008-01-08 10:16:05 UTC (rev 3799)
@@ -4,7 +4,7 @@
 
 class _test_gev(object):
 
-    def check_sygv(self,level=1,sym='sy',suffix='',itype=1):
+    def check_sygv(self,sym='sy',suffix='',itype=1):
         a = [[1,2,3],[2,2,3],[3,3,6]]
         b = [[10,-1,1],[-1,8,-2],[1,-2,6]]
         f = getattr(self.lapack,sym+'gv'+suffix)

Modified: branches/testing_cleanup/scipy/linalg/tests/test_basic.py
===================================================================
--- branches/testing_cleanup/scipy/linalg/tests/test_basic.py	2008-01-08 06:19:19 UTC (rev 3798)
+++ branches/testing_cleanup/scipy/linalg/tests/test_basic.py	2008-01-08 10:16:05 UTC (rev 3799)
@@ -14,9 +14,9 @@
 Build linalg:
   python setup_linalg.py build
 Run tests if scipy is installed:
-  python -c 'import scipy;scipy.linalg.test(<level>)'
+  python -c 'import scipy;scipy.linalg.test()'
 Run tests if linalg is not installed:
-  python tests/test_basic.py [<level>]
+  python tests/test_basic.py
 """
 
 import numpy
@@ -153,7 +153,8 @@
             x = solve(a,b,sym_pos=1)
             assert_array_almost_equal(numpy.dot(a,x),b)
 
-    def bench_random(self,level=5):
+    @dec.bench
+    def test_bench_random(self):
         import numpy.linalg as linalg
         basic_solve = linalg.solve
         print
@@ -174,19 +175,19 @@
             for i in range(size): a[i,i] = 10*(.1+a[i,i])
             b = random([size])
 
-            print '| %6.2f ' % self.measure('solve(a,b)',repeat),
+            print '| %6.2f ' % measure('solve(a,b)',repeat),
             sys.stdout.flush()
 
-            print '| %6.2f ' % self.measure('basic_solve(a,b)',repeat),
+            print '| %6.2f ' % measure('basic_solve(a,b)',repeat),
             sys.stdout.flush()
 
             a = a[-1::-1,-1::-1] # turn into a non-contiguous array
             assert not a.flags['CONTIGUOUS']
 
-            print '| %6.2f ' % self.measure('solve(a,b)',repeat),
+            print '| %6.2f ' % measure('solve(a,b)',repeat),
             sys.stdout.flush()
 
-            print '| %6.2f ' % self.measure('basic_solve(a,b)',repeat),
+            print '| %6.2f ' % measure('basic_solve(a,b)',repeat),
             sys.stdout.flush()
 
             print '   (secs for %s calls)' % (repeat)
@@ -226,7 +227,8 @@
             assert_array_almost_equal(numpy.dot(a,a_inv),
                                       numpy.identity(n))
 
-    def bench_random(self,level=5):
+    @dec.bench
+    def test_bench_random(self):
         import numpy.linalg as linalg
         basic_inv = linalg.inv
         print
@@ -245,19 +247,19 @@
             # large diagonal ensures non-singularity:
             for i in range(size): a[i,i] = 10*(.1+a[i,i])
 
-            print '| %6.2f ' % self.measure('inv(a)',repeat),
+            print '| %6.2f ' % measure('inv(a)',repeat),
             sys.stdout.flush()
 
-            print '| %6.2f ' % self.measure('basic_inv(a)',repeat),
+            print '| %6.2f ' % measure('basic_inv(a)',repeat),
             sys.stdout.flush()
 
             a = a[-1::-1,-1::-1] # turn into a non-contiguous array
             assert not a.flags['CONTIGUOUS']
 
-            print '| %6.2f ' % self.measure('inv(a)',repeat),
+            print '| %6.2f ' % measure('inv(a)',repeat),
             sys.stdout.flush()
 
-            print '| %6.2f ' % self.measure('basic_inv(a)',repeat),
+            print '| %6.2f ' % measure('basic_inv(a)',repeat),
             sys.stdout.flush()
 
             print '   (secs for %s calls)' % (repeat)
@@ -295,7 +297,8 @@
             d2 = basic_det(a)
             assert_almost_equal(d1,d2)
 
-    def bench_random(self,level=5):
+    @dec.bench
+    def test_bench_random(self):
         import numpy.linalg as linalg
         basic_det = linalg.det
         print
@@ -312,19 +315,19 @@
 
             a = random([size,size])
 
-            print '| %6.2f ' % self.measure('det(a)',repeat),
+            print '| %6.2f ' % measure('det(a)',repeat),
             sys.stdout.flush()
 
-            print '| %6.2f ' % self.measure('basic_det(a)',repeat),
+            print '| %6.2f ' % measure('basic_det(a)',repeat),
             sys.stdout.flush()
 
             a = a[-1::-1,-1::-1] # turn into a non-contiguous array
             assert not a.flags['CONTIGUOUS']
 
-            print '| %6.2f ' % self.measure('det(a)',repeat),
+            print '| %6.2f ' % measure('det(a)',repeat),
             sys.stdout.flush()
 
-            print '| %6.2f ' % self.measure('basic_det(a)',repeat),
+            print '| %6.2f ' % measure('basic_det(a)',repeat),
             sys.stdout.flush()
 
             print '   (secs for %s calls)' % (repeat)

Modified: branches/testing_cleanup/scipy/linalg/tests/test_decomp.py
===================================================================
--- branches/testing_cleanup/scipy/linalg/tests/test_decomp.py	2008-01-08 06:19:19 UTC (rev 3798)
+++ branches/testing_cleanup/scipy/linalg/tests/test_decomp.py	2008-01-08 10:16:05 UTC (rev 3799)
@@ -9,9 +9,9 @@
 Build linalg:
   python setup_linalg.py build
 Run tests if scipy is installed:
-  python -c 'import scipy;scipy.linalg.test(<level>)'
+  python -c 'import scipy;scipy.linalg.test()'
 Run tests if linalg is not installed:
-  python tests/test_decomp.py [<level>]
+  python tests/test_decomp.py 
 """
 
 import sys
@@ -59,7 +59,8 @@
                    (9+1j-sqrt(92+6j))/2]
         assert_array_almost_equal(w,exact_w)
 
-    def bench_random(self,level=5):
+    @dec.bench
+    def test_bench_random(self):
         import numpy.linalg as linalg
         Numeric_eigvals = linalg.eigvals
         print
@@ -76,7 +77,7 @@
 
             a = random([size,size])
 
-            print '| %6.2f ' % self.measure('eigvals(a)',repeat),
+            print '| %6.2f ' % measure('eigvals(a)',repeat),
             sys.stdout.flush()
 
             print '   (secs for %s calls)' % (repeat)

Modified: branches/testing_cleanup/scipy/ndimage/__init__.py
===================================================================
--- branches/testing_cleanup/scipy/ndimage/__init__.py	2008-01-08 06:19:19 UTC (rev 3798)
+++ branches/testing_cleanup/scipy/ndimage/__init__.py	2008-01-08 10:16:05 UTC (rev 3799)
@@ -37,3 +37,6 @@
 
 from info import __doc__
 __version__ = '2.0'
+
+from scipy.testing.pkgtester import Tester
+test = Tester().test

Modified: branches/testing_cleanup/scipy/optimize/tests/test_cobyla.py
===================================================================
--- branches/testing_cleanup/scipy/optimize/tests/test_cobyla.py	2008-01-08 06:19:19 UTC (rev 3798)
+++ branches/testing_cleanup/scipy/optimize/tests/test_cobyla.py	2008-01-08 10:16:05 UTC (rev 3799)
@@ -5,7 +5,7 @@
 from scipy.optimize import cobyla as co
 
 class TestCobyla(TestCase):
-    def test_simple(self, level=1):
+    def test_simple(self):
 
         function = lambda x: x[0]**2 + abs(x[1])**3
         con1 = lambda x: x[0]**2 + x[1]**2 - 25

Modified: branches/testing_cleanup/scipy/optimize/tests/test_zeros.py
===================================================================
--- branches/testing_cleanup/scipy/optimize/tests/test_zeros.py	2008-01-08 06:19:19 UTC (rev 3798)
+++ branches/testing_cleanup/scipy/optimize/tests/test_zeros.py	2008-01-08 10:16:05 UTC (rev 3799)
@@ -69,7 +69,8 @@
     def test_brenth(self):
         self.run_check(cc.brenth, 'brenth')
 
-    def bench_run(self,level=5):
+    @dec.bench
+    def test_run(self):
         a = .5
         b = sqrt(3)
         repeat = 2000
@@ -84,7 +85,7 @@
             for j in range(len(methods)) :
                 meth = methods[j]
                 try:
-                    t = self.measure("meth(func,a,b)",repeat)
+                    t = measure("meth(func,a,b)",repeat)
                 except:
                     print '%s : failed'%mstrings[j]
                 else:

Modified: branches/testing_cleanup/scipy/sparse/tests/test_base.py
===================================================================
--- branches/testing_cleanup/scipy/sparse/tests/test_base.py	2008-01-08 06:19:19 UTC (rev 3798)
+++ branches/testing_cleanup/scipy/sparse/tests/test_base.py	2008-01-08 10:16:05 UTC (rev 3799)
@@ -8,9 +8,9 @@
 Build sparse:
   python setup.py build
 Run tests if scipy is installed:
-  python -c 'import scipy;scipy.sparse.test(<level>)'
+  python -c 'import scipy;scipy.sparse.test()'
 Run tests if sparse is not installed:
-  python tests/test_sparse.py [<level>]
+  python tests/test_sparse.py
 """
 
 import numpy
@@ -1282,7 +1282,7 @@
         A = kron( [[1,0,2,0],[0,1,0,0],[0,0,0,0]], [[0,1,2],[3,0,5]] )
         assert_equal(bsr_matrix(A,blocksize=(2,3)).todense(),A)
         
-    def check_eliminate_zeros(self):
+    def test_eliminate_zeros(self):
         data = kron([1, 0, 0, 0, 2, 0, 3, 0], [[1,1],[1,1]]).T
         data = data.reshape(-1,2,2)
         indices = array( [1, 2, 3, 4, 5, 6, 7, 8] )

Modified: branches/testing_cleanup/scipy/sparse/tests/test_construct.py
===================================================================
--- branches/testing_cleanup/scipy/sparse/tests/test_construct.py	2008-01-08 06:19:19 UTC (rev 3798)
+++ branches/testing_cleanup/scipy/sparse/tests/test_construct.py	2008-01-08 10:16:05 UTC (rev 3799)
@@ -11,7 +11,7 @@
 #TODO check whether format=XXX is respected
 
 class TestConstructUtils(TestCase):
-    def check_spdiags(self):
+    def test_spdiags(self):
         diags1 = array( [[ 1, 2, 3, 4, 5]] )
         diags2 = array( [[ 1, 2, 3, 4, 5],
                          [ 6, 7, 8, 9,10]] )

Modified: branches/testing_cleanup/scipy/sparse/tests/test_sparse.py
===================================================================
--- branches/testing_cleanup/scipy/sparse/tests/test_sparse.py	2008-01-08 06:19:19 UTC (rev 3798)
+++ branches/testing_cleanup/scipy/sparse/tests/test_sparse.py	2008-01-08 10:16:05 UTC (rev 3799)
@@ -46,7 +46,8 @@
 class TestSparseTools(TestCase):
     """Simple benchmarks for sparse matrix module"""
 
-    def bench_arithmetic(self):
+    @dec.bench
+    def test_arithmetic(self):
         matrices = []
         #matrices.append( ('A','Identity', spidentity(500**2,format='csr')) )
         matrices.append( ('A','Poisson5pt', poisson2d(500,format='csr'))  )
@@ -93,8 +94,8 @@
                     print fmt % (format,operation,msec_per_it)
 
   
-
-    def bench_sort(self):
+    @dec.bench
+    def test_sort(self):
         """sort CSR column indices"""
         matrices = []
         matrices.append( ('Rand10',  1e4,  10) )
@@ -127,8 +128,8 @@
 
             print fmt % (A.format,name,shape,A.nnz,1e3*(end-start)/float(iter) )
 
-
-    def bench_matvec(self):
+    @dec.bench
+    def test_matvec(self):
         matrices = []
         matrices.append(('Identity',   spidentity(10**4,format='dia')))
         matrices.append(('Identity',   spidentity(10**4,format='csr')))
@@ -174,8 +175,9 @@
             MFLOPs = (2*A.nnz*iter/(end-start))/float(1e6)
 
             print fmt % (A.format,name,shape,A.nnz,MFLOPs)
-            
-    def bench_construction(self):
+
+    @dec.bench
+    def test_construction(self):
         """build matrices by inserting single values"""
         matrices = []
         matrices.append( ('Empty',csr_matrix((10000,10000))) )
@@ -210,8 +212,8 @@
 
                 print fmt % (format,name,shape,A.nnz,(end-start)/float(iter))
 
-
-    def bench_conversion(self):
+    @dec.bench
+    def test_conversion(self):
         A = poisson2d(100)
 
         formats = ['csr','csc','coo','lil','dok']

Added: branches/testing_cleanup/scipy/sparse/tests/test_spfuncs.py
===================================================================
--- branches/testing_cleanup/scipy/sparse/tests/test_spfuncs.py	2008-01-08 06:19:19 UTC (rev 3798)
+++ branches/testing_cleanup/scipy/sparse/tests/test_spfuncs.py	2008-01-08 10:16:05 UTC (rev 3799)
@@ -0,0 +1,61 @@
+from numpy import array, kron
+from scipy.testing import *
+
+from scipy.sparse.spfuncs import *
+from scipy.sparse import csr_matrix, csc_matrix
+
+class TestSparseFunctions(TestCase):
+    def test_estimate_blocksize(self):
+
+        mats = []
+        mats.append( [[0,1],[1,0]] )
+        mats.append( [[1,1,0],[0,0,1],[1,0,1]] )
+        mats.append( [[0],[0],[1]] )
+        mats = [array(x) for x in mats]
+    
+        blks = []
+        blks.append( [[1]] )
+        blks.append( [[1,1],[1,1]] )
+        blks.append( [[1,1],[0,1]] )
+        blks.append( [[1,1,0],[1,0,1],[1,1,1]] )
+        blks = [array(x) for x in blks]
+
+        for A in mats:
+            for B in blks:
+                X = kron(A,B)
+                r,c = estimate_blocksize(X)
+                assert(r >= B.shape[0])
+                assert(c >= B.shape[1])
+
+    def test_count_blocks(self):
+        def gold(A,bs):
+            R,C = bs
+            I,J = A.nonzero()
+            return len( set( zip(I/R,J/C) ) )
+        
+        mats = []
+        mats.append( [[0]] ) 
+        mats.append( [[1]] ) 
+        mats.append( [[1,0]] ) 
+        mats.append( [[1,1]] ) 
+        mats.append( [[0,1],[1,0]] )
+        mats.append( [[1,1,0],[0,0,1],[1,0,1]] )
+        mats.append( [[0],[0],[1]] )
+
+        for A in mats:
+            for B in mats:
+                X = kron(A,B)
+                Y = csr_matrix(X)
+                for R in range(1,6):
+                    for C in range(1,6):
+                        assert_equal(count_blocks(Y,(R,C)),gold(X,(R,C)))
+        
+        X = kron([[1,1,0],[0,0,1],[1,0,1]],[[1,1]])
+        Y = csc_matrix(X)
+        assert_equal(count_blocks(X,(1,2)),gold(X,(1,2)))
+        assert_equal(count_blocks(Y,(1,2)),gold(X,(1,2)))
+
+
+if __name__ == "__main__":
+    unittests.main()
+

Modified: branches/testing_cleanup/scipy/stats/info.py
===================================================================
--- branches/testing_cleanup/scipy/stats/info.py	2008-01-08 06:19:19 UTC (rev 3798)
+++ branches/testing_cleanup/scipy/stats/info.py	2008-01-08 10:16:05 UTC (rev 3799)
@@ -198,7 +198,7 @@
 levene    -- _
 shapiro    -- _
 anderson    -- _
-binom_test    -- _
+binom_p    -- _
 fligner    -- _
 mood    -- _
 oneway    -- _

Modified: branches/testing_cleanup/scipy/stats/morestats.py
===================================================================
--- branches/testing_cleanup/scipy/stats/morestats.py	2008-01-08 06:19:19 UTC (rev 3798)
+++ branches/testing_cleanup/scipy/stats/morestats.py	2008-01-08 10:16:05 UTC (rev 3799)
@@ -21,7 +21,7 @@
 __all__ = ['find_repeats',
            'bayes_mvs', 'kstat', 'kstatvar', 'probplot', 'ppcc_max', 'ppcc_plot',
            'boxcox_llf', 'boxcox', 'boxcox_normmax', 'boxcox_normplot',
-           'shapiro', 'anderson', 'ansari', 'bartlett', 'levene', 'binom_test',
+           'shapiro', 'anderson', 'ansari', 'bartlett', 'levene', 'binom_p',
            'fligner', 'mood', 'oneway', 'wilcoxon',
            'pdf_moments', 'pdf_fromgamma', 'pdfapprox',
            'circmean', 'circvar', 'circstd',
@@ -769,7 +769,7 @@
     pval = distributions.f.sf(W,k-1,Ntot-k) # 1 - cdf
     return W, pval
 
-def binom_test(x,n=None,p=0.5):
+def binom_p(x,n=None,p=0.5):
     """An exact (two-sided) test of the null hypothesis that the
     probability of success in a Bernoulli experiment is p.
 

Modified: branches/testing_cleanup/scipy/stats/tests/test_distributions.py
===================================================================
--- branches/testing_cleanup/scipy/stats/tests/test_distributions.py	2008-01-08 06:19:19 UTC (rev 3798)
+++ branches/testing_cleanup/scipy/stats/tests/test_distributions.py	2008-01-08 10:16:05 UTC (rev 3799)
@@ -2,7 +2,6 @@
 
 """
 
-
 from scipy.testing import *
 
 
@@ -10,9 +9,6 @@
 from numpy import typecodes, array
 import scipy.stats as stats
 
-
-import types
-
 def kolmogorov_check(diststr,args=(),N=20,significance=0.01):
     qtest = stats.ksoneisf(significance,N)
     cdf = eval('stats.'+diststr+'.cdf')
@@ -41,9 +37,9 @@
 
 # check function for test generator
 def check_distribution(dist, args, alpha):
-    D,pval = stats.kstest(dist,'',args=args, N=30)
+    D,pval = stats.kstest(dist,'', args=args, N=30)
     if (pval < alpha):
-        D,pval = stats.kstest(dit,'',args=args, N=30)
+        D,pval = stats.kstest(dist,'',args=args, N=30)
         #if (pval < alpha):
         #    D,pval = stats.kstest(dist,'',args=args, N=30)
         assert (pval > alpha), "D = " + str(D) + "; pval = " + str(pval) + \
@@ -69,7 +65,7 @@
             args = tuple(vals)
         else:
             args = tuple(1.0+rand(nargs))
-        yield check_distribution, dist, args, alpha\
+        yield check_distribution, dist, args, alpha
 
 class TestRandInt(TestCase):
     def test_rvs(self):

Modified: branches/testing_cleanup/scipy/stats/tests/test_morestats.py
===================================================================
--- branches/testing_cleanup/scipy/stats/tests/test_morestats.py	2008-01-08 06:19:19 UTC (rev 3798)
+++ branches/testing_cleanup/scipy/stats/tests/test_morestats.py	2008-01-08 10:16:05 UTC (rev 3799)
@@ -94,13 +94,13 @@
         assert_almost_equal(W,1.7059176930008939,7)
         assert_almost_equal(pval,0.0990829755522,7)
 
-class TestBinomTest(TestCase):
+class TestBinomP(TestCase):
     def test_data(self):
-        pval = stats.binom_test(100,250)
+        pval = stats.binom_p(100,250)
         assert_almost_equal(pval,0.0018833009350757682,11)
-        pval = stats.binom_test(201,405)
+        pval = stats.binom_p(201,405)
         assert_almost_equal(pval,0.92085205962670713,11)
-        pval = stats.binom_test([682,243],p=3.0/4)
+        pval = stats.binom_p([682,243],p=3.0/4)
         assert_almost_equal(pval,0.38249155957481695,11)
 
 class TestFindRepeats(TestCase):

Modified: branches/testing_cleanup/scipy/testing/decorators.py
===================================================================
--- branches/testing_cleanup/scipy/testing/decorators.py	2008-01-08 06:19:19 UTC (rev 3798)
+++ branches/testing_cleanup/scipy/testing/decorators.py	2008-01-08 10:16:05 UTC (rev 3799)
@@ -1,8 +1,5 @@
 """Decorators for labeling test objects."""
 
-''' String expression which is true for all undecorated tests '''
-undecorated_def = 'not slow'
-
 def slow(t):
     """Labels a test as 'slow'.
 
@@ -14,3 +11,11 @@
     t.slow = True
     return t
 
+def bench(t):
+    ''' Labels a test as a benchmark.
+
+    Benchmark tests are often slow, and intended to test timings
+    between different algorithms rather than validity of the result. '''
+    
+    t.bench = True
+    return t

Modified: branches/testing_cleanup/scipy/testing/nosetester.py
===================================================================
--- branches/testing_cleanup/scipy/testing/nosetester.py	2008-01-08 06:19:19 UTC (rev 3798)
+++ branches/testing_cleanup/scipy/testing/nosetester.py	2008-01-08 10:16:05 UTC (rev 3799)
@@ -4,10 +4,8 @@
 
 import nose
 
-from scipy.testing.decorators import undecorated_def
-
 class NoseTester(object):
-    """ Scipy nose tests site manager.
+    """ Scipy nose tests suite manager.
 
     Usage: NoseTester(<package>).test()
 
@@ -16,12 +14,11 @@
     def __init__(self, package=None):
         if package is None:
             f = sys._getframe(1)
-            package = f.f_locals.get('__file__',
-                                     f.f_globals.get('__file__',None))
+            package = f.f_locals.get('__file__', None)
             assert package is not None
             self.package_path = os.path.dirname(package)
         else:
-            self._process_package(package)
+            self.package_path = self._process_package(package)
 
     def _process_package(self, package):
         ''' Package can be module, path, or package name '''
@@ -30,11 +27,9 @@
         except AttributeError:
             pass
         else:
-            self.package_path = os.path.dirname(pfile)
-            return
+            return os.path.dirname(pfile)
         if os.path.isabs(package):
-            self.package_path = package
-            return
+            return package
         if package.find(os.path.sep) == -1:
             # Try scipy package name
             import scipy
@@ -50,14 +45,30 @@
         self.package_path = os.path.abspath(package)
         return
 
-    def test(self, labels=None, verbose=0, extra_argv=None):
-        if labels is None:
-            labels = undecorated_def
-        argv = ['', self.package_path, '-s']
-        if labels not in ('', 'all'):
+    def test(self, labels='fast', verbose=1, doctests=False, extra_argv=None):
+        ''' Module testing function
+
+        labels - identifies tests to run.  This can be a string to
+          pass to the nostests executable with the '-a'
+          option, or one of several special values.
+          Special values are:
+          'fast' - the default - which corresponds to
+             nosetests -a option of 'not slow and not bench'.
+          None or '' - run all tests and benchmarks
+
+        verbose - verbosity value 1-10
+        doctests - if True, run doctests in module
+        extra_argv - list with any extra args to pass to nosetest
+        '''
+        argv = ['scipy module test', self.package_path, '-s']
+        if labels:
+            if labels == 'fast':
+                labels = 'not slow and not bench'
             argv += ['-A', labels]
         argv += ['--verbosity', str(verbose)]
-        if extra_argv is not None:
+        if doctests:
+            argv+=['--with-doctest']
+        if extra_argv:
             argv+= extra_argv
         nose.run(argv=argv)
         

Modified: branches/testing_cleanup/scipy/testing/pkgtester.py
===================================================================
--- branches/testing_cleanup/scipy/testing/pkgtester.py	2008-01-08 06:19:19 UTC (rev 3798)
+++ branches/testing_cleanup/scipy/testing/pkgtester.py	2008-01-08 10:16:05 UTC (rev 3799)
@@ -1,7 +1,8 @@
 ''' Define test function for scipy package '''
 try:
     import nose
-    from scipy.testing.nosetester import NoseTester as Tester
 except ImportError:
     from scipy.testing.nulltester import NullTester as Tester
+else:
+    from scipy.testing.nosetester import NoseTester as Tester
 



More information about the Scipy-svn mailing list