[Scipy-svn] r3849 - in trunk/scipy: . fftpack fftpack/benchmarks fftpack/tests linalg linalg/benchmarks linalg/tests optimize optimize/benchmarks optimize/tests sparse sparse/benchmarks stsci/image/lib testing

scipy-svn@scip... scipy-svn@scip...
Fri Jan 18 17:49:12 CST 2008


Author: matthew.brett@gmail.com
Date: 2008-01-18 17:48:52 -0600 (Fri, 18 Jan 2008)
New Revision: 3849

Added:
   trunk/scipy/fftpack/benchmarks/
   trunk/scipy/fftpack/benchmarks/bench_basic.py
   trunk/scipy/fftpack/benchmarks/bench_pseudo_diffs.py
   trunk/scipy/linalg/benchmarks/
   trunk/scipy/linalg/benchmarks/bench_basic.py
   trunk/scipy/linalg/benchmarks/bench_decom.py
   trunk/scipy/optimize/_tstutils.py
   trunk/scipy/optimize/benchmarks/
   trunk/scipy/optimize/benchmarks/bench_zeros.py
   trunk/scipy/sparse/benchmarks/bench_sparse.py
Removed:
   trunk/scipy/sparse/benchmarks/test_sparse.py
Modified:
   trunk/scipy/__init__.py
   trunk/scipy/fftpack/__init__.py
   trunk/scipy/fftpack/tests/test_basic.py
   trunk/scipy/fftpack/tests/test_pseudo_diffs.py
   trunk/scipy/linalg/__init__.py
   trunk/scipy/linalg/tests/test_basic.py
   trunk/scipy/linalg/tests/test_decomp.py
   trunk/scipy/optimize/__init__.py
   trunk/scipy/optimize/tests/test_zeros.py
   trunk/scipy/sparse/__init__.py
   trunk/scipy/stsci/image/lib/_image.py
   trunk/scipy/testing/decorators.py
   trunk/scipy/testing/nosetester.py
Log:
Moved benchmarks over to benchmark directories, added .bench function, cleanup up stsci import

Modified: trunk/scipy/__init__.py
===================================================================
--- trunk/scipy/__init__.py	2008-01-17 15:41:44 UTC (rev 3848)
+++ trunk/scipy/__init__.py	2008-01-18 23:48:52 UTC (rev 3849)
@@ -64,7 +64,7 @@
 
 from testing.pkgtester import Tester
 test = Tester().test
