Changeset 279 for inundation/ga/storm_surge/pyvolution-1d/test_domain.py
- Timestamp:
- Sep 7, 2004, 5:24:43 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/ga/storm_surge/pyvolution-1d/test_domain.py
r256 r279 10 10 class TestCase(unittest.TestCase): 11 11 def setUp(self): 12 12 pass 13 14 15 def tearDown(self): 16 pass 17 18 19 def test_construct(self): 20 13 21 a = 0.0 14 22 b = 2.0 … … 20 28 points = [a, b, c, d, e, f] 21 29 22 self.points = [a, b, c, d, e, f] 23 self.domain = Domain(self.points) 24 25 26 def tearDown(self): 27 pass 30 domain = Domain(points) 31 assert allclose(domain.get_centroids(),[(a+b)*0.5, (b+c)*0.5, (c+d)*0.5, (d+e)*0.5, (e+f)*0.5]) 28 32 29 33 30 def test_ construct(self):34 def test_area(self): 31 35 32 domain = self.domain 33 centroids = domain.get_centroids() 34 assert allclose(centroids, [1.0, 2.25, 2.75, 6.5, 11.0]) 35 36 a = 0.0 37 b = 2.0 38 c = 2.5 39 d = 3.0 40 e = 10.0 41 f = 12.0 42 43 points = [a, b, c, d, e, f] 44 45 domain = Domain(points) 46 assert allclose(domain.get_area(0),b-a) 47 assert allclose(domain.get_area(1),c-b) 48 assert allclose(domain.get_area(2),d-c) 49 assert allclose(domain.get_area(3),e-d) 50 assert allclose(domain.get_area(4),f-e) 51 36 52 def test_in_order(self): 37 53 a = 0.0 … … 62 78 domain = Domain(points) 63 79 64 assert allclose(domain.get_ point(0), 0.5*(a+b))65 assert allclose(domain.get_ point(1), 0.5*(b+c))66 assert allclose(domain.get_ point(2), 0.5*(c+d))80 assert allclose(domain.get_coordinate(0), 0.5*(a+b)) 81 assert allclose(domain.get_coordinate(1), 0.5*(b+c)) 82 assert allclose(domain.get_coordinate(2), 0.5*(c+d)) 67 83 68 84 try: 69 allclose(domain.get_ point(3), 0.5*(a+b))85 allclose(domain.get_coordinate(3), 0.5*(a+b)) 70 86 except: 71 87 pass … … 74 90 raise msg 75 91 76 assert allclose(domain.get_ point(0,0), a)77 assert allclose(domain.get_ point(1,0), b)78 assert allclose(domain.get_ point(2,0), c)92 assert allclose(domain.get_coordinate(0,0), a) 93 assert allclose(domain.get_coordinate(1,0), b) 94 assert allclose(domain.get_coordinate(2,0), c) 79 95 80 assert allclose(domain.get_ point(0,1), b)81 assert allclose(domain.get_ point(1,1), c)82 assert allclose(domain.get_ point(2,1), d)96 assert allclose(domain.get_coordinate(0,1), b) 97 assert allclose(domain.get_coordinate(1,1), c) 98 assert allclose(domain.get_coordinate(2,1), d) 83 99 84 100
Note: See TracChangeset
for help on using the changeset viewer.