[Scipy-svn] r4621 - branches/Interpolate1D/tests

scipy-svn@scip... scipy-svn@scip...
Fri Aug 8 12:37:29 CDT 2008


Author: fcady
Date: 2008-08-08 12:37:26 -0500 (Fri, 08 Aug 2008)
New Revision: 4621

Added:
   branches/Interpolate1D/tests/test_interpolateNd.py
Removed:
   branches/Interpolate1D/tests/test_ndimage.py
Modified:
   branches/Interpolate1D/tests/regression_test.py
Log:
updated regression test to include higher diensional tests

Modified: branches/Interpolate1D/tests/regression_test.py
===================================================================
--- branches/Interpolate1D/tests/regression_test.py	2008-08-08 16:02:21 UTC (rev 4620)
+++ branches/Interpolate1D/tests/regression_test.py	2008-08-08 17:37:26 UTC (rev 4621)
@@ -11,27 +11,59 @@
 
 # hack to test on Field's computer
 import sys
-sys.path.append('c:/home/python/Interpolate1d')
+sys.path.append('c:/home/python/Interpolate1d/tests')
 
 import shelve, time
-from test_interpolate1d import Test
+from test_interpolate1d import Test as Test1
+from test_interpolate2d import Test as Test2
+from test_interpolateNd import Test as TestN
 
 # name of log file to which all data is stored.
 filename = 'regression_test.dbm'
 
 log_total = shelve.open(filename)
 current_time = str(time.localtime()[0:5]) # specified up to the minute
+current_dict = {} # holds results for each dimensionality
 
 # run all tests in interpolate1d's test class
-test_list = [name for name in dir(Test) if name.find('test_') == 0]
-log_now = {}
+if True:
+    test_list = [name for name in dir(Test1) if name.find('test_') == 0]
+    Test1_dict = {}
 
-# record time taken for each test
-for test_name in test_list:
-    t1 = time.clock()
-    eval('Test.%s' % test_name)
-    t2 = time.clock()
-    log_now[test_name] = t2-t1
+    # record time taken for each test
+    for test_name in test_list:
+        t1 = time.clock()
+        eval('Test1.%s' % test_name)
+        t2 = time.clock()
+        Test1_dict[test_name] = t2-t1
 
-log_total[current_time] = log_now
+    current_dict['Test1'] = Test1_dict
+    
+if True:
+    test_list = [name for name in dir(Test2) if name.find('test_') == 0]
+    Test2_dict = {}
+
+    # record time taken for each test
+    for test_name in test_list:
+        t1 = time.clock()
+        eval('Test2.%s' % test_name)
+        t2 = time.clock()
+        Test2_dict[test_name] = t2-t1
+
+    current_dict['Test2'] = Test2_dict
+
+if True:
+    test_list = [name for name in dir(TestN) if name.find('test_') == 0]
+    TestN_dict = {}
+
+    # record time taken for each test
+    for test_name in test_list:
+        t1 = time.clock()
+        eval('TestN.%s' % test_name)
+        t2 = time.clock()
+        TestN_dict[test_name] = t2-t1
+
+    current_dict['TestN'] = TestN_dict
+
+log_total[current_time] = current_dict
 log_total.close()

Copied: branches/Interpolate1D/tests/test_interpolateNd.py (from rev 4620, branches/Interpolate1D/tests/test_ndimage.py)

