Changeset 4160

Ignore:
Timestamp:
Jan 10, 2007, 2:23:45 PM (17 years ago)
Message:

Better error message and untabifying

Location:
anuga_core/source/anuga/abstract_2d_finite_volumes
Files:
2 edited

Unmodified
Removed
• anuga_core/source/anuga/abstract_2d_finite_volumes/test_util.py

 r4159 import time #Create sww file of simple propagation from left to right #through rectangular domain from shallow_water import Domain, Dirichlet_boundary #Create sww file of simple propagation from left to right #through rectangular domain from shallow_water import Domain, Dirichlet_boundary from mesh_factory import rectangular from Numeric import take, concatenate, reshape domain1.default_order = 2 domain1.store = True domain1.store = True domain1.set_datadir('.') domain1.set_name('spatio_temporal_boundary_source_%d' %(id(self))) finaltime = 8 #Evolution t0 = -1 t0 = -1 for t in domain1.evolve(yieldstep = 0.1, finaltime = finaltime): #print 'Timesteps: %.16f, %.16f' %(t0, t) #if t == t0: #    msg = 'Duplicate timestep found: %f, %f' %(t0, t) #   raise msg t0 = t #   raise msg t0 = t #domain1.write_time() msg = 'duplicate timesteps: %.16f and %.16f' %(T[-1], T[-2]) assert not T[-1] == T[-2], msg t = time[last_time_index] t = time[last_time_index] q = f(t, point_id=0); assert allclose(r0, q) q = f(t, point_id=1); assert allclose(r1, q) import time #Create sww file of simple propagation from left to right #through rectangular domain from shallow_water import Domain, Dirichlet_boundary #Create sww file of simple propagation from left to right #through rectangular domain from shallow_water import Domain, Dirichlet_boundary from mesh_factory import rectangular from Numeric import take, concatenate, reshape from anuga.utilities.numerical_tools import mean from anuga.utilities.numerical_tools import mean domain1.reduction = mean domain1.smooth = True #NOTE: Mimic sww output where each vertex has domain1.default_order = 2 domain1.store = True domain1.store = True domain1.set_datadir('.') domain1.set_name('spatio_temporal_boundary_source_%d' %(id(self))) #Diagonal is identified by vertices: 0, 5, 10, 15 last_time_index = len(time)-1 #Last last_time_index last_time_index = len(time)-1 #Last last_time_index d_stage = reshape(take(stage[last_time_index, :], [0,5,10,15]), (4,1)) d_uh = reshape(take(xmomentum[last_time_index, :], [0,5,10,15]), (4,1)) interpolation_points = d_midpoints) t = time[last_time_index] t = time[last_time_index] q = f(t, point_id=0); assert allclose(r0, q) q = f(t, point_id=1); assert allclose(r1, q) #Check that domain.starttime isn't updated if later than file starttime but earlier #than file end time delta = 23 delta = 23 domain.starttime = start + delta F = file_function(filename + '.sww', domain, #Check that domain.starttime isn't updated if later than file starttime but earlier #than file end time delta = 23 delta = 23 domain.starttime = start + delta F = file_function(filename + '.sww', domain, #Check that domain.starttime isn't updated if later than file starttime but earlier #than file end time delta = 23 delta = 23 domain.starttime = start + delta F = file_function(filename + '.tms', domain, """Test that obsolete call issues appropriate warning""" #Turn warning into an exception #Turn warning into an exception import warnings warnings.filterwarnings('error') warnings.filterwarnings('error') try: assert point_on_line( 0, 0.5, 0,1, 0,0 ) except DeprecationWarning: pass else: msg = 'point_on_line should have issued a DeprecationWarning' raise Exception(msg) warnings.resetwarnings() assert point_on_line( 0, 0.5, 0,1, 0,0 ) except DeprecationWarning: pass else: msg = 'point_on_line should have issued a DeprecationWarning' raise Exception(msg) warnings.resetwarnings() def test_get_version_info(self): int(fields[1]) except: msg = 'Revision number must be an integer. I got %s' %fields[1] msg = 'Revision number must be an integer. I got %s' %fields[1] msg += 'Chech that the command svn is on the system path' raise Exception(msg) raise Exception(msg) def test_add_directories(self): try: kens_dir = add_directories(root_dir, directories) except OSError: pass else: msg = 'bad dir name should give OSError' raise Exception(msg) except OSError: pass else: msg = 'bad dir name should give OSError' raise Exception(msg) #clean up!
• anuga_core/source/anuga/abstract_2d_finite_volumes/util.py

 r4159 # Create dummy info info = 'Revision: Version info could not be obtained.' info += 'A command line version of svn and access to the ' info += 'A command line version of svn must be availbable ' info += 'on the system PATH, access to the subversion ' info += 'repository is necessary and the output must ' info += 'contain a line starting with "Revision:"' fid = os.popen('svn info') except: msg = 'svn is not recognised' msg = 'svn is not recognised on the system PATH' warn(msg, UserWarning) else:
Note: See TracChangeset for help on using the changeset viewer.