Index: /branches/numpy_anuga_validation/automated_validation_tests/okushiri_tank_validation/test_caching_of_set_quantity.py
===================================================================
--- /branches/numpy_anuga_validation/automated_validation_tests/okushiri_tank_validation/test_caching_of_set_quantity.py	(revision 7039)
+++ /branches/numpy_anuga_validation/automated_validation_tests/okushiri_tank_validation/test_caching_of_set_quantity.py	(revision 7039)
@@ -0,0 +1,108 @@
+"""This script tests that caching works for set_quantity using point 
+data from a file.
+First cache is cleared, then set_quantity is run twice checking that
+fitting is evaluated only first time and that the result from cache on the
+second round is correct.
+
+This script depends on  Benchmark_2.msh and Benchmark_2_Bathymetry.pts
+"""
+
+# Module imports
+from anuga.shallow_water import Domain
+from anuga.caching import cache
+from anuga.fit_interpolate.fit import _fit_to_mesh
+import project
+import numpy as num
+import time
+
+internal_verbose = True # Verbosity used within this function
+
+filename=project.bathymetry_filename
+alpha=0.02
+from anuga.config import points_file_block_line_size as max_read_lines
+
+#-------------------------
+# Create Domain from mesh
+#-------------------------
+domain = cache(Domain, 
+               (project.mesh_filename, 
+                {'verbose': True}), 
+               verbose=False)
+
+# Clear caching of underlying function                                            
+args = (filename, )
+kwargs = {'vertex_coordinates': None,
+          'triangles': None,
+          'mesh': domain.mesh,
+          'point_attributes': None,
+          'alpha': alpha,
+          'verbose': internal_verbose,
+          'mesh_origin': None,
+          'data_origin': None,
+          'max_read_lines': max_read_lines,
+          'attribute_name': None 
+          }
+
+
+cache(_fit_to_mesh,
+      args, 
+      kwargs,
+      verbose=False,
+      dependencies=[filename],
+      clear=True)
+
+# Check that cache is empty      
+flag = cache(_fit_to_mesh,
+             args, 
+             kwargs,
+             verbose=False,
+             dependencies=[filename],
+             test=True)
+assert flag is None
+
+
+#-------------------------
+# Initial Conditions
+#-------------------------
+t0 = time.time()
+domain.set_quantity('elevation',
+                    filename=filename,
+                    alpha=0.02,                    
+                    verbose=internal_verbose,
+                    use_cache=True)
+compute_time = time.time()-t0
+                    
+ref = domain.get_quantity('elevation').get_values()                    
+
+# Check that cache is now present (and correct)
+flag = cache(_fit_to_mesh,
+             args, 
+             kwargs,
+             verbose=False,
+             dependencies=[filename],
+             test=True)
+             
+assert flag is not None
+res = domain.get_quantity('elevation').get_values()
+assert num.allclose(res, ref)
+
+# Now check this using the high level call
+print 'Try to read in via cache'
+t0 = time.time()
+domain.set_quantity('elevation',
+                    filename=filename,
+                    alpha=0.02,                    
+                    verbose=internal_verbose,
+                    use_cache=True)
+cache_time = time.time()-t0                    
+                    
+res = domain.get_quantity('elevation').get_values() 
+assert num.allclose(res, ref)
+
+print 'cache_time', cache_time
+print 'compute_time', compute_time
+
+msg = 'Caching did not speed things up as expected'
+msg += 'Compute time = %.f, Cache time = %.f' % (compute_time,
+                                                 cache_time)
+assert cache_time < compute_time/10, msg
Index: /branches/numpy_anuga_validation/automated_validation_tests/patong_beach_validation/run_model.py
===================================================================
--- /branches/numpy_anuga_validation/automated_validation_tests/patong_beach_validation/run_model.py	(revision 7038)
+++ /branches/numpy_anuga_validation/automated_validation_tests/patong_beach_validation/run_model.py	(revision 7039)
@@ -75,4 +75,7 @@
 
 # Create the STS file
+# FIXME (Ole): This is deadly dangerous if buildcode changes (as was the case 24th March 2009)
+# We need to use caching instead!
+
 log.critical( 'project.mux_data_folder=%s' % project.mux_data_folder)
 if not os.path.exists(project.event_sts + '.sts'):
Index: /branches/numpy_anuga_validation/automated_validation_tests/patong_beach_validation/validate.py
===================================================================
--- /branches/numpy_anuga_validation/automated_validation_tests/patong_beach_validation/validate.py	(revision 7038)
+++ /branches/numpy_anuga_validation/automated_validation_tests/patong_beach_validation/validate.py	(revision 7039)
@@ -47,5 +47,5 @@
 Optional_Data_Objects = ('patong.sww.TRIAL.tgz',
                          'patong.sww.BASIC.tgz',
-                         'patong.sww.FINAL.tgz',
+                         'patong.sww.FINAL.tgz'
                         )
 
Index: /branches/numpy_anuga_validation/okushiri_2005/test_caching_of_set_quantity.py
===================================================================
--- /branches/numpy_anuga_validation/okushiri_2005/test_caching_of_set_quantity.py	(revision 7038)
+++ /branches/numpy_anuga_validation/okushiri_2005/test_caching_of_set_quantity.py	(revision 7039)
@@ -1,3 +1,4 @@
-"""This script tests that caching works for set_quantity using point data from a file.
+"""This script tests that caching works for set_quantity using point 
+data from a file.
 First cache is cleared, then set_quantity is run twice checking that
 fitting is evaluated only first time and that the result from cache on the
