Changeset 2305


Ignore:
Timestamp:
Jan 31, 2006, 12:33:19 PM (19 years ago)
Author:
ole
Message:

Fixed problem with leaking files from tests as per ticket:42

Location:
inundation
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • inundation/README.txt

    r2179 r2305  
    88
    99
    10 This is the top directory for the inundation project developed at the
    11 Risk Assessment Methods Project at Geoscience Australia and
    12 Mathematical Sciences Institute at the Australian National University.
     10This is the top directory for the inundation project source code
     11developed at the Risk Assessment Methods Project at Geoscience
     12Australia and Mathematical Sciences Institute at the Australian
     13National University.
    1314
    1415
    15 Copyright 2004 
    16 Ole Nielsen, Stephen Roberts, Duncan Gray, Christopher Zoppou
     16Copyright 2004, 2005, 2006 
     17Ole Nielsen, Stephen Roberts, Duncan Gray, Jane Sexton, Christopher Zoppou
    1718
    1819
  • inundation/pyvolution/data_manager.py

    r2262 r2305  
    26692669
    26702670
    2671     domain = Domain(coordinates, volumes, boundary)
     2671    try:   
     2672        domain = Domain(coordinates, volumes, boundary)
     2673    except AssertionError, e:
     2674        fid.close()
     2675        msg = 'Domain could not be created: %s. Perhaps use "fail_if_NaN=False and NaN_filler = ..."' %e
     2676        raise msg
    26722677
    26732678    if not boundary is None:
     
    27282733            X = resize(X,(X.shape[0]/3,3))
    27292734        domain.set_quantity(quantity,X)
     2735       
    27302736    fid.close()
    27312737    return domain
     
    30003006    volumes = fid.variables['volumes'] #Connectivity
    30013007
     3008    #FIXME (Ole): What is this?
     3009    #             Why isn't anything returned?
     3010    #             Where's the unit test?
    30023011
    30033012def decimate_dem(basename_in, stencil, cellsize_new, basename_out=None,
  • inundation/pyvolution/test_data_manager.py

    r2304 r2305  
    141141           
    142142       
    143         fid.close()
     143            fid.close()
     144
    144145       
    145146
     
    147148    def tearDown(self):
    148149        import os
    149         #os.remove(self.test_MOST_file)
    150        
     150        for ext in ['_ha.nc', '_ua.nc', '_va.nc', '_e.nc']:
     151            #print 'Trying to remove', self.test_MOST_file + ext
     152            os.remove(self.test_MOST_file + ext)       
    151153
    152154    def test_sww_constant(self):
     
    18651867        #Done (Ole) - it was because sww2ers didn't close it's sww file
    18661868        os.remove(sww.filename)
     1869        os.remove(self.domain.filename + '_elevation')
     1870        os.remove(self.domain.filename + '_elevation.ers')                 
    18671871
    18681872
     
    18911895        first_value = fid.variables['HA'][:][0,0,0]
    18921896        fourth_value = fid.variables['HA'][:][0,0,3]
     1897        fid.close()
    18931898
    18941899
     
    19301935        #Cleanup
    19311936        import os
    1932         #os.remove('small.sww')
    19331937        os.remove(self.test_MOST_file + '.sww')
    19341938
     
    22322236
    22332237
    2234     def test_sww2domain(self):
     2238    def test_sww2domain1(self):
    22352239        ################################################
    22362240        #Create a test domain, and evolve and save it.
     
    22982302        ###################
    22992303
    2300         os.remove(domain.filename + '.sww')
     2304        #os.remove(domain.filename + '.sww')
     2305        os.remove(filename)       
    23012306
    23022307        bits = ['vertex_coordinates']
     
    23902395        domain.visualise = False
    23912396        domain.store = True
    2392         domain.filename = 'bedslope'
     2397        domain.set_name('test_file')
     2398        domain.set_datadir('.')
    23932399        domain.default_order=2
    23942400        domain.quantities_to_be_stored=['stage']
     
    24302436        try:
    24312437            domain2 = sww2domain(filename,boundary,fail_if_NaN=True,verbose=False)
    2432             assert True == False
    24332438        except:
    24342439            #Now import it, filling NaNs to be 0
     
    24362441            domain2 = sww2domain(filename,None,fail_if_NaN=False,NaN_filler = filler,verbose=False)
    24372442
     2443        #Clean up
     2444        os.remove(filename)
    24382445           
    24392446
     
    24552462        assert min(min(domain2.get_quantity('ymomentum')))==filler
    24562463
    2457         #print 'passed'
    2458 
    2459         #FIXME (DSG-all) this doesn't work (in windows), due to permitions
    2460         #it the file is created in the temp area this problem
    2461         # might be avoided
    2462        
    2463         #cleanup
    2464         #import os
    2465         #os.remove(domain.datadir+'/'+domain.filename+'.sww')
    2466         for filename in os.listdir('.'):
    2467             if filename.endswith('sww'):
    2468                 print filename
    2469         os.remove(domain.filename + '.sww')       
    24702464
    24712465
  • inundation/pyvolution/test_shallow_water.py

    r1835 r2305  
    726726                assert not allclose(stage, initial_stage)
    727727
     728        os.remove(domain.filename + '.sww')
    728729
    729730
     
    10131014        from data_manager import timefile2netcdf       
    10141015        timefile2netcdf(filename)
    1015 
     1016        os.remove(filename + '.txt')
    10161017
    10171018       
     
    10191020        F = file_function(filename + '.tms', quantities = ['Attribute0',
    10201021                                                           'Attribute1'])
     1022        os.remove(filename + '.tms')
     1023       
    10211024
    10221025        #print 'F(5)', F(5)
     
    10671070            assert allclose(domain.quantities['ymomentum'].explicit_update[k], S*v)
    10681071
    1069         #os.remove(filename + '.txt')
     1072
     1073       
    10701074
    10711075    def test_wind_stress_error_condition(self):
     
    16071611            #assert allclose (xmom, initial_xmom)
    16081612
     1613        os.remove(domain.filename + '.sww')
    16091614
    16101615
     
    16591664            #assert allclose (xmom, initial_xmom)
    16601665
     1666        os.remove(domain.filename + '.sww')
    16611667
    16621668    def test_conservation_3(self):
     
    17341740            assert allclose (volume, initial_volume)
    17351741
     1742        os.remove(domain.filename + '.sww')
    17361743
    17371744    def test_conservation_4(self):
     
    18201827
    18211828
    1822 
     1829        os.remove(domain.filename + '.sww')
    18231830
    18241831
     
    18831890
    18841891
    1885 
     1892        os.remove(domain.filename + '.sww')
    18861893
    18871894
     
    19511958        assert allclose(ref, now), msg
    19521959
    1953 
     1960        os.remove(domain.filename + '.sww')
    19541961
    19551962    def test_second_order_flat_bed_onestep(self):
     
    20202027                         -1.22721531e-004, -4.57969873e-005])
    20212028
     2029        os.remove(domain.filename + '.sww')
    20222030
    20232031
     
    20522060        #assert allclose(domain.max_timestep, 0.0396825396825)
    20532061        #print domain.quantities['stage'].centroid_values
     2062
     2063        os.remove(domain.filename + '.sww')       
    20542064
    20552065
     
    20972107            #assert allclose(domain.quantities['ymomentum'].edge_values[:4,i],
    20982108            #                [-0.0060238, -0.00157404, -0.00309633, -0.0001637])
     2109
     2110
     2111        os.remove(domain.filename + '.sww')           
    20992112
    21002113    def test_flatbed_second_order(self):
     
    21482161                        [-0.00139463,0.0006156,-0.00060364,0.00061827])
    21492162
     2163
     2164        os.remove(domain.filename + '.sww')
    21502165
    21512166
     
    22912306            #                [0.00090581,0.03685719,0.00088303,0.03687313])
    22922307
    2293 
     2308        os.remove(domain.filename + '.sww')
    22942309
    22952310
     
    23312346
    23322347
     2348        os.remove(domain.filename + '.sww')
     2349       
    23332350    def test_bedslope_problem_first_order_moresteps(self):
    23342351
     
    23932410                        -0.14439383, -0.13924047, -0.14829043])
    23942411
    2395 
     2412        os.remove(domain.filename + '.sww')
     2413       
    23962414    def test_bedslope_problem_second_order_one_step(self):
    23972415
     
    24792497                  -0.25865535, -0.24776246, -0.25865535, -0.24521113])
    24802498
    2481 
     2499        os.remove(domain.filename + '.sww')
    24822500
    24832501    def test_bedslope_problem_second_order_two_steps(self):
     
    25722590
    25732591
    2574 
     2592        os.remove(domain.filename + '.sww')
    25752593
    25762594    def test_bedslope_problem_second_order_two_yieldsteps(self):
     
    26612679                  -0.24286438])
    26622680
    2663 
     2681        os.remove(domain.filename + '.sww')
    26642682
    26652683    def test_bedslope_problem_second_order_more_steps(self):
     
    27772795      -4.50964850e-003, -3.06319963e-003,  6.08950810e-004, -4.79537921e-004])
    27782796
    2779 
     2797        os.remove(domain.filename + '.sww')
    27802798
    27812799
     
    28212839                        -6.39083123e-005, 6.29815168e-005])
    28222840
     2841        os.remove(domain.filename + '.sww')
    28232842
    28242843    def test_complex_bed(self):
     
    28982917# -5.48333333e-001, -5.31666667e-001, -5.48333333e-001, -5.31666667e-001])
    28992918
    2900 
    2901 
    2902     def test_spatio_temporal_boundary(self):
     2919        os.remove(domain.filename + '.sww')
     2920
     2921    def test_spatio_temporal_boundary_1(self):
    29032922        """Test that boundary values can be read from file and interpolated
    29042923        in both time and space.
     
    30183037        #Cleanup
    30193038        os.remove(domain1.filename + '.' + domain1.format)
     3039        os.remove(domain2.filename + '.' + domain2.format)       
    30203040
    30213041
Note: See TracChangeset for help on using the changeset viewer.