Changeset 1928
- Timestamp:
- Oct 14, 2005, 5:08:29 PM (19 years ago)
- Location:
- inundation/pyvolution
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/pyvolution/domain.py
r1924 r1928 155 155 """ 156 156 157 #FIXME (Ole): Allow new quantities 158 159 157 #FIXME (Ole): Allow new quantities here 160 158 #from quantity import Quantity, Conserved_quantity 161 162 159 #Create appropriate quantity object 163 160 ##if name in self.conserved_quantities: … … 172 169 del kwargs['expression'] 173 170 174 Q = create_quantity_from_expression(self, expression) 175 171 Q = self.create_quantity_from_expression(expression) 176 172 kwargs['quantity'] = Q 177 173 178 179 180 174 175 #Assign values 181 176 self.quantities[name].set_values(*args, **kwargs) 182 177 … … 200 195 201 196 197 def create_quantity_from_expression(self, expression): 198 """Create new quantity from other quantities using arbitrary expression 199 200 Combine existing quantities in domain using expression and return 201 result as a new quantity. 202 203 Note, the new quantity could e.g. be used in set_quantity 204 205 Valid expressions are limited to operators defined in class Quantity 206 207 Example: 208 209 210 """ 211 212 from util import apply_expression_to_dictionary 213 return apply_expression_to_dictionary(expression, self.quantities) 214 202 215 203 216 … … 707 720 708 721 709 def create_quantity_from_expression(domain, expression):710 """Create new quantity from other quantities using arbitrary expression711 712 Combine existing quantities in domain using expression and return713 result as a new quantity.714 715 Note, the new quantity could e.g. be used in set_quantity716 717 Valid expressions are limited to operators defined in class Quantity718 719 Example:720 721 722 """723 724 from util import apply_expression_to_dictionary725 return apply_expression_to_dictionary(expression, domain.quantities)726 727 722 728 723 -
inundation/pyvolution/quantity.py
r1924 r1928 255 255 msg = 'Exactly one of the arguments '+\ 256 256 'numeric, quantity, function, points, or filename '+\ 257 'must be present. L = %s' %str(L)257 'must be present.' 258 258 assert L.count(None) == len(L)-1, msg 259 259 -
inundation/pyvolution/test_domain.py
r1924 r1928 177 177 178 178 expression = 'stage - elevation' 179 Q = create_quantity_from_expression(domain,expression)179 Q = domain.create_quantity_from_expression(expression) 180 180 181 181 assert allclose(Q.vertex_values, [[2,3,4], [6,6,6], … … 183 183 184 184 expression = '(xmomentum*xmomentum + ymomentum*ymomentum)**0.5' 185 Q = create_quantity_from_expression(domain,expression)185 Q = domain.create_quantity_from_expression(expression) 186 186 187 187 X = domain.quantities['xmomentum'].vertex_values
Note: See TracChangeset
for help on using the changeset viewer.