Deleted: branches/Interpolate1D/tests/test_ndimage.py
===================================================================
--- branches/Interpolate1D/tests/test_ndimage.py	2008-08-08 16:02:21 UTC (rev 4620)
+++ branches/Interpolate1D/tests/test_ndimage.py	2008-08-08 17:37:26 UTC (rev 4621)
@@ -1,122 +0,0 @@
-""" module for testing ndimage_wrapper
-"""
-
-# hack to test on Field's computer
-import sys
-sys.path.append('c:/home/python/Interpolate1d')
-
-import unittest
-import time
-from numpy import arange, allclose, ones, array
-import numpy as np
-import interpolateNd as nd
-
-class Test (unittest.TestCase):
-    
-    def assertAllclose(self, x, y, err=1.0e-8):
-        self.assert_(np.allclose(x, y, atol=err))
-    
-    def test_interpNd(self):
-        """ Make sure : the function interpNd works
-        """
-        boring_data = np.ones((5,5,5))
-        answer = nd.interpNd(boring_data, np.array([[2.3], [1.0], [3.9]]))
-        self.assertAllclose( answer , 1.0 )
-        
-    def test_linear(self):
-        """ Make sure : basic linear works
-        """
-        boring_data = np.ones((5,5,5))
-        interp = nd.InterpolateNd(boring_data, kind = 'linear')
-        self.assertAllclose( interp(np.array([[2.3], [1.0], [3.9]])) , 1.0 )
-        
-    def test_linear_not_1(self):
-        """ Make sure : linear interpolation works on a general dataset
-        """
-        X, Y = np.meshgrid(arange(10.), arange(10.))
-        interesting_data = X+Y
-        interp = nd.InterpolateNd(interesting_data, kind = 'linear')
-        self.assertAllclose( interp(np.array([[2.3], [1.0]])) , 3.3 )
-        
-    def test_data_is_list(self):
-        """ Make sure : data can be entered as a list
-        """
-        boring_data = [ [1.0, 1.0, 1.0],
-                              [1.0, 1.0, 1.0],
-                              [1.0, 1.0, 1.0]]
-        interp = nd.InterpolateNd(boring_data)
-        self.assertAllclose( interp(np.array([[1.3], [1.0]])) , 1.0 )
-        
-    def test_coords_is_1d(self):
-        """ Make sure : coordinates for a single point can be entered as a 1D array
-        """
-        boring_data = np.ones((5,5,5))
-        interp = nd.InterpolateNd(boring_data)
-        self.assertAllclose( interp(np.array([2.3, 1.0, 3.9])) , 1.0 )
-        
-    def test_coords_is_list(self):
-        """ Make sure : coordinates for a single point can be entered as a list
-        """
-        boring_data = np.ones((5,5,5))
-        interp = nd.InterpolateNd(boring_data)
-        self.assertAllclose( interp([2.3, 1.0, 3.9]) , 1.0 )
-            
-    def test_order2(self):
-        """ Make sure : quadratic interpolation works
-        """
-        X, Y = np.meshgrid(arange(10.), arange(10.))
-        interesting_data = X+Y
-        interp = nd.InterpolateNd(interesting_data, kind = 2)
-        print "quad answer: ", interp(np.array([[2.3], [1.0]]))
-        self.assertAllclose( interp(np.array([[2.3], [1.0]])) , 3.3 , err=.1 )
-        
-    def test_order0(self):
-        """ Make sure : block interpolation works
-        """
-        X, Y = np.meshgrid(arange(10.), arange(10.))
-        interesting_data = X+Y
-        interp = nd.InterpolateNd(interesting_data, kind = 0)
-        self.assertAllclose( interp(np.array([[2.3], [1.1]])) , 3.0 )
-        
-    def test_order3(self):
-        """ Make sure : cubic interpolation works
-        """
-        X, Y = np.meshgrid(arange(10.), arange(10.))
-        interesting_data = X+Y
-        interp = nd.InterpolateNd(interesting_data, kind = 3)
-        print "cubi answer: ", interp(np.array([[4.3], [4.1]]))
-        self.assertAllclose( interp(np.array([[4.3], [4.1]])) , 8.4 , err=.1)
-        
-    def test_out(self):
-        """ Make sure : out-of-bounds returns NaN
-        """
-        boring_data = np.ones((5,5,5))
-        interp = nd.InterpolateNd(boring_data, kind = 'linear')
-        self.assert_( np.isnan(interp(  np.array([[7.3], [1.0], [3.9]])  )))
-        
-    def test_starting_coords(self):
-        """ Make sure : non-zero starting coordinates work correctly
-        """
-        X, Y = np.meshgrid(arange(10.), arange(10.))
-        interesting_data = X+Y
-        interp = nd.InterpolateNd(interesting_data, starting_coords = array([2, 1]))
-        self.assertAllclose( interp(np.array([[2.3], [1.0]])) , 0.3 )
-    
-    def test_spacings(self):
-        """ Make sure : spacings other than 1 work correctly
-        """
-        X, Y = np.meshgrid(arange(10.), arange(10.))
-        interesting_data = X+Y
-        interp = nd.InterpolateNd(interesting_data, spacings = array([2, 1]))
-        self.assertAllclose( interp(np.array([[2.4], [1.0]])) , 2.2 )
-        
-    def runTest(self):
-        """ run all tests
-        """
-        test_list = [method_name for method_name in dir(self) if method_name.find('test')==0]
-        for test_name in test_list:
-            exec("self.%s()" % test_name)
-        
-        
-if __name__ == '__main__':
-    unittest.main()
\ No newline at end of file



More information about the Scipy-svn mailing list