Changeset 5869


Ignore:
Timestamp:
Oct 27, 2008, 6:10:13 PM (15 years ago)
Author:
ole
Message:

Better caching of interpolation information. This one should also work on Win32.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/fit_interpolate/interpolate.py

    r5868 r5869  
    392392        f = ensure_numeric(f, Float)               
    393393
    394        
    395         # Hash point_coordinates to memory location and reuse if possible
    396394        from anuga.caching import myhash
    397395        from Numeric import alltrue
    398        
    399 
    400         key = myhash(point_coordinates)
    401        
    402         reuse_A = False       
    403         if self.interpolation_matrices.has_key(key):
    404             X, stored_points = self.interpolation_matrices[key]
    405             if alltrue(stored_points == point_coordinates):
    406                 reuse_A = True # Reuse interpolation matrix
     396        import sys
     397        if use_cache is True:
     398            if sys.platform != 'win32':
     399                # FIXME (Ole): (Why doesn't this work on windoze?)
     400                # Still absolutele fails on Win 24 Oct 2008
     401           
     402                X = cache(self._build_interpolation_matrix_A,
     403                          args=(point_coordinates,),
     404                          kwargs={'verbose': verbose},                       
     405                          verbose=verbose)       
     406            else:
     407                # Hash point_coordinates to memory location and reuse if possible
     408                # This will work on Linux as well if we want to use it there. (FIXME)
     409                key = myhash(point_coordinates)
     410       
     411                reuse_A = False       
     412                if self.interpolation_matrices.has_key(key):
     413                    X, stored_points = self.interpolation_matrices[key]
     414                    if alltrue(stored_points == point_coordinates):
     415                        reuse_A = True # Reuse interpolation matrix
    407416               
    408         if reuse_A is False:
     417                if reuse_A is False:
     418                    X = self._build_interpolation_matrix_A(point_coordinates,
     419                                                           verbose=verbose)
     420                    self.interpolation_matrices[key] = (X, point_coordinates)
     421        else:
    409422            X = self._build_interpolation_matrix_A(point_coordinates,
    410                                                    verbose=verbose)
    411             self.interpolation_matrices[key] = (X, point_coordinates)
     423                                                   verbose=verbose)           
    412424                                                       
    413425       
Note: See TracChangeset for help on using the changeset viewer.