-
+bench = Tester().bench
 __doc__ += """
 
 Utility tools

Modified: trunk/scipy/fftpack/__init__.py
===================================================================
--- trunk/scipy/fftpack/__init__.py	2008-01-17 15:41:44 UTC (rev 3848)
+++ trunk/scipy/fftpack/__init__.py	2008-01-18 23:48:52 UTC (rev 3849)
@@ -19,3 +19,4 @@
 
 from scipy.testing.pkgtester import Tester
 test = Tester().test
+bench = Tester().bench

Added: trunk/scipy/fftpack/benchmarks/bench_basic.py
===================================================================
--- trunk/scipy/fftpack/benchmarks/bench_basic.py	2008-01-17 15:41:44 UTC (rev 3848)
+++ trunk/scipy/fftpack/benchmarks/bench_basic.py	2008-01-18 23:48:52 UTC (rev 3849)
@@ -0,0 +1,220 @@
+""" Test functions for fftpack.basic module
+"""
+import sys
+from scipy.testing import *
+from scipy.fftpack import ifft,fft,fftn,ifftn,rfft,irfft
+from scipy.fftpack import _fftpack as fftpack
+
+from numpy import arange, add, array, asarray, zeros, dot, exp, pi,\
+     swapaxes, double, cdouble
+import numpy.fft
+
+from numpy.random import rand
+def random(size):
+    return rand(*size)
+
+def direct_dft(x):
+    x = asarray(x)
+    n = len(x)
+    y = zeros(n,dtype=cdouble)
+    w = -arange(n)*(2j*pi/n)
+    for i in range(n):
+        y[i] = dot(exp(i*w),x)
+    return y
+
+def direct_idft(x):
+    x = asarray(x)
+    n = len(x)
+    y = zeros(n,dtype=cdouble)
+    w = arange(n)*(2j*pi/n)
+    for i in range(n):
+        y[i] = dot(exp(i*w),x)/n
+    return y
+
+
+class TestFft(TestCase):
+
+    def bench_random(self):
+        from numpy.fft import fft as numpy_fft
+        print
+        print '                 Fast Fourier Transform'
+        print '================================================='
+        print '      |    real input     |   complex input    '
+        print '-------------------------------------------------'
+        print ' size |  scipy  |  numpy  |  scipy  |  numpy '
+        print '-------------------------------------------------'
+        for size,repeat in [(100,7000),(1000,2000),
+                            (256,10000),
+                            (512,10000),
+                            (1024,1000),
+                            (2048,1000),
+                            (2048*2,500),
+                            (2048*4,500),
+                            ]:
+            print '%5s' % size,
+            sys.stdout.flush()
+
+            for x in [random([size]).astype(double),
+                      random([size]).astype(cdouble)+random([size]).astype(cdouble)*1j
+                      ]:
+                if size > 500: y = fft(x)
+                else: y = direct_dft(x)
+                assert_array_almost_equal(fft(x),y)
+                print '|%8.2f' % measure('fft(x)',repeat),
+                sys.stdout.flush()
+
+                assert_array_almost_equal(numpy_fft(x),y)
+                print '|%8.2f' % measure('numpy_fft(x)',repeat),
+                sys.stdout.flush()
+
+            print ' (secs for %s calls)' % (repeat)
+        sys.stdout.flush()
+
+class TestIfft(TestCase):
+
+    def bench_random(self):
+        from numpy.fft import ifft as numpy_ifft
+        print
+        print '       Inverse Fast Fourier Transform'
+        print '==============================================='
+        print '      |     real input    |    complex input   '
+        print '-----------------------------------------------'
+        print ' size |  scipy  |  numpy  |  scipy  |  numpy  '
+        print '-----------------------------------------------'
+        for size,repeat in [(100,7000),(1000,2000),
+                            (256,10000),
+                            (512,10000),
+                            (1024,1000),
+                            (2048,1000),
+                            (2048*2,500),
+                            (2048*4,500),
+                            ]:
+            print '%5s' % size,
+            sys.stdout.flush()
+
+            for x in [random([size]).astype(double),
+                      random([size]).astype(cdouble)+random([size]).astype(cdouble)*1j
+                      ]:
+                if size > 500: y = ifft(x)
+                else: y = direct_idft(x)
+                assert_array_almost_equal(ifft(x),y)
+                print '|%8.2f' % measure('ifft(x)',repeat),
+                sys.stdout.flush()
+
+                assert_array_almost_equal(numpy_ifft(x),y)
+                print '|%8.2f' % measure('numpy_ifft(x)',repeat),
+                sys.stdout.flush()
+
+            print ' (secs for %s calls)' % (repeat)
+        sys.stdout.flush()
+
+class TestRfft(TestCase):
+
+    def bench_random(self):
+        from numpy.fft import rfft as numpy_rfft
+        print
+        print 'Fast Fourier Transform (real data)'
+        print '=================================='
+        print ' size |  scipy  |  numpy  '
+        print '----------------------------------'
+        for size,repeat in [(100,7000),(1000,2000),
+                            (256,10000),
+                            (512,10000),
+                            (1024,1000),
+                            (2048,1000),
+                            (2048*2,500),
+                            (2048*4,500),
+                            ]:
+            print '%5s' % size,
+            sys.stdout.flush()
+
+            x = random([size]).astype(double)
+            print '|%8.2f' % measure('rfft(x)',repeat),
+            sys.stdout.flush()
+
+            print '|%8.2f' % measure('numpy_rfft(x)',repeat),
+            sys.stdout.flush()
+
+            print ' (secs for %s calls)' % (repeat)
+        sys.stdout.flush()
+
+class TestIrfft(TestCase):
+
+    def bench_random(self):
+        from numpy.fft import irfft as numpy_irfft
+
+        print
+        print 'Inverse Fast Fourier Transform (real data)'
+        print '=================================='
+        print ' size |  scipy  |  numpy  '
+        print '----------------------------------'
+        for size,repeat in [(100,7000),(1000,2000),
+                            (256,10000),
+                            (512,10000),
+                            (1024,1000),
+                            (2048,1000),
+                            (2048*2,500),
+                            (2048*4,500),
+                            ]:
+            print '%5s' % size,
+            sys.stdout.flush()
+
+            x = random([size]).astype(double)
+            x1 = zeros(size/2+1,dtype=cdouble)
+            x1[0] = x[0]
+            for i in range(1,size/2):
+                x1[i] = x[2*i-1] + 1j * x[2*i]
+            if not size%2:
+                x1[-1] = x[-1]
+            y = irfft(x)
+
+            print '|%8.2f' % measure('irfft(x)',repeat),
+            sys.stdout.flush()
+
+            assert_array_almost_equal(numpy_irfft(x1,size),y)
+            print '|%8.2f' % measure('numpy_irfft(x1,size)',repeat),
+            sys.stdout.flush()
+
+            print ' (secs for %s calls)' % (repeat)
+
+        sys.stdout.flush()
+
+class TestFftn(TestCase):
+
+    def bench_random(self):
+        from numpy.fft import fftn as numpy_fftn
+        print
+        print '    Multi-dimensional Fast Fourier Transform'
+        print '==================================================='
+        print '          |    real input     |   complex input    '
+        print '---------------------------------------------------'
+        print '   size   |  scipy  |  numpy  |  scipy  |  numpy '
+        print '---------------------------------------------------'
+        for size,repeat in [((100,100),100),((1000,100),7),
+                            ((256,256),10),
+                            ((512,512),3),
+                            ]:
+            print '%9s' % ('%sx%s'%size),
+            sys.stdout.flush()
+
+            for x in [random(size).astype(double),
+                      random(size).astype(cdouble)+random(size).astype(cdouble)*1j
+                      ]:
+                y = fftn(x)
+                #if size > 500: y = fftn(x)
+                #else: y = direct_dft(x)
+                assert_array_almost_equal(fftn(x),y)
+                print '|%8.2f' % measure('fftn(x)',repeat),
+                sys.stdout.flush()
+
+                assert_array_almost_equal(numpy_fftn(x),y)
+                print '|%8.2f' % measure('numpy_fftn(x)',repeat),
+                sys.stdout.flush()
+
+            print ' (secs for %s calls)' % (repeat)
+
+        sys.stdout.flush()
+
+
+if __name__ == "__main__":
+    nose.run(argv=['', __file__])

Added: trunk/scipy/fftpack/benchmarks/bench_pseudo_diffs.py
===================================================================
--- trunk/scipy/fftpack/benchmarks/bench_pseudo_diffs.py	2008-01-17 15:41:44 UTC (rev 3848)
+++ trunk/scipy/fftpack/benchmarks/bench_pseudo_diffs.py	2008-01-18 23:48:52 UTC (rev 3849)
@@ -0,0 +1,186 @@
+""" Benchmark functions for fftpack.pseudo_diffs module
+"""
+import sys
+
+from numpy import arange, add, array, sin, cos, pi,exp,tanh,sum,sign
+
+from scipy.testing import *
+from scipy.fftpack import diff,fft,ifft,tilbert,itilbert,hilbert,ihilbert,rfft
+from scipy.fftpack import shift
+from scipy.fftpack import fftfreq
+
+def random(size):
+    return rand(*size)
+
+def direct_diff(x,k=1,period=None):
+    fx = fft(x)
+    n = len (fx)
+    if period is None:
+        period = 2*pi
+    w = fftfreq(n)*2j*pi/period*n
+    if k<0:
+        w = 1 / w**k
+        w[0] = 0.0
+    else:
+        w = w**k
+    if n>2000:
+        w[250:n-250] = 0.0
+    return ifft(w*fx).real
+
+def direct_tilbert(x,h=1,period=None):
+    fx = fft(x)
+    n = len (fx)
+    if period is None:
+        period = 2*pi
+    w = fftfreq(n)*h*2*pi/period*n
+    w[0] = 1
+    w = 1j/tanh(w)
+    w[0] = 0j
+    return ifft(w*fx)
+
+def direct_hilbert(x):
+    fx = fft(x)
+    n = len (fx)
+    w = fftfreq(n)*n
+    w = 1j*sign(w)
+    return ifft(w*fx)
+
+def direct_shift(x,a,period=None):
+    n = len(x)
+    if period is None:
+        k = fftfreq(n)*1j*n
+    else:
+        k = fftfreq(n)*2j*pi/period*n
+    return ifft(fft(x)*exp(k*a)).real
+
+
+class TestDiff(TestCase):
+
+    def bench_random(self):
+        print
+        print 'Differentiation of periodic functions'
+        print '====================================='
+        print ' size  |  convolve |    naive'
+        print '-------------------------------------'
+        for size,repeat in [(100,1500),(1000,300),
+                            (256,1500),
+                            (512,1000),
+                            (1024,500),
+                            (2048,200),
+                            (2048*2,100),
+                            (2048*4,50),
+                            ]:
+            print '%6s' % size,
+            sys.stdout.flush()
+            x = arange (size)*2*pi/size
+            if size<2000:
+                f = sin(x)*cos(4*x)+exp(sin(3*x))
+            else:
+                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' % measure('diff(f,3)',repeat),
+            sys.stdout.flush()
+            print '| %9.2f' % measure('direct_diff(f,3)',repeat),
+            sys.stdout.flush()
+            print ' (secs for %s calls)' % (repeat)
+
+
+class TestTilbert(TestCase):
+
+    def bench_random(self):
+        print
+        print ' Tilbert transform of periodic functions'
+        print '========================================='
+        print ' size  | optimized |    naive'
+        print '-----------------------------------------'
+        for size,repeat in [(100,1500),(1000,300),
+                            (256,1500),
+                            (512,1000),
+                            (1024,500),
+                            (2048,200),
+                            (2048*2,100),
+                            (2048*4,50),
+                            ]:
+            print '%6s' % size,
+            sys.stdout.flush()
+            x = arange (size)*2*pi/size
+            if size<2000:
+                f = sin(x)*cos(4*x)+exp(sin(3*x))
+            else:
+                f = sin(x)*cos(4*x)
+            assert_array_almost_equal(tilbert(f,1),direct_tilbert(f,1))
+            print '| %9.2f' % measure('tilbert(f,1)',repeat),
+            sys.stdout.flush()
+            print '| %9.2f' % measure('direct_tilbert(f,1)',repeat),
+            sys.stdout.flush()
+            print ' (secs for %s calls)' % (repeat)
+
+
+class TestHilbert(TestCase):
+
+    def bench_random(self):
+        print
+        print ' Hilbert transform of periodic functions'
+        print '========================================='
+        print ' size  | optimized |    naive'
+        print '-----------------------------------------'
+        for size,repeat in [(100,1500),(1000,300),
+                            (256,1500),
+                            (512,1000),
+                            (1024,500),
+                            (2048,200),
+                            (2048*2,100),
+                            (2048*4,50),
+                            ]:
+            print '%6s' % size,
+            sys.stdout.flush()
+            x = arange (size)*2*pi/size
+            if size<2000:
+                f = sin(x)*cos(4*x)+exp(sin(3*x))
+            else:
+                f = sin(x)*cos(4*x)
+            assert_array_almost_equal(hilbert(f),direct_hilbert(f))
+            print '| %9.2f' % measure('hilbert(f)',repeat),
+            sys.stdout.flush()
+            print '| %9.2f' % measure('direct_hilbert(f)',repeat),
+            sys.stdout.flush()
+            print ' (secs for %s calls)' % (repeat)
+
+
+class TestShift(TestCase):
+
+    def bench_random(self):
+        print
+        print ' Shifting periodic functions'
+        print '=============================='
+        print ' size  | optimized |    naive'
+        print '------------------------------'
+        for size,repeat in [(100,1500),(1000,300),
+                            (256,1500),
+                            (512,1000),
+                            (1024,500),
+                            (2048,200),
+                            (2048*2,100),
+                            (2048*4,50),
+                            ]:
+            print '%6s' % size,
+            sys.stdout.flush()
+            x = arange (size)*2*pi/size
+            a = 1
+            if size<2000:
+                f = sin(x)*cos(4*x)+exp(sin(3*x))
+                sf = sin(x+a)*cos(4*(x+a))+exp(sin(3*(x+a)))
+            else:
+                f = sin(x)*cos(4*x)
+                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' % measure('shift(f,a)',repeat),
+            sys.stdout.flush()
+            print '| %9.2f' % measure('direct_shift(f,a)',repeat),
+            sys.stdout.flush()
+            print ' (secs for %s calls)' % (repeat)
+
+if __name__ == "__main__":
+    nose.run(argv=['', __file__])

Modified: trunk/scipy/fftpack/tests/test_basic.py
===================================================================
--- trunk/scipy/fftpack/tests/test_basic.py	2008-01-17 15:41:44 UTC (rev 3848)
+++ trunk/scipy/fftpack/tests/test_basic.py	2008-01-18 23:48:52 UTC (rev 3849)
@@ -124,43 +124,7 @@
             y = fftpack.zrfft(x)
             assert_array_almost_equal(y,y2)
 
-    @dec.bench
-    def test_random(self):
-        from numpy.fft import fft as numpy_fft
-        print
-        print '                 Fast Fourier Transform'
-        print '================================================='
-        print '      |    real input     |   complex input    '
-        print '-------------------------------------------------'
-        print ' size |  scipy  |  numpy  |  scipy  |  numpy '
-        print '-------------------------------------------------'
-        for size,repeat in [(100,7000),(1000,2000),
-                            (256,10000),
-                            (512,10000),
-                            (1024,1000),
-                            (2048,1000),
-                            (2048*2,500),
-                            (2048*4,500),
-                            ]:
-            print '%5s' % size,
-            sys.stdout.flush()
 
-            for x in [random([size]).astype(double),
-                      random([size]).astype(cdouble)+random([size]).astype(cdouble)*1j
-                      ]:
-                if size > 500: y = fft(x)
-                else: y = direct_dft(x)
-                assert_array_almost_equal(fft(x),y)
-                print '|%8.2f' % measure('fft(x)',repeat),
-                sys.stdout.flush()
-
-                assert_array_almost_equal(numpy_fft(x),y)
-                print '|%8.2f' % measure('numpy_fft(x)',repeat),
-                sys.stdout.flush()
-
-            print ' (secs for %s calls)' % (repeat)
-        sys.stdout.flush()
-
 class TestIfft(TestCase):
 
     def test_definition(self):
@@ -200,43 +164,7 @@
             assert_array_almost_equal (ifft(fft(x)),x)
             assert_array_almost_equal (fft(ifft(x)),x)
 
-    @dec.bench
-    def test_random(self):
-        from numpy.fft import ifft as numpy_ifft
-        print
-        print '       Inverse Fast Fourier Transform'
-        print '==============================================='
-        print '      |     real input    |    complex input   '
-        print '-----------------------------------------------'
-        print ' size |  scipy  |  numpy  |  scipy  |  numpy  '
-        print '-----------------------------------------------'
-        for size,repeat in [(100,7000),(1000,2000),
-                            (256,10000),
-                            (512,10000),
-                            (1024,1000),
-                            (2048,1000),
-                            (2048*2,500),
-                            (2048*4,500),
-                            ]:
-            print '%5s' % size,
-            sys.stdout.flush()
 
-            for x in [random([size]).astype(double),
-                      random([size]).astype(cdouble)+random([size]).astype(cdouble)*1j
-                      ]:
-                if size > 500: y = ifft(x)
-                else: y = direct_idft(x)
-                assert_array_almost_equal(ifft(x),y)
-                print '|%8.2f' % measure('ifft(x)',repeat),
-                sys.stdout.flush()
-
-                assert_array_almost_equal(numpy_ifft(x),y)
-                print '|%8.2f' % measure('numpy_ifft(x)',repeat),
-                sys.stdout.flush()
-
-            print ' (secs for %s calls)' % (repeat)
-        sys.stdout.flush()
-
 class TestRfft(TestCase):
 
     def test_definition(self):
@@ -264,35 +192,7 @@
             y = fftpack.drfft(x)
             assert_array_almost_equal(y,y1)
 
-    @dec.bench
-    def test_random(self):
-        from numpy.fft import rfft as numpy_rfft
-        print
-        print 'Fast Fourier Transform (real data)'
-        print '=================================='
-        print ' size |  scipy  |  numpy  '
-        print '----------------------------------'
-        for size,repeat in [(100,7000),(1000,2000),
-                            (256,10000),
-                            (512,10000),
-                            (1024,1000),
-                            (2048,1000),
-                            (2048*2,500),
-                            (2048*4,500),
-                            ]:
-            print '%5s' % size,
-            sys.stdout.flush()
 
-            x = random([size]).astype(double)
-            print '|%8.2f' % measure('rfft(x)',repeat),
-            sys.stdout.flush()
-
-            print '|%8.2f' % measure('numpy_rfft(x)',repeat),
-            sys.stdout.flush()
-
-            print ' (secs for %s calls)' % (repeat)
-        sys.stdout.flush()
-
 class TestIrfft(TestCase):
 
     def test_definition(self):
@@ -330,46 +230,7 @@
             assert_array_almost_equal (irfft(rfft(x)),x)
             assert_array_almost_equal (rfft(irfft(x)),x)
 
-    @dec.bench
-    def test_random(self):
-        from numpy.fft import irfft as numpy_irfft
 
-        print
-        print 'Inverse Fast Fourier Transform (real data)'
-        print '=================================='
-        print ' size |  scipy  |  numpy  '
-        print '----------------------------------'
-        for size,repeat in [(100,7000),(1000,2000),
-                            (256,10000),
-                            (512,10000),
-                            (1024,1000),
-                            (2048,1000),
-                            (2048*2,500),
-                            (2048*4,500),
-                            ]:
-            print '%5s' % size,
-            sys.stdout.flush()
-
-            x = random([size]).astype(double)
-            x1 = zeros(size/2+1,dtype=cdouble)
-            x1[0] = x[0]
-            for i in range(1,size/2):
-                x1[i] = x[2*i-1] + 1j * x[2*i]
-            if not size%2:
-                x1[-1] = x[-1]
-            y = irfft(x)
-
-            print '|%8.2f' % measure('irfft(x)',repeat),
-            sys.stdout.flush()
-
-            assert_array_almost_equal(numpy_irfft(x1,size),y)
-            print '|%8.2f' % measure('numpy_irfft(x1,size)',repeat),
-            sys.stdout.flush()
-
-            print ' (secs for %s calls)' % (repeat)
-
-        sys.stdout.flush()
-
 class TestFftn(TestCase):
 
     def test_definition(self):
@@ -497,41 +358,7 @@
         assert_array_almost_equal (y,swapaxes(\
             fftn(swapaxes(large_x1,-1,-2)),-1,-2))
 
-    @dec.bench
-    def test_random(self):
-        from numpy.fft import fftn as numpy_fftn
-        print
-        print '    Multi-dimensional Fast Fourier Transform'
-        print '==================================================='
-        print '          |    real input     |   complex input    '
-        print '---------------------------------------------------'
-        print '   size   |  scipy  |  numpy  |  scipy  |  numpy '
-        print '---------------------------------------------------'
-        for size,repeat in [((100,100),100),((1000,100),7),
-                            ((256,256),10),
-                            ((512,512),3),
-                            ]:
-            print '%9s' % ('%sx%s'%size),
-            sys.stdout.flush()
 
-            for x in [random(size).astype(double),
-                      random(size).astype(cdouble)+random(size).astype(cdouble)*1j
-                      ]:
-                y = fftn(x)
-                #if size > 500: y = fftn(x)
-                #else: y = direct_dft(x)
-                assert_array_almost_equal(fftn(x),y)
-                print '|%8.2f' % measure('fftn(x)',repeat),
-                sys.stdout.flush()
-
-                assert_array_almost_equal(numpy_fftn(x),y)
-                print '|%8.2f' % measure('numpy_fftn(x)',repeat),
-                sys.stdout.flush()
-
-            print ' (secs for %s calls)' % (repeat)
-
-        sys.stdout.flush()
-
 class TestIfftn(TestCase):
 
     def test_definition(self):

Modified: trunk/scipy/fftpack/tests/test_pseudo_diffs.py
===================================================================
--- trunk/scipy/fftpack/tests/test_pseudo_diffs.py	2008-01-17 15:41:44 UTC (rev 3848)
+++ trunk/scipy/fftpack/tests/test_pseudo_diffs.py	2008-01-18 23:48:52 UTC (rev 3849)
@@ -184,37 +184,7 @@
                 assert_array_almost_equal(diff(diff(f,k),-k),f)
                 assert_array_almost_equal(diff(diff(f,-k),k),f)
 
-    @dec.bench
-    def test_random(self):
-        print
-        print 'Differentiation of periodic functions'
-        print '====================================='
-        print ' size  |  convolve |    naive'
-        print '-------------------------------------'
-        for size,repeat in [(100,1500),(1000,300),
-                            (256,1500),
-                            (512,1000),
-                            (1024,500),
-                            (2048,200),
-                            (2048*2,100),
-                            (2048*4,50),
-                            ]:
-            print '%6s' % size,
-            sys.stdout.flush()
-            x = arange (size)*2*pi/size
-            if size<2000:
-                f = sin(x)*cos(4*x)+exp(sin(3*x))
-            else:
-                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' % measure('diff(f,3)',repeat),
-            sys.stdout.flush()
-            print '| %9.2f' % measure('direct_diff(f,3)',repeat),
-            sys.stdout.flush()
-            print ' (secs for %s calls)' % (repeat)
 
-
 class TestTilbert(TestCase):
 
     def test_definition(self):
@@ -248,34 +218,6 @@
                 assert_array_almost_equal(itilbert(tilbert(f,h),h),f)
                 assert_array_almost_equal(tilbert(itilbert(f,h),h),f)
 
-    @dec.bench
-    def test_random(self):
-        print
-        print ' Tilbert transform of periodic functions'
-        print '========================================='
-        print ' size  | optimized |    naive'
-        print '-----------------------------------------'
-        for size,repeat in [(100,1500),(1000,300),
-                            (256,1500),
-                            (512,1000),
-                            (1024,500),
-                            (2048,200),
-                            (2048*2,100),
-                            (2048*4,50),
-                            ]:
-            print '%6s' % size,
-            sys.stdout.flush()
-            x = arange (size)*2*pi/size
-            if size<2000:
-                f = sin(x)*cos(4*x)+exp(sin(3*x))
-            else:
-                f = sin(x)*cos(4*x)
-            assert_array_almost_equal(tilbert(f,1),direct_tilbert(f,1))
-            print '| %9.2f' % measure('tilbert(f,1)',repeat),
-            sys.stdout.flush()
-            print '| %9.2f' % measure('direct_tilbert(f,1)',repeat),
-            sys.stdout.flush()
-            print ' (secs for %s calls)' % (repeat)
 
 class TestITilbert(TestCase):
 
@@ -332,34 +274,6 @@
             assert_array_almost_equal(direct_hilbert(direct_ihilbert(f)),f)
             assert_array_almost_equal(hilbert(ihilbert(f)),f)
 
-    @dec.bench
-    def test_random(self):
-        print
-        print ' Hilbert transform of periodic functions'
-        print '========================================='
-        print ' size  | optimized |    naive'
-        print '-----------------------------------------'
-        for size,repeat in [(100,1500),(1000,300),
-                            (256,1500),
-                            (512,1000),
-                            (1024,500),
-                            (2048,200),
-                            (2048*2,100),
-                            (2048*4,50),
-                            ]:
-            print '%6s' % size,
-            sys.stdout.flush()
-            x = arange (size)*2*pi/size
-            if size<2000:
-                f = sin(x)*cos(4*x)+exp(sin(3*x))
-            else:
-                f = sin(x)*cos(4*x)
-            assert_array_almost_equal(hilbert(f),direct_hilbert(f))
-            print '| %9.2f' % measure('hilbert(f)',repeat),
-            sys.stdout.flush()
-            print '| %9.2f' % measure('direct_hilbert(f)',repeat),
-            sys.stdout.flush()
-            print ' (secs for %s calls)' % (repeat)
 
 class TestIHilbert(TestCase):
 
@@ -398,38 +312,6 @@
             assert_array_almost_equal(shift(sin(x),pi),-sin(x))
             assert_array_almost_equal(shift(sin(x),pi/2),cos(x))
 
-    @dec.bench
-    def test_random(self):
-        print
-        print ' Shifting periodic functions'
-        print '=============================='
-        print ' size  | optimized |    naive'
-        print '------------------------------'
-        for size,repeat in [(100,1500),(1000,300),
-                            (256,1500),
-                            (512,1000),
-                            (1024,500),
-                            (2048,200),
-                            (2048*2,100),
-                            (2048*4,50),
-                            ]:
-            print '%6s' % size,
-            sys.stdout.flush()
-            x = arange (size)*2*pi/size
-            a = 1
-            if size<2000:
-                f = sin(x)*cos(4*x)+exp(sin(3*x))
-                sf = sin(x+a)*cos(4*(x+a))+exp(sin(3*(x+a)))
-            else:
-                f = sin(x)*cos(4*x)
-                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' % measure('shift(f,a)',repeat),
-            sys.stdout.flush()
-            print '| %9.2f' % measure('direct_shift(f,a)',repeat),
-            sys.stdout.flush()
-            print ' (secs for %s calls)' % (repeat)
 
 if __name__ == "__main__":
     nose.run(argv=['', __file__])

Modified: trunk/scipy/linalg/__init__.py
===================================================================
--- trunk/scipy/linalg/__init__.py	2008-01-17 15:41:44 UTC (rev 3848)
+++ trunk/scipy/linalg/__init__.py	2008-01-18 23:48:52 UTC (rev 3849)
@@ -30,3 +30,4 @@
 
 from scipy.testing.pkgtester import Tester
 test = Tester().test
+bench = Tester().bench

Added: trunk/scipy/linalg/benchmarks/bench_basic.py
===================================================================
--- trunk/scipy/linalg/benchmarks/bench_basic.py	2008-01-17 15:41:44 UTC (rev 3848)
+++ trunk/scipy/linalg/benchmarks/bench_basic.py	2008-01-18 23:48:52 UTC (rev 3849)
@@ -0,0 +1,130 @@
+import sys
+import numpy
+from numpy import arange, add, array, dot, zeros, identity, conjugate, transpose
+
+from scipy.testing import *
+
+from scipy.linalg import solve,inv,det,lstsq, toeplitz, hankel, tri, triu, \
+     tril, pinv, pinv2, solve_banded
+
+def random(size):
+    return rand(*size)
+
+class TestSolve(TestCase):
+
+    def bench_random(self):
+        import numpy.linalg as linalg
+        basic_solve = linalg.solve
+        print
+        print '      Solving system of linear equations'
+        print '      =================================='
+
+        print '      |    contiguous     |   non-contiguous '
+        print '----------------------------------------------'
+        print ' size |  scipy  | basic   |  scipy  | basic '
+
+        for size,repeat in [(20,1000),(100,150),(500,2),(1000,1)][:-1]:
+            repeat *= 2
+            print '%5s' % size,
+            sys.stdout.flush()
+
+            a = random([size,size])
+            # larger diagonal ensures non-singularity:
+            for i in range(size): a[i,i] = 10*(.1+a[i,i])
+            b = random([size])
+
+            print '| %6.2f ' % measure('solve(a,b)',repeat),
+            sys.stdout.flush()
+
+            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 ' % measure('solve(a,b)',repeat),
+            sys.stdout.flush()
+
+            print '| %6.2f ' % measure('basic_solve(a,b)',repeat),
+            sys.stdout.flush()
+
+            print '   (secs for %s calls)' % (repeat)
+
+class TestInv(TestCase):
+
+    def bench_random(self):
+        import numpy.linalg as linalg
+        basic_inv = linalg.inv
+        print
+        print '           Finding matrix inverse'
+        print '      =================================='
+        print '      |    contiguous     |   non-contiguous '
+        print '----------------------------------------------'
+        print ' size |  scipy  | basic   |  scipy  | basic'
+
+        for size,repeat in [(20,1000),(100,150),(500,2),(1000,1)][:-1]:
+            repeat *= 2
+            print '%5s' % size,
+            sys.stdout.flush()
+
+            a = random([size,size])
+            # large diagonal ensures non-singularity:
+            for i in range(size): a[i,i] = 10*(.1+a[i,i])
+
+            print '| %6.2f ' % measure('inv(a)',repeat),
+            sys.stdout.flush()
+
+            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 ' % measure('inv(a)',repeat),
+            sys.stdout.flush()
+
+            print '| %6.2f ' % measure('basic_inv(a)',repeat),
+            sys.stdout.flush()
+
+            print '   (secs for %s calls)' % (repeat)
+
+
+class TestDet(TestCase):
+
+    def bench_random(self):
+        import numpy.linalg as linalg
+        basic_det = linalg.det
+        print
+        print '           Finding matrix determinant'
+        print '      =================================='
+        print '      |    contiguous     |   non-contiguous '
+        print '----------------------------------------------'
+        print ' size |  scipy  | basic   |  scipy  | basic '
+
+        for size,repeat in [(20,1000),(100,150),(500,2),(1000,1)][:-1]:
+            repeat *= 2
+            print '%5s' % size,
+            sys.stdout.flush()
+
+            a = random([size,size])
+
+            print '| %6.2f ' % measure('det(a)',repeat),
+            sys.stdout.flush()
+
+            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 ' % measure('det(a)',repeat),
+            sys.stdout.flush()
+
+            print '| %6.2f ' % measure('basic_det(a)',repeat),
+            sys.stdout.flush()
+
+            print '   (secs for %s calls)' % (repeat)
+
+
+if __name__ == "__main__":
+    nose.run(argv=['', __file__])

Added: trunk/scipy/linalg/benchmarks/bench_decom.py
===================================================================
--- trunk/scipy/linalg/benchmarks/bench_decom.py	2008-01-17 15:41:44 UTC (rev 3848)
+++ trunk/scipy/linalg/benchmarks/bench_decom.py	2008-01-18 23:48:52 UTC (rev 3849)
@@ -0,0 +1,35 @@
+""" Benchmark functions for linalg.decomp module
+
+"""
+import sys
+
+import numpy
+from numpy import linalg
+from scipy.linalg import eigvals
+
+from scipy.testing import *
+
+def random(size):
+    return rand(*size)
+
+def bench_random():
+    Numeric_eigvals = linalg.eigvals
+    print
+    print '           Finding matrix eigenvalues'
+    print '      =================================='
+    print '      |    contiguous     '#'|   non-contiguous '
+    print '----------------------------------------------'
+    print ' size |  scipy  '#'| core |  scipy  | core '
+    
+    for size,repeat in [(20,150),(100,7),(200,2)]:
+        repeat *= 1
+        print '%5s' % size,
+        sys.stdout.flush()
+        
+        a = random([size,size])
+        
+        print '| %6.2f ' % measure('eigvals(a)',repeat),
+        sys.stdout.flush()
+        
+        print '   (secs for %s calls)' % (repeat)
+

Modified: trunk/scipy/linalg/tests/test_basic.py
===================================================================
--- trunk/scipy/linalg/tests/test_basic.py	2008-01-17 15:41:44 UTC (rev 3848)
+++ trunk/scipy/linalg/tests/test_basic.py	2008-01-18 23:48:52 UTC (rev 3849)
@@ -153,45 +153,7 @@
             x = solve(a,b,sym_pos=1)
             assert_array_almost_equal(numpy.dot(a,x),b)
 
-    @dec.bench
-    def test_bench_random(self):
-        import numpy.linalg as linalg
-        basic_solve = linalg.solve
-        print
-        print '      Solving system of linear equations'
-        print '      =================================='
 
-        print '      |    contiguous     |   non-contiguous '
-        print '----------------------------------------------'
-        print ' size |  scipy  | basic   |  scipy  | basic '
-
-        for size,repeat in [(20,1000),(100,150),(500,2),(1000,1)][:-1]:
-            repeat *= 2
-            print '%5s' % size,
-            sys.stdout.flush()
-
-            a = random([size,size])
-            # larger diagonal ensures non-singularity:
-            for i in range(size): a[i,i] = 10*(.1+a[i,i])
-            b = random([size])
-
-            print '| %6.2f ' % measure('solve(a,b)',repeat),
-            sys.stdout.flush()
-
-            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 ' % measure('solve(a,b)',repeat),
-            sys.stdout.flush()
-
-            print '| %6.2f ' % measure('basic_solve(a,b)',repeat),
-            sys.stdout.flush()
-
-            print '   (secs for %s calls)' % (repeat)
-
 class TestInv(TestCase):
 
     def test_simple(self):
@@ -227,44 +189,7 @@
             assert_array_almost_equal(numpy.dot(a,a_inv),
                                       numpy.identity(n))
 
-    @dec.bench
-    def test_bench_random(self):
-        import numpy.linalg as linalg
-        basic_inv = linalg.inv
-        print
-        print '           Finding matrix inverse'
-        print '      =================================='
-        print '      |    contiguous     |   non-contiguous '
-        print '----------------------------------------------'
-        print ' size |  scipy  | basic   |  scipy  | basic'
 
-        for size,repeat in [(20,1000),(100,150),(500,2),(1000,1)][:-1]:
-            repeat *= 2
-            print '%5s' % size,
-            sys.stdout.flush()
-
-            a = random([size,size])
-            # large diagonal ensures non-singularity:
-            for i in range(size): a[i,i] = 10*(.1+a[i,i])
-
-            print '| %6.2f ' % measure('inv(a)',repeat),
-            sys.stdout.flush()
-
-            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 ' % measure('inv(a)',repeat),
-            sys.stdout.flush()
-
-            print '| %6.2f ' % measure('basic_inv(a)',repeat),
-            sys.stdout.flush()
-
-            print '   (secs for %s calls)' % (repeat)
-
-
 class TestDet(TestCase):
 
     def test_simple(self):
@@ -297,42 +222,7 @@
             d2 = basic_det(a)
             assert_almost_equal(d1,d2)
 
-    @dec.bench
-    def test_bench_random(self):
-        import numpy.linalg as linalg
-        basic_det = linalg.det
-        print
-        print '           Finding matrix determinant'
-        print '      =================================='
-        print '      |    contiguous     |   non-contiguous '
-        print '----------------------------------------------'
-        print ' size |  scipy  | basic   |  scipy  | basic '
 
-        for size,repeat in [(20,1000),(100,150),(500,2),(1000,1)][:-1]:
-            repeat *= 2
-            print '%5s' % size,
-            sys.stdout.flush()
-
-            a = random([size,size])
-
-            print '| %6.2f ' % measure('det(a)',repeat),
-            sys.stdout.flush()
-
-            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 ' % measure('det(a)',repeat),
-            sys.stdout.flush()
-
-            print '| %6.2f ' % measure('basic_det(a)',repeat),
-            sys.stdout.flush()
-
-            print '   (secs for %s calls)' % (repeat)
-
-
 def direct_lstsq(a,b,cmplx=0):
     at = transpose(a)
     if cmplx:

Modified: trunk/scipy/linalg/tests/test_decomp.py
===================================================================
--- trunk/scipy/linalg/tests/test_decomp.py	2008-01-17 15:41:44 UTC (rev 3848)
+++ trunk/scipy/linalg/tests/test_decomp.py	2008-01-18 23:48:52 UTC (rev 3849)
@@ -17,7 +17,6 @@
 import sys
 from scipy.testing import *
 
-
 from scipy.linalg import eig,eigvals,lu,svd,svdvals,cholesky,qr, \
      schur,rsf2csf, lu_solve,lu_factor,solve,diagsvd,hessenberg,rq, \
      eig_banded, eigvals_banded
@@ -27,7 +26,7 @@
 from numpy import array, transpose, sometrue, diag, ones, linalg, \
      argsort, zeros, arange, float32, complex64, dot, conj, identity, \
      ravel, sqrt, iscomplex, shape, sort, sign, conjugate, sign, bmat, \
-     asarray, matrix, isfinite
+     asarray, matrix, isfinite, all
 
 
 from numpy.random import rand
@@ -59,29 +58,7 @@
                    (9+1j-sqrt(92+6j))/2]
         assert_array_almost_equal(w,exact_w)
 
-    @dec.bench
-    def test_bench_random(self):
-        import numpy.linalg as linalg
-        Numeric_eigvals = linalg.eigvals
-        print
-        print '           Finding matrix eigenvalues'
-        print '      =================================='
-        print '      |    contiguous     '#'|   non-contiguous '
-        print '----------------------------------------------'
-        print ' size |  scipy  '#'| core |  scipy  | core '
 
-        for size,repeat in [(20,150),(100,7),(200,2)]:
-            repeat *= 1
-            print '%5s' % size,
-            sys.stdout.flush()
-
-            a = random([size,size])
-
-            print '| %6.2f ' % measure('eigvals(a)',repeat),
-            sys.stdout.flush()
-
-            print '   (secs for %s calls)' % (repeat)
-
 class TestEig(TestCase):
 
     def test_simple(self):

Modified: trunk/scipy/optimize/__init__.py
===================================================================
--- trunk/scipy/optimize/__init__.py	2008-01-17 15:41:44 UTC (rev 3848)
+++ trunk/scipy/optimize/__init__.py	2008-01-18 23:48:52 UTC (rev 3849)
@@ -18,3 +18,4 @@
 __all__ = filter(lambda s:not s.startswith('_'),dir())
 from scipy.testing.pkgtester import Tester
 test = Tester().test
+bench = Tester().bench

Added: trunk/scipy/optimize/_tstutils.py
===================================================================
--- trunk/scipy/optimize/_tstutils.py	2008-01-17 15:41:44 UTC (rev 3848)
+++ trunk/scipy/optimize/_tstutils.py	2008-01-18 23:48:52 UTC (rev 3849)
@@ -0,0 +1,47 @@
+''' Parameters used in test and benchmark methods '''
+
+from random import random
+
+from scipy.optimize import zeros as cc
+
+def f1(x) :
+    return x*(x-1.)
+
+def f2(x) :
+    return x**2 - 1
+
+def f3(x) :
+    return x*(x-1.)*(x-2.)*(x-3.)
+
+def f4(x) :
+    if x > 1 : return  1.0 + .1*x
+    if x < 1 : return -1.0 + .1*x
+    return 0
+
+def f5(x) :
+    if x != 1 : return 1.0/(1. - x)
+    return 0
+
+def f6(x) :
+    if   x > 1 : return random()
+    elif x < 1 : return -random()
+    else : return 0
+
+description = """
+f2 is a symmetric parabola, x**2 - 1
+f3 is a quartic polynomial with large hump in interval
+f4 is step function with a discontinuity at 1
+f5 is a hyperbola with vertical asymptote at 1
+f6 has random values positive to left of 1, negative to right
+
+of course these are not real problems. They just test how the
+'good' solvers behave in bad circumstances where bisection is
+really the best. A good solver should not be much worse than
+bisection in such circumstance, while being faster for smooth
+monotone sorts of functions.
+"""
+
+methods = [cc.bisect,cc.ridder,cc.brenth,cc.brentq]
+mstrings = ['cc.bisect','cc.ridder','cc.brenth','cc.brentq']
+functions = [f2,f3,f4,f5,f6]
+fstrings = ['f2','f3','f4','f5','f6']

Added: trunk/scipy/optimize/benchmarks/bench_zeros.py
===================================================================
--- trunk/scipy/optimize/benchmarks/bench_zeros.py	2008-01-17 15:41:44 UTC (rev 3848)
+++ trunk/scipy/optimize/benchmarks/bench_zeros.py	2008-01-18 23:48:52 UTC (rev 3849)
@@ -0,0 +1,35 @@
+from math import sqrt
+
+from scipy.testing import *
+
+from scipy.optimize import zeros as cc
+
+# Import testing parameters
+from scipy.optimize._tstutils import methods, mstrings, functions, \
+     fstrings, description
+
+class BenchZeros(TestCase):
+    def bench_run(self):
+        a = .5
+        b = sqrt(3)
+        repeat = 2000
+
+        print description
+
+        print 'TESTING SPEED\n'
+        print 'times in seconds for %d iterations \n'%repeat
+        for i in range(len(functions)) :
+            print 'function %s\n'%fstrings[i]
+            func = functions[i]
+            for j in range(len(methods)) :
+                meth = methods[j]
+                try:
+                    t = measure("meth(func,a,b)",repeat)
+                except:
+                    print '%s : failed'%mstrings[j]
+                else:
+                    print '%s : %5.3f'%(mstrings[j],t)
+            print '\n\n'
+
+if __name__ == '__main__' :
+    nose.run(argv=['', __file__])

Modified: trunk/scipy/optimize/tests/test_zeros.py
===================================================================
--- trunk/scipy/optimize/tests/test_zeros.py	2008-01-17 15:41:44 UTC (rev 3848)
+++ trunk/scipy/optimize/tests/test_zeros.py	2008-01-18 23:48:52 UTC (rev 3849)
@@ -1,55 +1,15 @@
 #!/usr/bin/env python
 
+from math import sqrt
 
 from scipy.testing import *
 
 from scipy.optimize import zeros as cc
 
-from math import sin,sqrt,log
-from random import random
+# Import testing parameters
+from scipy.optimize._tstutils import methods, mstrings, functions, \
+     fstrings, description
 
-def f1(x) :
-    return x*(x-1.)
-
-def f2(x) :
-    return x**2 - 1
-
-def f3(x) :
-    return x*(x-1.)*(x-2.)*(x-3.)
-
-def f4(x) :
-    if x > 1 : return  1.0 + .1*x
-    if x < 1 : return -1.0 + .1*x
-    return 0
-
-def f5(x) :
-    if x != 1 : return 1.0/(1. - x)
-    return 0
-
-def f6(x) :
-    if   x > 1 : return random()
-    elif x < 1 : return -random()
-    else : return 0
-
-description = """
-f2 is a symmetric parabola, x**2 - 1
-f3 is a quartic polynomial with large hump in interval
-f4 is step function with a discontinuity at 1
-f5 is a hyperbola with vertical asymptote at 1
-f6 has random values positive to left of 1, negative to right
-
-of course these are not real problems. They just test how the
-'good' solvers behave in bad circumstances where bisection is
-really the best. A good solver should not be much worse than
-bisection in such circumstance, while being faster for smooth
-monotone sorts of functions.
-"""
-
-methods = [cc.bisect,cc.ridder,cc.brenth,cc.brentq]
-mstrings = ['cc.bisect','cc.ridder','cc.brenth','cc.brentq']
-functions = [f2,f3,f4,f5,f6]
-fstrings = ['f2','f3','f4','f5','f6']
-
 class TestBasic(TestCase) :
     def run_check(self, method, name):
         a = .5
@@ -69,28 +29,6 @@
     def test_brenth(self):
         self.run_check(cc.brenth, 'brenth')
 
-    @dec.bench
-    def test_run(self):
-        a = .5
-        b = sqrt(3)
-        repeat = 2000
 
-        print description
-
-        print 'TESTING SPEED\n'
-        print 'times in seconds for %d iterations \n'%repeat
-        for i in range(len(functions)) :
-            print 'function %s\n'%fstrings[i]
-            func = functions[i]
-            for j in range(len(methods)) :
-                meth = methods[j]
-                try:
-                    t = measure("meth(func,a,b)",repeat)
-                except:
-                    print '%s : failed'%mstrings[j]
-                else:
-                    print '%s : %5.3f'%(mstrings[j],t)
-            print '\n\n'
-
 if __name__ == '__main__' :
     nose.run(argv=['', __file__])

Modified: trunk/scipy/sparse/__init__.py
===================================================================
--- trunk/scipy/sparse/__init__.py	2008-01-17 15:41:44 UTC (rev 3848)
+++ trunk/scipy/sparse/__init__.py	2008-01-18 23:48:52 UTC (rev 3849)
@@ -17,3 +17,4 @@
 __all__ = filter(lambda s:not s.startswith('_'),dir())
 from scipy.testing.pkgtester import Tester
 test = Tester().test
+bench = Tester().bench

Copied: trunk/scipy/sparse/benchmarks/bench_sparse.py (from rev 3848, trunk/scipy/sparse/benchmarks/test_sparse.py)
===================================================================
--- trunk/scipy/sparse/benchmarks/test_sparse.py	2008-01-17 15:41:44 UTC (rev 3848)
+++ trunk/scipy/sparse/benchmarks/bench_sparse.py	2008-01-18 23:48:52 UTC (rev 3849)
@@ -0,0 +1,281 @@
+"""general tests and simple benchmarks for the sparse module"""
+
+import numpy
+from numpy import ones, array, asarray, empty
+
+import random
+from scipy.testing import *
+
+from scipy.sparse import csc_matrix, csr_matrix, dok_matrix, \
+        coo_matrix, lil_matrix, dia_matrix, spidentity, spdiags, \
+        spkron
+from scipy.linsolve import splu
+
+
+def random_sparse(m,n,nnz_per_row):
+    rows = numpy.arange(m).repeat(nnz_per_row)
+    cols = numpy.random.random_integers(low=0,high=n-1,size=nnz_per_row*m)
+    vals = numpy.random.random_sample(m*nnz_per_row)
+    return coo_matrix((vals,(rows,cols)),(m,n)).tocsr()
+
+
+#TODO move this to a matrix gallery and add unittests
+def poisson2d(N,dtype='d',format=None):
+    """
+    Return a sparse matrix for the 2d poisson problem
+    with standard 5-point finite difference stencil on a
+    square N-by-N grid.
+    """
+    if N == 1:
+        diags   = asarray( [[4]],dtype=dtype)
+        return dia_matrix((diags,[0]), shape=(1,1)).asformat(format)
+
+    offsets = array([0,-N,N,-1,1])
+
+    diags = empty((5,N**2),dtype=dtype)
+
+    diags[0]  =  4 #main diagonal
+    diags[1:] = -1 #all offdiagonals
+
+    diags[3,N-1::N] = 0  #first lower diagonal
+    diags[4,N::N] = 0  #first upper diagonal
+
+    return dia_matrix((diags,offsets),shape=(N**2,N**2)).asformat(format)
+
+import time
+class TestSparseTools(TestCase):
+    """Simple benchmarks for sparse matrix module"""
+
+    def bench_arithmetic(self):
+        matrices = []
+        #matrices.append( ('A','Identity', spidentity(500**2,format='csr')) )
+        matrices.append( ('A','Poisson5pt', poisson2d(500,format='csr'))  )
+        matrices.append( ('B','Poisson5pt^2', poisson2d(500,format='csr')**2)  )
+   
+        print
+        print '                 Sparse Matrix Arithmetic'
+        print '===================================================================='
+        print ' var |     name       |         shape        |   dtype   |    nnz   '
+        print '--------------------------------------------------------------------'
+        fmt = '  %1s  | %14s | %20s | %9s | %8d '
+
+        for var,name,mat in matrices:
+            name  = name.center(14)
+            shape = ("%s" % (mat.shape,)).center(20)
+            dtype = mat.dtype.name.center(9)
+            print fmt % (var,name,shape,dtype,mat.nnz)
+
+        space = ' ' * 10 
+        print
+        print space+'              Timings'
+        print space+'=========================================='
+        print space+' format |     operation     | time (msec) '
+        print space+'------------------------------------------'
+        fmt = space+'   %3s  | %17s |  %7.1f  '
+
+        for format in ['csr']:
+            vars = dict( [(var,mat.asformat(format)) for (var,name,mat) in matrices ] )
+            for X,Y in [ ('A','A'),('A','B'),('B','A'),('B','B') ]:
+                x,y = vars[X],vars[Y]
+                for op in ['__add__','__sub__','multiply','__div__','__mul__']:
+                    fn = getattr(x,op)
+                    fn(y) #warmup
+
+                    start = time.clock()
+                    iter = 0
+                    while iter < 5 or time.clock() < start + 1:
+                        fn(y)
+                        iter += 1
+                    end = time.clock()
+
+                    msec_per_it = 1000*(end - start)/float(iter)
+                    operation = (X + '.' + op + '(' + Y + ')').center(17)
+                    print fmt % (format,operation,msec_per_it)
+
+  
+    def bench_sort(self):
+        """sort CSR column indices"""
+        matrices = []
+        matrices.append( ('Rand10',  1e4,  10) )
+        matrices.append( ('Rand25',  1e4,  25) )
+        matrices.append( ('Rand50',  1e4,  50) )
+        matrices.append( ('Rand100', 1e4, 100) )
+        matrices.append( ('Rand200', 1e4, 200) )
+
+        print
+        print '                    Sparse Matrix Index Sorting'
+        print '====================================================================='
+        print ' type |    name      |         shape        |    nnz   | time (msec) '
+        print '---------------------------------------------------------------------'
+        fmt = '  %3s | %12s | %20s | %8d |   %6.2f  '
+
+        for name,N,K in matrices:
+            N = int(N) 
+            A = random_sparse(N,N,K)
+            
+            start = time.clock()
+            iter = 0
+            while iter < 5 and time.clock() - start < 1:
+                A._has_sorted_indices = False
+                A.sort_indices() 
+                iter += 1
+            end = time.clock()
+
+            name = name.center(12)
+            shape = ("%s" % (A.shape,)).center(20)
+
+            print fmt % (A.format,name,shape,A.nnz,1e3*(end-start)/float(iter) )
+
+    def bench_matvec(self):
+        matrices = []
+        matrices.append(('Identity',   spidentity(10**4,format='dia')))
+        matrices.append(('Identity',   spidentity(10**4,format='csr')))
+        matrices.append(('Poisson5pt', poisson2d(300,format='dia')))
+        matrices.append(('Poisson5pt', poisson2d(300,format='csr')))
+        matrices.append(('Poisson5pt', poisson2d(300,format='bsr')))
+
+        A = spkron(poisson2d(150),ones((2,2))).tobsr(blocksize=(2,2))
+        matrices.append( ('Block2x2', A.tocsr()) )
+        matrices.append( ('Block2x2', A) )
+        
+        A = spkron(poisson2d(100),ones((3,3))).tobsr(blocksize=(3,3))
+        matrices.append( ('Block3x3', A.tocsr()) )
+        matrices.append( ('Block3x3', A) )
+
+        print
+        print '                 Sparse Matrix Vector Product'
+        print '=================================================================='
+        print ' type |    name      |         shape        |    nnz   |  MFLOPs  '
+        print '------------------------------------------------------------------'
+        fmt = '  %3s | %12s | %20s | %8d |  %6.1f '
+
+        for name,A in matrices:
+            x = ones(A.shape[1],dtype=A.dtype)
+
+            y = A*x  #warmup
+
+            start = time.clock()
+            iter = 0
+            while iter < 5 or time.clock() < start + 1:
+                try:
+                    #avoid creating y if possible
+                    A.matvec(x,y)
+                except:
+                    y = A*x
+                iter += 1
+            end = time.clock()
+
+            del y
+
+            name = name.center(12)
+            shape = ("%s" % (A.shape,)).center(20)
+            MFLOPs = (2*A.nnz*iter/(end-start))/float(1e6)
+
+            print fmt % (A.format,name,shape,A.nnz,MFLOPs)
+            
+    def bench_construction(self):
+        """build matrices by inserting single values"""
+        matrices = []
+        matrices.append( ('Empty',csr_matrix((10000,10000))) )
+        matrices.append( ('Identity',spidentity(10000)) )
+        matrices.append( ('Poisson5pt', poisson2d(100)) )
+        
+        print
+        print '                    Sparse Matrix Construction'
+        print '===================================================================='
+        print ' type |    name      |         shape        |    nnz   | time (sec) '
+        print '--------------------------------------------------------------------'
+        fmt = '  %3s | %12s | %20s | %8d |   %6.4f '
+
+        for name,A in matrices:
+            A = A.tocoo()
+             
+            for format in ['lil','dok']: 
+
+                start = time.clock()
+                
+                iter = 0
+                while time.clock() < start + 0.5:
+                    T = eval(format + '_matrix')(A.shape)
+                    for i,j,v in zip(A.row,A.col,A.data):
+                        T[i,j] = v
+                    iter += 1
+                end = time.clock()
+
+                del T
+                name = name.center(12)
+                shape = ("%s" % (A.shape,)).center(20)
+
+                print fmt % (format,name,shape,A.nnz,(end-start)/float(iter))
+
+    def bench_conversion(self):
+        A = poisson2d(100)
+
+        formats = ['csr','csc','coo','lil','dok']
+       
+        print
+        print '                Sparse Matrix Conversion'
+        print '=========================================================='
+        print ' format | tocsr() | tocsc() | tocoo() | tolil() | todok() '
+        print '----------------------------------------------------------'
+        
+        for fromfmt in formats:
+            base = getattr(A,'to' + fromfmt)()
+ 
+            times = []
+
+            for tofmt in formats:
+                try:
+                    fn = getattr(base,'to' + tofmt)
+                except:
+                    times.append(None)
+                else:
+                    x = fn() #warmup
+                    start = time.clock()
+                    iter = 0
+                    while time.clock() < start + 0.2:
+                        x = fn()
+                        iter += 1
+                    end = time.clock()
+                    del x 
+                    times.append( (end - start)/float(iter))
+
+            output = "  %3s   " % fromfmt
+            for t in times:
+                if t is None:
+                    output += '|    n/a    '
+                else:
+                    output += '| %5.1fms ' % (1000*t) 
+            print output
+
+
+class TestLarge(TestCase):
+    def bench_large(self):
+        # Create a 100x100 matrix with 100 non-zero elements
+        # and play around with it
+        #TODO move this out of Common since it doesn't use spmatrix
+        random.seed(0)
+        A = dok_matrix((100,100))
+        for k in range(100):
+            i = random.randrange(100)
+            j = random.randrange(100)
+            A[i,j] = 1.
+        csr = A.tocsr()
+        csc = A.tocsc()
+        csc2 = csr.tocsc()
+        coo = A.tocoo()
+        csr2 = coo.tocsr()
+        assert_array_equal(A.transpose().todense(), csr.transpose().todense())
+        assert_array_equal(csc.todense(), csr.todense())
+        assert_array_equal(csr.todense(), csr2.todense())
+        assert_array_equal(csr2.todense().transpose(), coo.transpose().todense())
+        assert_array_equal(csr2.todense(), csc2.todense())
+        csr_plus_csc = csr + csc
+        csc_plus_csr = csc + csr
+        assert_array_equal(csr_plus_csc.todense(), (2*A).todense())
+        assert_array_equal(csr_plus_csc.todense(), csc_plus_csr.todense())
+
+
+if __name__ == "__main__":
+    nose.run(argv=['', __file__])
+

Deleted: trunk/scipy/sparse/benchmarks/test_sparse.py
===================================================================
--- trunk/scipy/sparse/benchmarks/test_sparse.py	2008-01-17 15:41:44 UTC (rev 3848)
+++ trunk/scipy/sparse/benchmarks/test_sparse.py	2008-01-18 23:48:52 UTC (rev 3849)
@@ -1,286 +0,0 @@
-"""general tests and simple benchmarks for the sparse module"""
-
-import numpy
-from numpy import ones, array, asarray, empty
-
-import random
-from scipy.testing import *
-
-from scipy.sparse import csc_matrix, csr_matrix, dok_matrix, \
-        coo_matrix, lil_matrix, dia_matrix, spidentity, spdiags, \
-        spkron
-from scipy.linsolve import splu
-
-
-def random_sparse(m,n,nnz_per_row):
-    rows = numpy.arange(m).repeat(nnz_per_row)
-    cols = numpy.random.random_integers(low=0,high=n-1,size=nnz_per_row*m)
-    vals = numpy.random.random_sample(m*nnz_per_row)
-    return coo_matrix((vals,(rows,cols)),(m,n)).tocsr()
-
-
-#TODO move this to a matrix gallery and add unittests
-def poisson2d(N,dtype='d',format=None):
-    """
-    Return a sparse matrix for the 2d poisson problem
-    with standard 5-point finite difference stencil on a
-    square N-by-N grid.
-    """
-    if N == 1:
-        diags   = asarray( [[4]],dtype=dtype)
-        return dia_matrix((diags,[0]), shape=(1,1)).asformat(format)
-
-    offsets = array([0,-N,N,-1,1])
-
-    diags = empty((5,N**2),dtype=dtype)
-
-    diags[0]  =  4 #main diagonal
-    diags[1:] = -1 #all offdiagonals
-
-    diags[3,N-1::N] = 0  #first lower diagonal
-    diags[4,N::N] = 0  #first upper diagonal
-
-    return dia_matrix((diags,offsets),shape=(N**2,N**2)).asformat(format)
-
-import time
-class TestSparseTools(TestCase):
-    """Simple benchmarks for sparse matrix module"""
-
-    @dec.bench
-    def test_arithmetic(self):
-        matrices = []
-        #matrices.append( ('A','Identity', spidentity(500**2,format='csr')) )
-        matrices.append( ('A','Poisson5pt', poisson2d(500,format='csr'))  )
-        matrices.append( ('B','Poisson5pt^2', poisson2d(500,format='csr')**2)  )
-   
-        print
-        print '                 Sparse Matrix Arithmetic'
-        print '===================================================================='
-        print ' var |     name       |         shape        |   dtype   |    nnz   '
-        print '--------------------------------------------------------------------'
-        fmt = '  %1s  | %14s | %20s | %9s | %8d '
-
-        for var,name,mat in matrices:
-            name  = name.center(14)
-            shape = ("%s" % (mat.shape,)).center(20)
-            dtype = mat.dtype.name.center(9)
-            print fmt % (var,name,shape,dtype,mat.nnz)
-
-        space = ' ' * 10 
-        print
-        print space+'              Timings'
-        print space+'=========================================='
-        print space+' format |     operation     | time (msec) '
-        print space+'------------------------------------------'
-        fmt = space+'   %3s  | %17s |  %7.1f  '
-
-        for format in ['csr']:
-            vars = dict( [(var,mat.asformat(format)) for (var,name,mat) in matrices ] )
-            for X,Y in [ ('A','A'),('A','B'),('B','A'),('B','B') ]:
-                x,y = vars[X],vars[Y]
-                for op in ['__add__','__sub__','multiply','__div__','__mul__']:
-                    fn = getattr(x,op)
-                    fn(y) #warmup
-
-                    start = time.clock()
-                    iter = 0
-                    while iter < 5 or time.clock() < start + 1:
-                        fn(y)
-                        iter += 1
-                    end = time.clock()
-
-                    msec_per_it = 1000*(end - start)/float(iter)
-                    operation = (X + '.' + op + '(' + Y + ')').center(17)
-                    print fmt % (format,operation,msec_per_it)
-
-  
-    @dec.bench
-    def test_sort(self):
-        """sort CSR column indices"""
-        matrices = []
-        matrices.append( ('Rand10',  1e4,  10) )
-        matrices.append( ('Rand25',  1e4,  25) )
-        matrices.append( ('Rand50',  1e4,  50) )
-        matrices.append( ('Rand100', 1e4, 100) )
-        matrices.append( ('Rand200', 1e4, 200) )
-
-        print
-        print '                    Sparse Matrix Index Sorting'
-        print '====================================================================='
-        print ' type |    name      |         shape        |    nnz   | time (msec) '
-        print '---------------------------------------------------------------------'
-        fmt = '  %3s | %12s | %20s | %8d |   %6.2f  '
-
-        for name,N,K in matrices:
-            N = int(N) 
-            A = random_sparse(N,N,K)
-            
-            start = time.clock()
-            iter = 0
-            while iter < 5 and time.clock() - start < 1:
-                A._has_sorted_indices = False
-                A.sort_indices() 
-                iter += 1
-            end = time.clock()
-
-            name = name.center(12)
-            shape = ("%s" % (A.shape,)).center(20)
-
-            print fmt % (A.format,name,shape,A.nnz,1e3*(end-start)/float(iter) )
-
-    @dec.bench
-    def test_matvec(self):
-        matrices = []
-        matrices.append(('Identity',   spidentity(10**4,format='dia')))
-        matrices.append(('Identity',   spidentity(10**4,format='csr')))
-        matrices.append(('Poisson5pt', poisson2d(300,format='dia')))
-        matrices.append(('Poisson5pt', poisson2d(300,format='csr')))
-        matrices.append(('Poisson5pt', poisson2d(300,format='bsr')))
-
-        A = spkron(poisson2d(150),ones((2,2))).tobsr(blocksize=(2,2))
-        matrices.append( ('Block2x2', A.tocsr()) )
-        matrices.append( ('Block2x2', A) )
-        
-        A = spkron(poisson2d(100),ones((3,3))).tobsr(blocksize=(3,3))
-        matrices.append( ('Block3x3', A.tocsr()) )
-        matrices.append( ('Block3x3', A) )
-
-        print
-        print '                 Sparse Matrix Vector Product'
-        print '=================================================================='
-        print ' type |    name      |         shape        |    nnz   |  MFLOPs  '
-        print '------------------------------------------------------------------'
-        fmt = '  %3s | %12s | %20s | %8d |  %6.1f '
-
-        for name,A in matrices:
-            x = ones(A.shape[1],dtype=A.dtype)
-
-            y = A*x  #warmup
-
-            start = time.clock()
-            iter = 0
-            while iter < 5 or time.clock() < start + 1:
-                try:
-                    #avoid creating y if possible
-                    A.matvec(x,y)
-                except:
-                    y = A*x
-                iter += 1
-            end = time.clock()
-
-            del y
-
-            name = name.center(12)
-            shape = ("%s" % (A.shape,)).center(20)
-            MFLOPs = (2*A.nnz*iter/(end-start))/float(1e6)
-
-            print fmt % (A.format,name,shape,A.nnz,MFLOPs)
-            
-    @dec.bench
-    def test_construction(self):
-        """build matrices by inserting single values"""
-        matrices = []
-        matrices.append( ('Empty',csr_matrix((10000,10000))) )
-        matrices.append( ('Identity',spidentity(10000)) )
-        matrices.append( ('Poisson5pt', poisson2d(100)) )
-        
-        print
-        print '                    Sparse Matrix Construction'
-        print '===================================================================='
-        print ' type |    name      |         shape        |    nnz   | time (sec) '
-        print '--------------------------------------------------------------------'
-        fmt = '  %3s | %12s | %20s | %8d |   %6.4f '
-
-        for name,A in matrices:
-            A = A.tocoo()
-             
-            for format in ['lil','dok']: 
-
-                start = time.clock()
-                
-                iter = 0
-                while time.clock() < start + 0.5:
-                    T = eval(format + '_matrix')(A.shape)
-                    for i,j,v in zip(A.row,A.col,A.data):
-                        T[i,j] = v
-                    iter += 1
-                end = time.clock()
-
-                del T
-                name = name.center(12)
-                shape = ("%s" % (A.shape,)).center(20)
-
-                print fmt % (format,name,shape,A.nnz,(end-start)/float(iter))
-
-    @dec.bench
-    def test_conversion(self):
-        A = poisson2d(100)
-
-        formats = ['csr','csc','coo','lil','dok']
-       
-        print
-        print '                Sparse Matrix Conversion'
-        print '=========================================================='
-        print ' format | tocsr() | tocsc() | tocoo() | tolil() | todok() '
-        print '----------------------------------------------------------'
-        
-        for fromfmt in formats:
-            base = getattr(A,'to' + fromfmt)()
- 
-            times = []
-
-            for tofmt in formats:
-                try:
-                    fn = getattr(base,'to' + tofmt)
-                except:
-                    times.append(None)
-                else:
-                    x = fn() #warmup
-                    start = time.clock()
-                    iter = 0
-                    while time.clock() < start + 0.2:
-                        x = fn()
-                        iter += 1
-                    end = time.clock()
-                    del x 
-                    times.append( (end - start)/float(iter))
-
-            output = "  %3s   " % fromfmt
-            for t in times:
-                if t is None:
-                    output += '|    n/a    '
-                else:
-                    output += '| %5.1fms ' % (1000*t) 
-            print output
-
-
-class TestLarge(TestCase):
-    def test_large(self):
-        # Create a 100x100 matrix with 100 non-zero elements
-        # and play around with it
-        #TODO move this out of Common since it doesn't use spmatrix
-        random.seed(0)
-        A = dok_matrix((100,100))
-        for k in range(100):
-            i = random.randrange(100)
-            j = random.randrange(100)
-            A[i,j] = 1.
-        csr = A.tocsr()
-        csc = A.tocsc()
-        csc2 = csr.tocsc()
-        coo = A.tocoo()
-        csr2 = coo.tocsr()
-        assert_array_equal(A.transpose().todense(), csr.transpose().todense())
-        assert_array_equal(csc.todense(), csr.todense())
-        assert_array_equal(csr.todense(), csr2.todense())
-        assert_array_equal(csr2.todense().transpose(), coo.transpose().todense())
-        assert_array_equal(csr2.todense(), csc2.todense())
-        csr_plus_csc = csr + csc
-        csc_plus_csr = csc + csr
-        assert_array_equal(csr_plus_csc.todense(), (2*A).todense())
-        assert_array_equal(csr_plus_csc.todense(), csc_plus_csr.todense())
-
-
-if __name__ == "__main__":
-    unittest.main()
-

Modified: trunk/scipy/stsci/image/lib/_image.py
===================================================================
--- trunk/scipy/stsci/image/lib/_image.py	2008-01-17 15:41:44 UTC (rev 3848)
+++ trunk/scipy/stsci/image/lib/_image.py	2008-01-18 23:48:52 UTC (rev 3849)
@@ -1,6 +1,6 @@
 import numpy as num
-import convolve
-import convolve._correlate as _correlate
+import scipy.stsci.convolve
+import scipy.stsci.convolve._correlate as _correlate
 MLab=num
 
 def _translate(a, dx, dy, output=None, mode="nearest", cval=0.0):

Modified: trunk/scipy/testing/decorators.py
===================================================================
--- trunk/scipy/testing/decorators.py	2008-01-17 15:41:44 UTC (rev 3848)
+++ trunk/scipy/testing/decorators.py	2008-01-18 23:48:52 UTC (rev 3849)
@@ -11,15 +11,6 @@
     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
-
 def willfail(t):
     ''' Labels test as known failure
 

Modified: trunk/scipy/testing/nosetester.py
===================================================================
--- trunk/scipy/testing/nosetester.py	2008-01-17 15:41:44 UTC (rev 3848)
+++ trunk/scipy/testing/nosetester.py	2008-01-18 23:48:52 UTC (rev 3849)
@@ -1,10 +1,11 @@
 ''' Nose test running
 
-Implements .test functions for modules.
+Implements test and bench functions for modules.
 
 '''
 import os
 import sys
+import re
 
 import nose
 
@@ -30,6 +31,7 @@
     returning this class if nose is present, and a null class
     otherwise.
     """
