Ignore:
Timestamp:
Jan 21, 2015, 9:16:02 PM (10 years ago)
Author:
steve
Message:

Fixing up test files to work with nosetests

Location:
trunk/anuga_core/source/anuga
Files:
1 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/anuga_core/source/anuga/fit_interpolate/test/test_fit.py

    r9479 r9480  
    1313import os
    1414
    15 from fit import *
     15from anuga.fit_interpolate.fit import *
    1616from anuga.abstract_2d_finite_volumes.neighbour_mesh import Mesh
    1717from anuga.utilities.sparse import Sparse, Sparse_CSR
     
    286286        os.remove(txt_file)
    287287       
    288     def cache_test_fit_to_mesh_pts(self):
    289         a = [-1.0, 0.0]
    290         b = [3.0, 4.0]
    291         c = [4.0,1.0]
    292         d = [-3.0, 2.0] #3
    293         e = [-1.0,-2.0]
    294         f = [1.0, -2.0] #5
    295 
    296         vertices = [a, b, c, d,e,f]
    297         triangles = [[0,1,3], [1,0,2], [0,4,5], [0,5,2]] #abd bac aef afc
    298 
    299 
    300         fileName = tempfile.mktemp(".txt")
    301         file = open(fileName,"w")
    302         file.write(" x, y, elevation \n\
    303 -2.0, 2.0, 0.\n\
    304 -1.0, 1.0, 0.\n\
    305 0.0, 2.0 , 2.\n\
    306 1.0, 1.0 , 2.\n\
    307  2.0,  1.0 ,3. \n\
    308  0.0,  0.0 , 0.\n\
    309  1.0,  0.0 , 1.\n\
    310  0.0,  -1.0, -1.\n\
    311  -0.2, -0.5, -0.7\n\
    312  -0.9, -1.5, -2.4\n\
    313  0.5,  -1.9, -1.4\n\
    314  3.0,  1.0 , 4.\n")
    315         file.close()
    316         geo = Geospatial_data(fileName)
    317         fileName_pts = tempfile.mktemp(".pts")
    318         points = geo.get_data_points(absolute=True)
    319         atts = geo.get_attributes()
    320         f = fit_to_mesh(points,atts, vertices, triangles,
    321                                 alpha=0.0, max_read_lines=2,
    322                         use_cache=True, verbose=True)
    323         answer = linear_function(vertices)
    324         #print "f\n",f
    325         #print "answer\n",answer
    326         assert num.allclose(f, answer)
    327         os.remove(fileName)
    328288       
    329289    def test_fit_to_mesh_pts(self):
     
    11821142        os.remove(point_file)
    11831143 
    1184     def Not_yet_test_smooth_att_to_mesh_with_excess_verts(self):
    1185 
    1186         a = [0.0, 0.0]
    1187         b = [0.0, 5.0]
    1188         c = [5.0, 0.0]
    1189         d = [1.0, 1.0]
    1190         e = [18.0, 1000.0]
    1191        
    1192         points = [a, b, c, d, e]
    1193         triangles = [ [1,0,2] ]   #bac
    1194 
    1195         d1 = [1.0, 1.0]
    1196         d2 = [1.0, 2.0]
    1197         d3 = [3.0,1.0]
    1198         d4 = [2.0,3.0]
    1199         d5 = [2.0,2.0]
    1200         d6 = [1.0,3.0]
    1201         data_coords = [d1, d2, d3, d4, d5, d6]
    1202         z = linear_function(data_coords)
    1203         #print "z",z
    1204 
    1205         interp = Fit(points, triangles, alpha=0.0)
    1206        
    1207         try:
    1208             f = interp.fit(data_coords, z)
    1209         except VertsWithNoTrianglesError:
    1210             pass
    1211         else:
    1212             raise Exception('Verts with no triangles did not raise error!')
    1213        
    1214         #f = interp.fit(data_coords, z)
    1215         #answer = linear_function(points)
    1216 
    1217         #  Removing the bad verts that we don't care about
    1218         #f = f[0:3]
    1219         #answer = answer[0:3]
    1220         #assert allclose(f, answer)
    12211144
    12221145#-------------------------------------------------------------
  • trunk/anuga_core/source/anuga/fit_interpolate/test/test_interpolate2d.py

    r9479 r9480  
    1414import numpy
    1515
    16 from interpolate2d import interpolate2d
     16from anuga.fit_interpolate.interpolate2d import interpolate2d
    1717
    1818
     
    466466if __name__ == '__main__':
    467467    suite = unittest.makeSuite(Test_interpolate, 'test')
    468     runner = unittest.TextTestRunner(verbosity=2)
     468    runner = unittest.TextTestRunner(verbosity=1)
    469469    runner.run(suite)
  • trunk/anuga_core/source/anuga/geometry/test/test_polygon.py

    r9462 r9480  
    2323
    2424
    25 def test_function(x, y):
     25def simple_function(x, y):
    2626    return x+y
    2727
     
    162162        p2 = [[0,0], [10,10], [15,5], [20, 10], [25,0], [30,10], [40,-10]]
    163163
    164         f = Polygon_function([(p1, test_function)])
     164        f = Polygon_function([(p1, simple_function)])
    165165        z = f([5, 5, 27, 35], [5, 9, 8, -5]) # Two first inside p1
    166166        assert num.allclose(z, [10, 14, 0, 0])
    167167
    168168        # Combined
    169         f = Polygon_function([(p1, test_function), (p2, 2.0)])
     169        f = Polygon_function([(p1, simple_function), (p2, 2.0)])
    170170        z = f([5, 5, 27, 35], [5, 9, 8, -5])
    171171        assert num.allclose(z, [2, 14, 0, 2])
    172172
    173173        # Combined w default
    174         f = Polygon_function([(p1, test_function), (p2, 2.0)], default = 3.14)
     174        f = Polygon_function([(p1, simple_function), (p2, 2.0)], default = 3.14)
    175175        z = f([5, 5, 27, 35], [5, 9, 8, -5])
    176176        assert num.allclose(z, [2, 14, 3.14, 2])
    177177
    178178        # Combined w default func
    179         f = Polygon_function([(p1, test_function), (p2, 2.0)],
    180                              default=test_function)
     179        f = Polygon_function([(p1, simple_function), (p2, 2.0)],
     180                             default=simple_function)
    181181        z = f([5, 5, 27, 35], [5, 9, 8, -5])
    182182        assert num.allclose(z, [2, 14, 35, 2])
     
    867867    # This function tests all parallel line cases for 4 collinear points.
    868868    # This function should never be run directly by the unittest code.
    869     def helper_test_parallel_intersection_code(self, P1, P2, P3, P4):
     869    def helper_parallel_intersection_code(self, P1, P2, P3, P4):
    870870        # lines in same direction, no overlap
    871871        # 0:         ---->----
     
    13761376        P4 = [4.0, 4.0]
    13771377
    1378         self.helper_test_parallel_intersection_code(P1, P2, P3, P4)
     1378        self.helper_parallel_intersection_code(P1, P2, P3, P4)
    13791379        P1 = [1.0, 1.0+1.0e-9]
    1380         self.helper_test_parallel_intersection_code(P1, P2, P3, P4)
     1380        self.helper_parallel_intersection_code(P1, P2, P3, P4)
    13811381        P1 = [1.0, 1.0]
    13821382        P2 = [2.0, 2.0+1.0e-9]
    1383         self.helper_test_parallel_intersection_code(P1, P2, P3, P4)
     1383        self.helper_parallel_intersection_code(P1, P2, P3, P4)
    13841384        P2 = [2.0, 2.0]
    13851385        P3 = [3.0, 3.0+1.0e-9]
    1386         self.helper_test_parallel_intersection_code(P1, P2, P3, P4)
     1386        self.helper_parallel_intersection_code(P1, P2, P3, P4)
    13871387        P3 = [3.0, 3.0]
    13881388        P4 = [4.0, 4.0+1.0e-9]
    1389         self.helper_test_parallel_intersection_code(P1, P2, P3, P4)
     1389        self.helper_parallel_intersection_code(P1, P2, P3, P4)
    13901390
    13911391    def test_intersection_bug_20081110_TL(self):
     
    14021402        P4 = [-4.0, 4.0]
    14031403
    1404         self.helper_test_parallel_intersection_code(P1, P2, P3, P4)
     1404        self.helper_parallel_intersection_code(P1, P2, P3, P4)
    14051405        P1 = [-1.0, 1.0+1.0e-9]
    1406         self.helper_test_parallel_intersection_code(P1, P2, P3, P4)
     1406        self.helper_parallel_intersection_code(P1, P2, P3, P4)
    14071407        P1 = [-1.0, 1.0]
    14081408        P2 = [-2.0, 2.0+1.0e-9]
    1409         self.helper_test_parallel_intersection_code(P1, P2, P3, P4)
     1409        self.helper_parallel_intersection_code(P1, P2, P3, P4)
    14101410        P2 = [-2.0, 2.0]
    14111411        P3 = [-3.0, 3.0+1.0e-9]
    1412         self.helper_test_parallel_intersection_code(P1, P2, P3, P4)
     1412        self.helper_parallel_intersection_code(P1, P2, P3, P4)
    14131413        P3 = [-3.0, 3.0]
    14141414        P4 = [-4.0, 4.0+1.0e-9]
    1415         self.helper_test_parallel_intersection_code(P1, P2, P3, P4)
     1415        self.helper_parallel_intersection_code(P1, P2, P3, P4)
    14161416
    14171417    def test_intersection_bug_20081110_BL(self):
     
    14281428        P4 = [-4.0, -4.0]
    14291429
    1430         self.helper_test_parallel_intersection_code(P1, P2, P3, P4)
     1430        self.helper_parallel_intersection_code(P1, P2, P3, P4)
    14311431        P1 = [-1.0, -1.0+1.0e-9]
    1432         self.helper_test_parallel_intersection_code(P1, P2, P3, P4)
     1432        self.helper_parallel_intersection_code(P1, P2, P3, P4)
    14331433        P1 = [-1.0, -1.0]
    14341434        P2 = [-2.0, -2.0+1.0e-9]
    1435         self.helper_test_parallel_intersection_code(P1, P2, P3, P4)
     1435        self.helper_parallel_intersection_code(P1, P2, P3, P4)
    14361436        P2 = [-2.0, -2.0]
    14371437        P3 = [-3.0, -3.0+1.0e-9]
    1438         self.helper_test_parallel_intersection_code(P1, P2, P3, P4)
     1438        self.helper_parallel_intersection_code(P1, P2, P3, P4)
    14391439        P3 = [-3.0, -3.0]
    14401440        P4 = [-4.0, -4.0+1.0e-9]
    1441         self.helper_test_parallel_intersection_code(P1, P2, P3, P4)
     1441        self.helper_parallel_intersection_code(P1, P2, P3, P4)
    14421442
    14431443    def test_intersection_bug_20081110_BR(self):
     
    14541454        P4 = [4.0, -4.0]
    14551455
    1456         self.helper_test_parallel_intersection_code(P1, P2, P3, P4)
     1456        self.helper_parallel_intersection_code(P1, P2, P3, P4)
    14571457        P1 = [1.0, -1.0+1.0e-9]
    1458         self.helper_test_parallel_intersection_code(P1, P2, P3, P4)
     1458        self.helper_parallel_intersection_code(P1, P2, P3, P4)
    14591459        P1 = [1.0, -1.0]
    14601460        P2 = [2.0, -2.0+1.0e-9]
    1461         self.helper_test_parallel_intersection_code(P1, P2, P3, P4)
     1461        self.helper_parallel_intersection_code(P1, P2, P3, P4)
    14621462        P2 = [2.0, -2.0]
    14631463        P3 = [3.0, -3.0+1.0e-9]
    1464         self.helper_test_parallel_intersection_code(P1, P2, P3, P4)
     1464        self.helper_parallel_intersection_code(P1, P2, P3, P4)
    14651465        P3 = [3.0, -3.0]
    14661466        P4 = [4.0, -4.0+1.0e-9]
    1467         self.helper_test_parallel_intersection_code(P1, P2, P3, P4)
     1467        self.helper_parallel_intersection_code(P1, P2, P3, P4)
    14681468
    14691469    def test_intersection_bug_20081110_TR_TL(self):
     
    14791479        P3 = [ 2.0, 6.0]
    14801480        P4 = [ 3.0, 7.0]
    1481         self.helper_test_parallel_intersection_code(P1, P2, P3, P4)
     1481        self.helper_parallel_intersection_code(P1, P2, P3, P4)
    14821482
    14831483        # define 4 collinear points, 2 in TL, 2 in TR
     
    14871487        P3 = [ 2.0, 6.0]
    14881488        P4 = [ 3.0, 7.0]
    1489         self.helper_test_parallel_intersection_code(P1, P2, P3, P4)
     1489        self.helper_parallel_intersection_code(P1, P2, P3, P4)
    14901490
    14911491        # define 4 collinear points, 3 in TL, 1 in TR
     
    14951495        P3 = [-1.0, 3.0]
    14961496        P4 = [ 3.0, 7.0]
    1497         self.helper_test_parallel_intersection_code(P1, P2, P3, P4)
     1497        self.helper_parallel_intersection_code(P1, P2, P3, P4)
    14981498
    14991499    def test_intersection_bug_20081110_TR_BL(self):
     
    15091509        P3 = [ 2.0,  3.0]
    15101510        P4 = [ 3.0,  4.0]
    1511         self.helper_test_parallel_intersection_code(P1, P2, P3, P4)
     1511        self.helper_parallel_intersection_code(P1, P2, P3, P4)
    15121512
    15131513        # define 4 collinear points, 2 in TL, 2 in TR
     
    15171517        P3 = [ 2.0,  3.0]
    15181518        P4 = [ 3.0,  4.0]
    1519         self.helper_test_parallel_intersection_code(P1, P2, P3, P4)
     1519        self.helper_parallel_intersection_code(P1, P2, P3, P4)
    15201520
    15211521        # define 4 collinear points, 3 in TL, 1 in TR
     
    15251525        P3 = [-2.0, -1.0]
    15261526        P4 = [ 3.0,  4.0]
    1527         self.helper_test_parallel_intersection_code(P1, P2, P3, P4)
     1527        self.helper_parallel_intersection_code(P1, P2, P3, P4)
    15281528
    15291529    def test_intersection_bug_20081110_TR_BR(self):
     
    15391539        P3 = [ 6.0,  2.0]
    15401540        P4 = [ 7.0,  3.0]
    1541         self.helper_test_parallel_intersection_code(P1, P2, P3, P4)
     1541        self.helper_parallel_intersection_code(P1, P2, P3, P4)
    15421542
    15431543        # define 4 collinear points, 2 in BR, 2 in TR
     
    15471547        P3 = [ 6.0,  2.0]
    15481548        P4 = [ 7.0,  3.0]
    1549         self.helper_test_parallel_intersection_code(P1, P2, P3, P4)
     1549        self.helper_parallel_intersection_code(P1, P2, P3, P4)
    15501550
    15511551        # define 4 collinear points, 3 in BR, 1 in TR
     
    15551555        P3 = [ 3.0, -1.0]
    15561556        P4 = [ 7.0,  3.0]
    1557         self.helper_test_parallel_intersection_code(P1, P2, P3, P4)
     1557        self.helper_parallel_intersection_code(P1, P2, P3, P4)
    15581558
    15591559
Note: See TracChangeset for help on using the changeset viewer.