Changeset 1753 for inundation/pyvolution/quantity.py
- Timestamp:
- Aug 24, 2005, 1:49:47 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/pyvolution/quantity.py
r1752 r1753 91 91 location = 'vertices', 92 92 indices = None, 93 verbose = None): 93 verbose = None, 94 use_cache = False): 94 95 95 96 """Set values for quantity based on different sources. … … 155 156 will be left undefined. 156 157 158 verbose: True means that output to stdout is generated 159 160 use_cache: True means that caching of intermediate results is 161 attempted for least squares fit. 162 163 164 157 165 158 166 Exactly one of the arguments … … 211 219 assert values is not None, msg 212 220 self.set_values_from_points(points, values, alpha, 213 location, indices, verbose) 221 location, indices, verbose, 222 use_cache) 214 223 elif filename is not None: 215 224 self.set_values_from_file(filename, attribute_name, alpha, 216 location, indices, verbose) 225 location, indices, verbose, 226 use_cache) 217 227 else: 218 228 raise 'This can\'t happen :-)' … … 437 447 438 448 def set_values_from_points(self, points, values, alpha, 439 location, indices, verbose): 440 """ 441 """ 442 443 444 #FIXME: Needs unit test 449 location, indices, verbose, use_cache): 450 """Set quantity values from arbitray data points using least squares 451 """ 452 453 from Numeric import Float 445 454 from util import ensure_numeric 446 455 from least_squares import fit_to_mesh … … 457 466 triangles = self.domain.triangles 458 467 459 #FIXME Pass and use caching here 460 vertex_attributes = fit_to_mesh(coordinates, 461 triangles, 462 points, 463 values, 464 alpha = alpha, 465 verbose = verbose) 468 if use_cache is True: 469 try: 470 from caching import cache 471 except: 472 msg = 'Caching was requested, but caching module'+\ 473 'could not be imported' 474 raise msg 475 476 args = (coordinates, triangles, points, values) 477 kwargs = {'alpha': alpha, 'verbose': verbose} 478 vertex_attributes = cache(fit_to_mesh, 479 args, kwargs, 480 verbose = verbose) 481 else: 482 vertex_attributes = fit_to_mesh(coordinates, 483 triangles, 484 points, 485 values, 486 alpha = alpha, 487 verbose = verbose) 488 466 489 467 490 self.set_values_from_array(vertex_attributes, … … 473 496 474 497 def set_values_from_file(self, filename, attribute_name, alpha, 475 location, indices, verbose ):498 location, indices, verbose, use_cache): 476 499 """Set quantity based on arbitrary points in .pts file 477 500 using least_squares attribute_name selects name of attribute … … 481 504 482 505 483 #FIXME: Needs unit test484 506 from types import StringType 485 507 msg = 'Filename must be a text string' … … 513 535 #Call least squares method 514 536 self.set_values_from_points(points, z, alpha, 515 location, indices, verbose )537 location, indices, verbose, use_cache) 516 538 517 539 … … 523 545 location: Where values are to be stored. 524 546 Permissible options are: vertices, edges, centroid 525 Default is "vertices"547 and unique vertices. Default is 'vertices' 526 548 527 549 In case of location == 'centroids' the dimension values must
Note: See TracChangeset
for help on using the changeset viewer.