+
     def __init__(self, package=None):
         ''' Test class init
 
@@ -39,7 +41,6 @@
             If string, gives full path to package
             If None, extract calling module path
             Default is None
-            
         '''
         if package is None:
             f = sys._getframe(1)
@@ -50,45 +51,80 @@
             package = os.path.dirname(package.__file__)
         self.package_path = package
         
-    def test(self, label='fast', verbose=1, doctests=False, extra_argv=None):
-        ''' Module testing function
+    def _add_doc(testtype):
+        ''' Decorator to add docstring to functions using test labels
 
         Parameters
         ----------
+        testtype : string
+            Type of test for function docstring
+        '''
+        def docit(func):
+            test_header = \
+        '''Parameters
+        ----------
         label : {'fast', 'full', '', attribute identifer}
-            Identifies tests to run.  This can be a string to pass to
+            Identifies %(testtype)s to run.  This can be a string to pass to
             the nosetests 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 and not willfail'.
-            'full' - fast (as above) and slow tests as in
-                nosetests -A option of 'not bench and not willfail'. 
-            None or '' - run all tests and benchmarks
+                'not slow and not willfail'.
+            'full' - fast (as above) and slow %(testtype)s as in
+                nosetests -A option of 'not willfail'. 
+            None or '' - run all %(testtype)ss 
             attribute_identifier - string passed directly to
                 nosetests as '-A' 
         verbose : integer
             verbosity value for test outputs, 1-10
