Changeset 1108
- Timestamp:
- Mar 18, 2005, 4:21:58 PM (20 years ago)
- Location:
- inundation/ga/storm_surge/pyvolution
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/ga/storm_surge/pyvolution/region.py
r715 r1108 91 91 location=self.location) 92 92 93 class Add_quantities(Region): 94 """ 95 Will add a value to the current quantity value. 96 """ 97 98 def __init__(self, tag, quantity_answer, adding_quantity, location='vertices'): 99 #I have to get this going! 100 #Region.__init__(self) 101 self.tag = tag 102 self.quantity_answer = quantity_answer 103 self.adding_quantity = adding_quantity 104 self.location = location 105 106 def __repr__(self): 107 pass 108 109 def __call__(self, tag, elements, domain): 110 """ 111 """ 112 if tag == self.tag: 113 114 new_values = domain.get_quantity(self.quantity_answer, 115 indexes=self.build_indexes(elements, domain), 116 location=self.location) \ 117 + domain.get_quantity(self.adding_quantity, 118 indexes=self.build_indexes(elements, domain), 119 location=self.location) 120 domain.set_quantity(self.quantity_answer, new_values, 121 indexes=self.build_indexes(elements, domain), 122 location=self.location) 123 93 124 94 125 class Stage_no_less_than_elevation(Region): -
inundation/ga/storm_surge/pyvolution/test_region.py
r1018 r1108 12 12 def add_x_y(x, y): 13 13 return x+y 14 15 def give_me_23(x, y): 16 return 23.0 14 17 15 18 class Test_Region(unittest.TestCase): … … 90 93 [ 11.0, 11.0, 11.0]]) 91 94 95 96 domain.set_quantity('elevation', 10.0) 97 domain.set_quantity('stage', give_me_23) 98 domain.set_region(Add_quantities('top', 'elevation','stage')) 99 #print domain.quantities['elevation'].get_values() 100 assert allclose(domain.quantities['elevation'].get_values(), 101 [[ 10., 10., 10.], 102 [ 10., 10., 10.], 103 [ 10., 10., 10.], 104 [ 10., 10., 10.], 105 [ 33., 33.0, 33.], 106 [ 33.0, 33., 33.]]) 107 92 108 def test_unique_vertices(self): 93 109 """
Note: See TracChangeset
for help on using the changeset viewer.