Changeset 6232 for anuga_validation
- Timestamp:
- Jan 23, 2009, 2:44:41 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_validation/okushiri_2005/test_caching_of_set_quantity.py
r6196 r6232 26 26 # Module imports 27 27 from anuga.shallow_water import Domain 28 from anuga.caching import cache 29 from anuga.fit_interpolate.fit import _fit_to_mesh 28 30 import project 31 import Numeric as num 29 32 33 internal_verbose = False # Verbose used in set_quantity and passed into fit_to_mesh 34 35 filename=project.bathymetry_filename 36 alpha=0.02 37 from anuga.config import points_file_block_line_size as max_read_lines 30 38 31 39 #------------------------- 32 40 # Create Domain from mesh 33 41 #------------------------- 34 domain = Domain(project.mesh_filename, use_cache=True, verbose=True) 42 domain = cache(Domain, (project.mesh_filename, {'verbose': True}), verbose=False) 43 44 # Clear caching of underlying function 45 args = (filename, ) 46 kwargs = {'vertex_coordinates': None, 47 'triangles': None, 48 'mesh': domain.mesh, 49 'point_attributes': None, 50 'alpha': alpha, 51 'verbose': internal_verbose, 52 'acceptable_overshoot': 1.01, # This is the default value in _fit_to_mesh 53 'mesh_origin': None, 54 'data_origin': None, 55 'max_read_lines': max_read_lines, 56 'attribute_name': None 57 } 58 59 60 cache(_fit_to_mesh, 61 args, 62 kwargs, 63 verbose=False, 64 dependencies=[filename], 65 clear=True) 66 67 # Check that cache is empty 68 flag = cache(_fit_to_mesh, 69 args, 70 kwargs, 71 verbose=False, 72 dependencies=[filename], 73 test=True) 74 assert flag is None 75 35 76 36 77 … … 38 79 # Initial Conditions 39 80 #------------------------- 40 print 'Set elevation and cache'81 #print 'Set elevation and cache' 41 82 domain.set_quantity('elevation', 42 filename= project.bathymetry_filename,83 filename=filename, 43 84 alpha=0.02, 44 verbose= True,85 verbose=internal_verbose, 45 86 use_cache=True) 87 88 ref = domain.get_quantity('elevation').get_values() 46 89 47 print 'Try to read in via cache' 90 # Check that cache is now present (and correct) 91 flag = cache(_fit_to_mesh, 92 args, 93 kwargs, 94 verbose=False, 95 dependencies=[filename], 96 test=True) 97 assert flag is not None 98 res = domain.get_quantity('elevation').get_values() 99 assert num.allclose(res, ref) 100 101 # Now check this using the high level call 102 #print 'Try to read in via cache' 48 103 domain.set_quantity('elevation', 49 filename= project.bathymetry_filename,104 filename=filename, 50 105 alpha=0.02, 51 verbose= True,106 verbose=internal_verbose, 52 107 use_cache=True) 108 109 res = domain.get_quantity('elevation').get_values() 110 assert num.allclose(res, ref)
Note: See TracChangeset
for help on using the changeset viewer.