Changeset 9480
- Timestamp:
- Jan 21, 2015, 9:16:02 PM (10 years ago)
- 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 13 13 import os 14 14 15 from fit import *15 from anuga.fit_interpolate.fit import * 16 16 from anuga.abstract_2d_finite_volumes.neighbour_mesh import Mesh 17 17 from anuga.utilities.sparse import Sparse, Sparse_CSR … … 286 286 os.remove(txt_file) 287 287 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] #3293 e = [-1.0,-2.0]294 f = [1.0, -2.0] #5295 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 afc298 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",f325 #print "answer\n",answer326 assert num.allclose(f, answer)327 os.remove(fileName)328 288 329 289 def test_fit_to_mesh_pts(self): … … 1182 1142 os.remove(point_file) 1183 1143 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] ] #bac1194 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",z1204 1205 interp = Fit(points, triangles, alpha=0.0)1206 1207 try:1208 f = interp.fit(data_coords, z)1209 except VertsWithNoTrianglesError:1210 pass1211 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 about1218 #f = f[0:3]1219 #answer = answer[0:3]1220 #assert allclose(f, answer)1221 1144 1222 1145 #------------------------------------------------------------- -
trunk/anuga_core/source/anuga/fit_interpolate/test/test_interpolate2d.py
r9479 r9480 14 14 import numpy 15 15 16 from interpolate2d import interpolate2d16 from anuga.fit_interpolate.interpolate2d import interpolate2d 17 17 18 18 … … 466 466 if __name__ == '__main__': 467 467 suite = unittest.makeSuite(Test_interpolate, 'test') 468 runner = unittest.TextTestRunner(verbosity= 2)468 runner = unittest.TextTestRunner(verbosity=1) 469 469 runner.run(suite) -
trunk/anuga_core/source/anuga/geometry/test/test_polygon.py
r9462 r9480 23 23 24 24 25 def test_function(x, y):25 def simple_function(x, y): 26 26 return x+y 27 27 … … 162 162 p2 = [[0,0], [10,10], [15,5], [20, 10], [25,0], [30,10], [40,-10]] 163 163 164 f = Polygon_function([(p1, test_function)])164 f = Polygon_function([(p1, simple_function)]) 165 165 z = f([5, 5, 27, 35], [5, 9, 8, -5]) # Two first inside p1 166 166 assert num.allclose(z, [10, 14, 0, 0]) 167 167 168 168 # Combined 169 f = Polygon_function([(p1, test_function), (p2, 2.0)])169 f = Polygon_function([(p1, simple_function), (p2, 2.0)]) 170 170 z = f([5, 5, 27, 35], [5, 9, 8, -5]) 171 171 assert num.allclose(z, [2, 14, 0, 2]) 172 172 173 173 # 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) 175 175 z = f([5, 5, 27, 35], [5, 9, 8, -5]) 176 176 assert num.allclose(z, [2, 14, 3.14, 2]) 177 177 178 178 # 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) 181 181 z = f([5, 5, 27, 35], [5, 9, 8, -5]) 182 182 assert num.allclose(z, [2, 14, 35, 2]) … … 867 867 # This function tests all parallel line cases for 4 collinear points. 868 868 # 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): 870 870 # lines in same direction, no overlap 871 871 # 0: ---->---- … … 1376 1376 P4 = [4.0, 4.0] 1377 1377 1378 self.helper_ test_parallel_intersection_code(P1, P2, P3, P4)1378 self.helper_parallel_intersection_code(P1, P2, P3, P4) 1379 1379 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) 1381 1381 P1 = [1.0, 1.0] 1382 1382 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) 1384 1384 P2 = [2.0, 2.0] 1385 1385 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) 1387 1387 P3 = [3.0, 3.0] 1388 1388 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) 1390 1390 1391 1391 def test_intersection_bug_20081110_TL(self): … … 1402 1402 P4 = [-4.0, 4.0] 1403 1403 1404 self.helper_ test_parallel_intersection_code(P1, P2, P3, P4)1404 self.helper_parallel_intersection_code(P1, P2, P3, P4) 1405 1405 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) 1407 1407 P1 = [-1.0, 1.0] 1408 1408 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) 1410 1410 P2 = [-2.0, 2.0] 1411 1411 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) 1413 1413 P3 = [-3.0, 3.0] 1414 1414 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) 1416 1416 1417 1417 def test_intersection_bug_20081110_BL(self): … … 1428 1428 P4 = [-4.0, -4.0] 1429 1429 1430 self.helper_ test_parallel_intersection_code(P1, P2, P3, P4)1430 self.helper_parallel_intersection_code(P1, P2, P3, P4) 1431 1431 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) 1433 1433 P1 = [-1.0, -1.0] 1434 1434 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) 1436 1436 P2 = [-2.0, -2.0] 1437 1437 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) 1439 1439 P3 = [-3.0, -3.0] 1440 1440 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) 1442 1442 1443 1443 def test_intersection_bug_20081110_BR(self): … … 1454 1454 P4 = [4.0, -4.0] 1455 1455 1456 self.helper_ test_parallel_intersection_code(P1, P2, P3, P4)1456 self.helper_parallel_intersection_code(P1, P2, P3, P4) 1457 1457 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) 1459 1459 P1 = [1.0, -1.0] 1460 1460 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) 1462 1462 P2 = [2.0, -2.0] 1463 1463 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) 1465 1465 P3 = [3.0, -3.0] 1466 1466 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) 1468 1468 1469 1469 def test_intersection_bug_20081110_TR_TL(self): … … 1479 1479 P3 = [ 2.0, 6.0] 1480 1480 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) 1482 1482 1483 1483 # define 4 collinear points, 2 in TL, 2 in TR … … 1487 1487 P3 = [ 2.0, 6.0] 1488 1488 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) 1490 1490 1491 1491 # define 4 collinear points, 3 in TL, 1 in TR … … 1495 1495 P3 = [-1.0, 3.0] 1496 1496 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) 1498 1498 1499 1499 def test_intersection_bug_20081110_TR_BL(self): … … 1509 1509 P3 = [ 2.0, 3.0] 1510 1510 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) 1512 1512 1513 1513 # define 4 collinear points, 2 in TL, 2 in TR … … 1517 1517 P3 = [ 2.0, 3.0] 1518 1518 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) 1520 1520 1521 1521 # define 4 collinear points, 3 in TL, 1 in TR … … 1525 1525 P3 = [-2.0, -1.0] 1526 1526 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) 1528 1528 1529 1529 def test_intersection_bug_20081110_TR_BR(self): … … 1539 1539 P3 = [ 6.0, 2.0] 1540 1540 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) 1542 1542 1543 1543 # define 4 collinear points, 2 in BR, 2 in TR … … 1547 1547 P3 = [ 6.0, 2.0] 1548 1548 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) 1550 1550 1551 1551 # define 4 collinear points, 3 in BR, 1 in TR … … 1555 1555 P3 = [ 3.0, -1.0] 1556 1556 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) 1558 1558 1559 1559
Note: See TracChangeset
for help on using the changeset viewer.