Changeset 664 for inundation/ga/storm_surge/pyvolution/test_util.py
- Timestamp:
- Dec 2, 2004, 3:28:33 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/ga/storm_surge/pyvolution/test_util.py
r659 r664 8 8 from util import * 9 9 from config import epsilon 10 11 12 def test_function(x, y): 13 return x+y 10 14 11 15 class TestCase(unittest.TestCase): … … 334 338 335 339 336 def test_polygon_function (self):340 def test_polygon_function_constants(self): 337 341 p1 = [[0,0], [10,0], [10,10], [0,10]] 338 342 p2 = [[0,0], [10,10], [15,5], [20, 10], [25,0], [30,10], [40,-10]] … … 353 357 assert allclose(z, [2,1,0,2]) 354 358 359 360 def test_polygon_function_callable(self): 361 """Check that values passed into Polygon_function can be callable 362 themselves. 363 """ 364 p1 = [[0,0], [10,0], [10,10], [0,10]] 365 p2 = [[0,0], [10,10], [15,5], [20, 10], [25,0], [30,10], [40,-10]] 366 367 f = Polygon_function( [(p1, test_function)] ) 368 z = f([5, 5, 27, 35], [5, 9, 8, -5]) #Two first inside p1 369 assert allclose(z, [10,14,0,0]) 370 371 #Combined 372 f = Polygon_function( [(p1, test_function), (p2, 2.0)] ) 373 z = f([5, 5, 27, 35], [5, 9, 8, -5]) 374 assert allclose(z, [2,14,0,2]) 375 376 377 #Combined w default 378 f = Polygon_function( [(p1, test_function), (p2, 2.0)], default = 3.14) 379 z = f([5, 5, 27, 35], [5, 9, 8, -5]) 380 assert allclose(z, [2,14,3.14,2]) 381 382 383 #Combined w default func 384 f = Polygon_function( [(p1, test_function), (p2, 2.0)], 385 default = test_function) 386 z = f([5, 5, 27, 35], [5, 9, 8, -5]) 387 assert allclose(z, [2,14,35,2]) 355 388 356 389 … … 467 500 assert inside_polygon( (10.5, 10.5), polygon ) 468 501 469 #FIXME: Fails 470 #assert not inside_polygon( (5.5, 5.5), polygon )502 #FIXME: Fails if point is 5.5, 5.5 503 assert not inside_polygon( (0, 5.5), polygon ) 471 504 472 505 #Polygon with a hole … … 475 508 476 509 assert inside_polygon( (0, -0.5), polygon ) 477 478 #FIXME: Fails 479 #assert not inside_polygon( (0.5, 0.5), polygon ) 510 assert not inside_polygon( (0.5, 0.5), polygon ) 480 511 481 512
Note: See TracChangeset
for help on using the changeset viewer.