-        doctests : boolean
-            If True, run doctests in module, default False
         extra_argv : list
-            List with any extra args to pass to nosetests
+            List with any extra args to pass to nosetests''' \
+            % {'testtype': testtype}
+            func.__doc__ = func.__doc__ % {
+                'test_header': test_header}
+            return func
+        return docit
+
+    @_add_doc('(testtype)')
+    def _test_argv(self, label, verbose, extra_argv):
+        ''' Generate argv for nosetest command
+
+        %(test_header)s
         '''
-        argv = ['scipy module test', self.package_path, '-s']
+        argv = [__file__, self.package_path, '-s']
         if label:
             if not isinstance(label, basestring):
-                raise TypeError, 'Test selection label should be a string'
+                raise TypeError, 'Selection label should be a string'
             if label == 'fast':
-                label = 'not slow and not bench and not willfail'
+                label = 'not slow and not willfail'
             elif label == 'full':
-                label = 'not bench and not willfail'
+                label = 'not willfail'
             argv += ['-A', label]
         argv += ['--verbosity', str(verbose)]
+        if extra_argv:
+            argv += extra_argv
+        return argv
+        
+    @_add_doc('test')        
+    def test(self, label='fast', verbose=1, extra_argv=None, doctests=False):
+        ''' Run tests for module using nose
+        
+        %(test_header)s
+        doctests : boolean
+            If True, run doctests in module, default False
+        '''
+        argv = self._test_argv(label, verbose, extra_argv)
         if doctests:
             argv+=['--with-doctest']
-        if extra_argv:
-            argv+= extra_argv
         nose.run(argv=argv)
+        
+    @_add_doc('benchmark')
+    def bench(self, label='fast', verbose=1, extra_argv=None):
+        ''' Run benchmarks for module using nose
 
+        %(test_header)s'''
+        argv = self._test_argv(label, verbose, extra_argv)
+        argv += ['--match', r'(?:^|[\\b_\\.%s-])[Bb]ench' % os.sep]
+        nose.run(argv=argv)
         



More information about the Scipy-svn mailing list