Changeset 8124


Ignore:
Timestamp:
Mar 3, 2011, 6:04:03 PM (14 years ago)
Author:
wilsonr
Message:

Made changes described in ticket 359.

Location:
trunk/anuga_core/source/anuga
Files:
48 edited

Legend:

Unmodified
Added
Removed
  • trunk/anuga_core/source/anuga/__init__.py

    r8118 r8124  
    249249            msg = 'Caching was requested, but caching module'+\
    250250                  'could not be imported'
    251             raise msg
     251            raise (msg)
    252252
    253253
  • trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/ermapper_grids.py

    r7317 r8124  
    176176    #    else:
    177177    #        msg = 'Format %s is not yet defined by celltype_map' %data_format
    178     #        raise msg
     178    #        raise Exception(msg)
    179179       
    180180   
  • trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/file_function.py

    r8118 r8124  
    215215        # suggestion about reading hydrographs.
    216216        # This may also deal with the gist of ticket:289
    217         raise 'Must be a NetCDF File'
     217        raise Exception('Must be a NetCDF File')
    218218
    219219
     
    271271    if quantity_names is None or len(quantity_names) < 1:
    272272        msg = 'No quantities are specified in file_function'
    273         raise Exception, msg
     273        raise Exception(msg)
    274274 
    275275    if interpolation_points is not None:
     
    289289              % (str(missing), filename)
    290290        fid.close()
    291         raise Exception, msg
     291        raise Exception(msg)
    292292
    293293    # Decide whether this data has a spatial dimension
     
    298298
    299299    if filename[-3:] == 'tms' and spatial is True:
    300         msg = 'Files of type tms must not contain spatial information'
     300        msg = 'Files of type TMS must not contain spatial information'
    301301        raise Exception(msg)
    302302
    303303    if filename[-3:] == 'sww' and spatial is False:
    304         msg = 'Files of type sww must contain spatial information'       
     304        msg = 'Files of type SWW must contain spatial information'       
    305305        raise Exception(msg)
    306306
    307307    if filename[-3:] == 'sts' and spatial is False:
    308308        #What if mux file only contains one point
    309         msg = 'Files of type sts must contain spatial information'       
     309        msg = 'Files of type STS must contain spatial information'       
    310310        raise Exception(msg)
    311311
     
    414414               != len(temp)-1:
    415415                msg='incorrect number of segments'
    416                 raise msg
     416                raise Exception(msg)
    417417            vertex_coordinates=ensure_numeric(temp)
    418418            if len(vertex_coordinates)==0:
    419419                msg = 'None of the sts gauges fall on the boundary'
    420                 raise msg
     420                raise Exception(msg)
    421421        else:
    422422            gauge_neighbour_id=None
  • trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/gauge.py

    r8063 r8124  
    156156    except Exception, e:
    157157        msg = 'File "%s" could not be opened: Error="%s"' % (gauge_file, e)
    158         raise msg
     158        raise Exception(msg)
    159159
    160160    if verbose: log.critical('Gauges obtained from: %s' % gauge_file)
     
    193193    else:
    194194        msg = 'File "%s" could not be opened: no read permission' % sww_file
    195         raise msg
     195        raise Exception(msg)
    196196
    197197    sww_files = get_all_swwfiles(look_in_dir=dir_name,
     
    453453    except Exception, e:
    454454        msg = 'File "%s" could not be opened: Error="%s"' % (gauge_filename, e)
    455         raise msg
     455        raise Exception(msg)
    456456
    457457    if report is None:
     
    491491        except Exception, e:
    492492            msg = 'File "%s" could not be opened: Error="%s"' % (swwfile, e)
    493             raise msg
     493            raise Exception(msg)
    494494
    495495        if verbose:
     
    543543        if time_min < theminT: # min(T):
    544544            msg = 'Minimum time entered not correct - please try again'
    545             raise Exception, msg
     545            raise Exception(msg)
    546546
    547547    if time_max is None:
     
    550550        if time_max > themaxT: # max(T):
    551551            msg = 'Maximum time entered not correct - please try again'
    552             raise Exception, msg
     552            raise Exception(msg)
    553553
    554554    if verbose and len(gauge_index) > 0:
     
    611611                  % filename
    612612            msg += 'The header must be: easting, northing, name, elevation'
    613             raise Exception, msg
     613            raise Exception(msg)
    614614
    615615        if elev_index is None:
  • trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/generic_boundary_conditions.py

    r7573 r8124  
    2626    def evaluate(self, vol_id=None, edge_id=None):
    2727        msg = 'Generic class Boundary must be subclassed'
    28         raise Exception, msg
     28        raise Exception(msg)
    2929
    3030
     
    4141        if domain is None:
    4242            msg = 'Domain must be specified for transmissive boundary'
    43             raise Exception, msg
     43            raise Exception(msg)
    4444
    4545        self.domain = domain
     
    7373        if conserved_quantities is None:
    7474            msg = 'Must specify one value for each conserved quantity'
    75             raise Exception, msg
     75            raise Exception(msg)
    7676
    7777        self.conserved_quantities=num.array(conserved_quantities, num.float)
     
    116116
    117117        if domain is None:
    118             raise Exception, 'You must specify a domain to Time_boundary'
     118            raise Exception('You must specify a domain to Time_boundary')
    119119
    120120        # FIXME: Temporary code to deal with both f and function
    121121        if function is not None and f is not None:
    122             raise Exception, 'Specify either function or f to Time_boundary'
     122            raise Exception('Specify either function or f to Time_boundary')
    123123           
    124124        if function is None and f is None:
    125             raise Exception, 'You must specify a function to Time_boundary'
     125            raise Exception('You must specify a function to Time_boundary')
    126126           
    127127        if f is None:
     
    133133        except Exception, e:
    134134            msg = 'Function for time boundary could not be executed:\n%s' %e
    135             raise msg
     135            raise Exception(msg)
    136136
    137137
     
    143143            msg += 'Specified function should return either list or array.\n'
    144144            msg += 'I got %s' %str(q)
    145             raise msg
     145            raise Exception(msg)
    146146
    147147        msg = 'ERROR: Time boundary function must return a 1d list or array '
     
    163163            res = self.f(self.domain.time)
    164164        except Modeltime_too_early, e:
    165             raise Modeltime_too_early, e
     165            raise Modeltime_too_early(e)
    166166        except Modeltime_too_late, e:
    167167            if self.default_boundary is None:
    168                 raise Exception, e # Reraise exception
     168                raise Exception(e) # Reraise exception
    169169            else:
    170170                # Pass control to default boundary
     
    223223       
    224224        if function is None:
    225             raise Exception, 'You must specify a function to Time_space_boundary'
     225            raise Exception('You must specify a function to Time_space_boundary')
    226226           
    227227        try:
     
    229229        except Exception, e:
    230230            msg = 'Function for time_space_boundary could not be executed:\n%s' %e
    231             raise msg
     231            raise Exception(msg)
    232232
    233233
     
    239239            msg += 'Specified function should return either list or array.\n'
    240240            msg += 'I got %s' %str(q)
    241             raise msg
     241            raise Exception(msg)
    242242
    243243        msg = 'ERROR: Time_space_boundary function must return a 1d list or array '
     
    262262            res = self.function(self.domain.get_time(), x, y)
    263263        except Modeltime_too_early, e:
    264             raise Modeltime_too_early, e
     264            raise Modeltime_too_early(e)
    265265        except Modeltime_too_late, e:
    266266            if self.default_boundary is None:
    267                 raise Exception, e # Reraise exception
     267                raise Exception(e) # Reraise exception
    268268            else:
    269269                # Pass control to default boundary
     
    437437                res = self.F(t, point_id=i)
    438438            except Modeltime_too_early, e:
    439                 raise Modeltime_too_early, e
     439                raise Modeltime_too_early(e)
    440440            except Modeltime_too_late, e:
    441441                if self.default_boundary is None:
    442                     raise Exception, e # Reraise exception
     442                    raise Exception(e) # Reraise exception
    443443                else:
    444444                    # Pass control to default boundary
     
    486486                        msg += 'the file %s.\n' %self.F.filename
    487487                        msg += 'Check this file for NANs.'
    488                 raise Exception, msg
     488                raise Exception(msg)
    489489           
    490490            return res
     
    492492            msg = 'Boundary call without point_id not implemented.\n'
    493493            msg += 'vol_id=%s, edge_id=%s' %(str(vol_id), str(edge_id))
    494             raise Exception, msg
     494            raise Exception(msg)
    495495
    496496class AWI_boundary(Boundary):
     
    641641                        msg += 'the file %s.\n' % self.F.filename
    642642                        msg += 'Check this file for NANs.'
    643                 raise Exception, msg
     643                raise Exception(msg)
    644644           
    645645            q[0] = res[0] # Take stage, leave momentum alone
  • trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/generic_domain.py

    r8073 r8124  
    413413            msg = 'Values for both vertex and edge was specified.'
    414414            msg += 'Only one (or none) is allowed.'
    415             raise Exception, msg
     415            raise Exception(msg)
    416416
    417417        q = num.zeros(len(self.conserved_quantities), num.float)
     
    452452            msg = 'Values for both vertex and edge was specified.'
    453453            msg += 'Only one (or none) is allowed.'
    454             raise Exception, msg
     454            raise Exception(msg)
    455455
    456456        q = num.zeros(len(self.evolved_quantities), num.float)
     
    828828                msg += 'in set_boundary.\n'
    829829                msg += 'The tags are: %s' %self.get_boundary_tags()
    830                 raise Exception, msg
     830                raise Exception(msg)
    831831
    832832    ##
     
    942942
    943943                if polygon in self.quantities:
    944                     raise Exception, msg
     944                    raise Exception(msg)
    945945
    946946                try:
     
    950950                    pass
    951951                else:
    952                     raise Exception, msg
     952                    raise Exception(msg)
    953953
    954954                # In any case, we don't allow polygon to be a string
    955955                msg = ('argument "polygon" must not be a string: '
    956956                       'I got polygon="%s"') % polygon
    957                 raise Exception, msg
     957                raise Exception(msg)
    958958
    959959            # Get indices for centroids that are inside polygon
     
    13301330
    13311331        msg = '%s is an incorrect timestepping type' % timestepping_method
    1332         raise Exception, msg
     1332        raise Exception(msg)
    13331333
    13341334    ##
     
    14441444        if finaltime is not None and duration is not None:
    14451445            msg = 'Only one of finaltime and duration may be specified'
    1446             raise Exception, msg
     1446            raise Exception(msg)
    14471447        else:
    14481448            if finaltime is not None:
     
    15311531                    # Now changed to Exception.
    15321532                    msg = ('WARNING (domain.py): time overshot finaltime. ')
    1533                     raise Exception, msg
     1533                    raise Exception(msg)
    15341534
    15351535                # Log and then Yield final time and stop
     
    18081808            msg = 'Method conserved_values_to_evolved_values must be overridden'
    18091809            msg += ' by Domain subclass'
    1810             raise Exception, msg
     1810            raise Exception(msg)
    18111811
    18121812        return q_evol
     
    18461846                    msg = 'Boundary must return array of either conserved'
    18471847                    msg += ' or evolved quantities'
    1848                     raise Exception, msg
     1848                    raise Exception(msg)
    18491849               
    18501850                for j, name in enumerate(self.evolved_quantities):
     
    18571857    def compute_fluxes(self):
    18581858        msg = 'Method compute_fluxes must be overridden by Domain subclass'
    1859         raise Exception, msg
     1859        raise Exception(msg)
    18601860
    18611861
     
    19361936                    log.critical(stats)
    19371937
    1938                     raise Exception, msg
     1938                    raise Exception(msg)
    19391939                else:
    19401940                    # Try to overcome situation by switching to 1 order
     
    20332033                Q.extrapolate_second_order()
    20342034            else:
    2035                 raise Exception, 'Unknown order'
     2035                raise Exception('Unknown order: %s' % str(self._order_))
    20362036
    20372037    ##
  • trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/mesh_factory.py

    r8009 r8124  
    685685                              int(float(fields[2]))-1])
    686686        else:
    687             raise 'wrong format in ' + filename
     687            raise Excetion('wrong format in %s' % filename)
    688688
    689689    elements = [] #Final list of elements
  • trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/neighbour_mesh.py

    r8070 r8124  
    262262            if neighbourdict.has_key((a,b)):
    263263                    msg = "Edge 2 of triangle %d is duplicating edge %d of triangle %d.\n" %(i,neighbourdict[a,b][1],neighbourdict[a,b][0])
    264                     raise Exception, msg
     264                    raise Exception(msg)
    265265            if neighbourdict.has_key((b,c)):
    266266                    msg = "Edge 0 of triangle %d is duplicating edge %d of triangle %d.\n" %(i,neighbourdict[b,c][1],neighbourdict[b,c][0])
    267                     raise msg
     267                    raise Exception(msg)
    268268            if neighbourdict.has_key((c,a)):
    269269                    msg = "Edge 1 of triangle %d is duplicating edge %d of triangle %d.\n" %(i,neighbourdict[c,a][1],neighbourdict[c,a][0])
    270                     raise msg
     270                    raise Exception(msg)
    271271
    272272            neighbourdict[a,b] = (i, 2) #(id, edge)
     
    427427            msg = 'Boundary dictionary must be defined before '
    428428            msg += 'building boundary structure'
    429             raise msg
     429            raise Exception(msg)
    430430
    431431
     
    505505            if p0 is None:
    506506                msg = 'Impossible: p0 is None!?'
    507                 raise Exception, msg
     507                raise Exception(msg)
    508508
    509509            # Register potential paths from A to B
     
    876876        if is_outside_polygon(point, polygon):
    877877            msg = 'Point %s is outside mesh' %str(point)
    878             raise Exception, msg
     878            raise Exception(msg)
    879879
    880880
     
    889889
    890890        msg = 'Point %s not found within a triangle' %str(point)
    891         raise Exception, msg
     891        raise Exception(msg)
    892892
    893893
  • trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/quantity.py

    r8123 r8124  
    423423            if indices is not None:
    424424                msg = 'Only one of polygon and indices can be specified'
    425                 raise Exception, msg
     425                raise Exception(msg)
    426426
    427427            msg = 'With polygon selected, set_quantity must provide '
     
    429429            msg += 'a constant.'
    430430            if numeric is None:
    431                 raise Exception, msg
     431                raise Exception(msg)
    432432            else:
    433433                # Check that numeric is as constant
     
    457457        if location == 'edges':
    458458            msg = 'edges has been deprecated as valid location'
    459             raise Exception, msg
     459            raise Exception(msg)
    460460
    461461        if location not in ['vertices', 'centroids', 'unique vertices']:
    462462            msg = 'Invalid location: %s' % location
    463             raise Exception, msg
     463            raise Exception(msg)
    464464
    465465        msg = 'Indices must be a list, array or None'
     
    488488                    msg = ("Illegal type for variable 'numeric': %s"
    489489                           % type(numeric))
    490                     raise Exception, msg
     490                    raise Exception(msg)
    491491                self.set_values_from_constant(numeric, location,
    492492                                              indices, verbose)
     
    513513                                      use_cache=use_cache)
    514514        else:
    515             raise Exception, "This can't happen :-)"
     515            raise Exception("This can't happen :-)")
    516516
    517517        # Update all locations in triangles
     
    665665            else:
    666666                msg = 'Values array must be 1d or 2d'
    667                 raise Exception, msg
     667                raise Exception(msg)
    668668
    669669    ##
     
    769769                        self.vertex_values[i, j] = values[3*i + j]
    770770        else:
    771             raise Exception, 'Not implemented: %s' % location
     771            raise Exception('Not implemented: %s' % location)
    772772
    773773    ##
     
    802802            msg = ("set_values_from_points is only defined for "
    803803                   "location='vertices'")
    804             raise Exception, msg
     804            raise Exception(msg)
    805805
    806806        # Take care of georeferencing
     
    848848        """Set quantity values from arbitray data points using fit_interpolate.fit"""
    849849
    850         raise Exception, 'set_values_from_points is obsolete, use geospatial data object instead'
     850        raise Exception('set_values_from_points is obsolete, use geospatial data object instead')
    851851
    852852    ##
     
    882882        if location != 'vertices':
    883883            msg = "set_values_from_file is only defined for location='vertices'"
    884             raise Exception, msg
     884            raise Exception(msg)
    885885
    886886           
     
    951951            i = num.argmin(V)
    952952        else:
    953             raise ValueError, 'Bad mode value, got: %s' % str(mode)
     953            raise ValueError('Bad mode value, got: %s' % str(mode))
    954954
    955955        if indices is None:
     
    11901190                            'edges', 'unique vertices']:
    11911191            msg = 'Invalid location: %s' % location
    1192             raise Exception, msg
     1192            raise Exception(msg)
    11931193
    11941194
     
    12181218                if len(triangles) == 0:
    12191219                    msg = 'Unique vertex not associated with triangles'
    1220                     raise Exception, msg
     1220                    raise Exception(msg)
    12211221
    12221222                # Go through all triangle, vertex pairs
     
    13811381                    if current_node == N:
    13821382                        msg = 'Current node exceeding number of nodes (%d) ' % N
    1383                         raise Exception, msg
     1383                        raise Exception(msg)
    13841384
    13851385                    k += 1
     
    15761576    def __init__(self, domain, vertex_values=None):
    15771577        msg = 'ERROR: Use Quantity instead of Conserved_quantity'
    1578         raise Exception, msg
     1578        raise Exception(msg)
    15791579
    15801580
     
    16111611    msg += 'Make sure compile_all.py has been run as described in '
    16121612    msg += 'the ANUGA installation guide.'
    1613     raise Exception, msg
     1613    raise Exception(msg)
  • trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/region.py

    r7276 r8124  
    2020    def __call__(self, tag, elements, domain):
    2121        msg = 'Generic class Boundary must be subclassed'
    22         raise msg
     22        raise Exception(msg)
    2323
    2424
     
    8686            self.quantity_initial_value = initial_quantity
    8787        if callable(X):
    88             raise 'This class does not work with functions' 
     88            raise Exception('This class does not work with functions')
    8989
    9090    def __repr__(self):
  • trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/test_generic_boundary_conditions.py

    r7814 r8124  
    3838            pass
    3939        else:
    40             raise 'Should have raised exception'
     40            raise Exception('Should have raised exception')
    4141
    4242
     
    4848            pass
    4949        else:
    50             raise 'Should have raised exception'
     50            raise Exception('Should have raised exception')
    5151
    5252    def test_dirichlet(self):
     
    9595            pass
    9696        else:
    97             raise 'Should have raised exception'
     97            raise Exception('Should have raised exception')
    9898
    9999        #Test time bdry, you need to provide a function
     
    103103            pass
    104104        else:
    105             raise 'Should have raised exception'
     105            raise Exception('Should have raised exception')
    106106
    107107
     
    161161            pass
    162162        else:
    163             raise 'Should have raised exception'
     163            raise Exception('Should have raised exception')
    164164
    165165        #Test time bdry, you need to provide a function
     
    169169            pass
    170170        else:
    171             raise 'Should have raised exception'
     171            raise Exception('Should have raised exception')
    172172
    173173
     
    233233            pass
    234234        else:
    235             raise 'Should have raised exception'
     235            raise Exception('Should have raised exception')
    236236
    237237        T = Transmissive_boundary(domain)
     
    424424            pass
    425425        else:
    426             raise 'Should have raised an exception'       
     426            raise Exception('Should have raised an exception')
    427427       
    428428        os.remove(filename + '.txt')
  • trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/test_neighbour_mesh.py

    r7711 r8124  
    4242        else:
    4343            msg = 'Should have raised exception'
    44             raise msg
     44            raise Exception(msg)
    4545
    4646
     
    396396            pass
    397397        else:
    398             raise "triangle edge duplicates not caught"
     398            raise Exception("triangle edge duplicates not caught")
    399399
    400400
     
    652652            pass
    653653        else:
    654             raise 'Should have raised an exception'
     654            raise Exception('Should have raised an exception')
    655655
    656656        #Too few points - 1 element
     
    660660            pass
    661661        else:
    662             raise 'Should have raised an exception'
     662            raise Exception('Should have raised an exception')
    663663
    664664        #Wrong dimension of vertices
     
    668668            pass
    669669        else:
    670             raise 'Should have raised an exception'
     670            raise Exception('Should have raised an exception')
    671671
    672672        #Unsubscriptable coordinates object raises exception
     
    676676            pass
    677677        else:
    678             raise 'Should have raised an exception'
     678            raise Exception('Should have raised an exception')
    679679
    680680        #FIXME: This has been commented out pending a decision
     
    687687        #    pass
    688688        #else:
    689         #    raise 'Should have raised an exception'
     689        #    raise Exception('Should have raised an exception')
    690690
    691691        #Specifying wrong non existing segment
     
    695695            pass
    696696        else:
    697             raise 'Should have raised an exception'
     697            raise Exception('Should have raised an exception')
    698698
    699699
     
    12111211        else:
    12121212            msg = 'Should have caught point outside polygon (Non)'           
    1213             raise Exception, msg
     1213            raise Exception(msg)
    12141214           
    12151215        id = mesh.get_triangle_containing_point([0.5, 1.0])
     
    12681268                intersected_triangles = [2,3,6,7]
    12691269            else:
    1270                 raise Exception, 'this test is not for parallel lines'
     1270                raise Exception('this test is not for parallel lines')
    12711271
    12721272
     
    17611761                    assert num.allclose(x.normal, [s2,-s2])
    17621762                else:
    1763                     msg = 'Unknow segment: %s' %x.segment
    1764                     raise Exception, msg
     1763                    msg = 'Unknown segment: %s' %x.segment
     1764                    raise Exception(msg)
    17651765               
    17661766
  • trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/test_quantity.py

    r7737 r8124  
    7575            pass
    7676        else:
    77             raise 'Should have raised empty quantity exception'
     77            raise Exception('Should have raised empty quantity exception')
    7878
    7979
     
    8484        #    pass
    8585        #except:
    86         #    raise 'Should have raised "mising mesh object" error'
     86        #    raise Exception('Should have raised "mising mesh object" error')
    8787
    8888
     
    286286            pass
    287287        except:
    288             raise 'should have raised Assertionerror'
     288            raise Exception('should have raised Assertionerror')
    289289
    290290
     
    461461        else:
    462462            msg = 'Should have caught this'
    463             raise msg
     463            raise Exception(msg)
    464464
    465465
  • trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/test_util.py

    r7814 r8124  
    166166            #if t == t0:
    167167            #    msg = 'Duplicate timestep found: %f, %f' %(t0, t)
    168             #   raise msg
     168            #   raise Exception(msg)
    169169            t0 = t
    170170             
     
    12691269        else:
    12701270            msg = 'Should have raised a NameError Exception'
    1271             raise msg
     1271            raise Exception(msg)
    12721272
    12731273
     
    12791279        else:
    12801280            msg = 'Should have raised a AssertionError Exception'
    1281             raise msg       
     1281            raise Exception(msg)
    12821282       
    12831283
  • trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/util.py

    r7800 r8124  
    113113    except NameError, e:
    114114        msg = 'Expression "%s" could not be evaluated: %s' % (expression, e)
    115         raise NameError, msg
     115        raise NameError(msg)
    116116    except ValueError, e:
    117117        msg = 'Expression "%s" could not be evaluated: %s' % (expression, e)
    118         raise ValueError, msg
     118        raise ValueError(msg)
    119119
    120120
     
    146146                return s
    147147            else:
    148                 raise 'Illegal input to get_textual_float:', value
     148                raise Exception('Illegal input to get_textual_float: %s' % str(value))
    149149        else:
    150150            return format % float(value)
     
    177177    p = list(set(quantity).difference(set(all_quantity)))
    178178    if len(p) != 0:
    179         msg = 'Quantities %s do not exist - please try again' %p
    180         raise Exception, msg
     179        msg = 'Quantities %s do not exist - please try again' % p
     180        raise Exception(msg)
    181181
    182182
     
    340340    msg += 'Please use "from anuga.abstract_2d_finite_volumes.util import ' \
    341341           'csv2timeseries_graphs"'
    342     raise Exception, msg
     342    raise Exception(msg)
    343343
    344344    return csv2timeseries_graphs(directories_dic,
     
    502502    except ImportError:
    503503        msg='csv2timeseries_graphs needs pylab to be installed correctly'
    504         raise msg
     504        raise Exception(msg)
    505505            #ANUGA don't need pylab to work so the system doesn't
    506506            #rely on pylab being installed
  • trunk/anuga_core/source/anuga/advection/advection.py

    r7737 r8124  
    105105                #Q.limit()
    106106            else:
    107                 raise 'Unknown order'
     107                raise Exception('Unknown order: %s' % str(self._order_))
    108108            #Q.interpolate_from_vertices_to_edges()
    109109
  • trunk/anuga_core/source/anuga/caching/caching.py

    r7317 r8124  
    10491049  if argsfile is None:
    10501050    msg = 'ERROR (caching): Could not open argsfile for writing: %s' %FN
    1051     raise IOError, msg
     1051    raise IOError(msg)
    10521052
    10531053  mysave((args,kwargs),argsfile,compression)  # Save args and kwargs to cache
     
    12891289      msg = '****WARNING (caching.py): Could not pickle data for compression.'
    12901290      msg += ' Try using compression = False'
    1291       raise MemoryError, msg
     1291      raise MemoryError(msg)
    12921292    else: 
    12931293      # Compressed pickling     
     
    13291329      #  print e
    13301330      #  msg = 'Could not store to %s, bin=%s' %(file, bin)
    1331       #  raise msg
     1331      #  raise Exception(msg)
    13321332     
    13331333
     
    15661566      msg = 'Instance %s was passed into caching in the role of a function ' % str(my_F)
    15671567      msg = ' but it was not callable.'
    1568       raise Exception, msg
     1568      raise Exception(msg)
    15691569  elif type(my_F) in [types.BuiltinFunctionType, types.BuiltinMethodType]:     
    15701570    # Built-in functions are assumed not to change 
     
    15761576  else:
    15771577    msg = 'Unknown function type: %s' % type(my_F)
    1578     raise Exception, msg
     1578    raise Exception(msg)
    15791579
    15801580
     
    16141614      if expanded_FN == []:
    16151615        errmsg = 'ERROR (caching.py): Dependency '+FN+' does not exist.'
    1616         raise Exception, errmsg     
     1616        raise Exception(errmsg)
    16171617
    16181618      expanded_dependencies += expanded_FN
     
    16231623        errmsg = 'ERROR (caching.py): Dependency must be a string.\n'
    16241624        errmsg += '                   Dependency given: %s' %FN
    1625         raise Exception, errmsg     
     1625        raise Exception(errmsg)
    16261626      if not os.access(FN,os.F_OK):
    16271627        errmsg = 'ERROR (caching.py): Dependency '+FN+' does not exist.'
    1628         raise Exception, errmsg
     1628        raise Exception(errmsg)
    16291629      (size,atime,mtime,ctime) = filestat(FN)
    16301630
     
    21072107    if sortidx > len(rec)-1:
    21082108      msg = 'ERROR: Sorting index too large, sortidx = %s' % str(sortidx)
    2109       raise IndexError, msg
     2109      raise IndexError(msg)
    21102110
    21112111    val = rec[sortidx]
  • trunk/anuga_core/source/anuga/caching/test_caching.py

    r7317 r8124  
    724724                    fid.close()
    725725                except:
    726                     raise 'Statistics files cannot be opened'         
     726                    raise Exception('Statistics files cannot be opened')
    727727 
    728728         
  • trunk/anuga_core/source/anuga/coordinate_transforms/geo_reference.py

    r7779 r8124  
    2929
    3030
    31 ##
    32 # @brief A class for ...
    3331class Geo_reference:
    3432    """
     
    4644    """
    4745
    48     ##
    49     # @brief Instantiate an instance of class Geo_reference.
    50     # @param zone The UTM zone.
    51     # @param xllcorner X coord of origin of georef.
    52     # @param yllcorner Y coord of origin of georef.
    53     # @param datum ??
    54     # @param projection The projection used (default UTM).
    55     # @param units Units used in measuring distance (default m).
    56     # @param false_easting ??
    57     # @param false_northing ??
    58     # @param NetCDFObject NetCDF file *handle* to write to.
    59     # @param ASCIIFile ASCII text file *handle* to write to.
    60     # @param read_title Title of the georeference text.
    6146    def __init__(self,
    6247                 zone=DEFAULT_ZONE,
     
    7257                 read_title=None):
    7358        """
    74         input:
    75         NetCDFObject - a handle to the netCDF file to be written to
    76         ASCIIFile - a handle to the text file
    77         read_title - the title of the georeference text, if it was read in.
    78          If the function that calls this has already read the title line,
    79          it can't unread it, so this info has to be passed.
    80          If you know of a way to unread this info, then tell us.
    81 
    82          Note, the text file only saves a sub set of the info the
    83          points file does.  Currently the info not written in text
    84          must be the default info, since ANUGA assumes it isn't
    85          changing.
     59        zone            the UTM zone.
     60        xllcorner       X coord of origin of georef.
     61        yllcorner       Y coord of origin of georef.
     62        datum           ??
     63        projection      the projection used (default UTM).
     64        units           units used in measuring distance (default m).
     65        false_easting   ??
     66        false_northing  ??
     67        NetCDFObject    NetCDF file *handle* to write to.
     68        ASCIIFile       ASCII text file *handle* to write to.
     69        read_title      title of the georeference text.
     70
     71        If the function that calls this has already read the title line,
     72        it can't unread it, so this info has to be passed.
     73        If you know of a way to unread this info, then tell us.
     74
     75        Note, the text file only saves a sub set of the info the
     76        points file does.  Currently the info not written in text
     77        must be the default info, since ANUGA assumes it isn't
     78        changing.
    8679        """
    8780
     
    110103        return self.xllcorner
    111104
    112     ##
    113     # @brief Get the Y coordinate of the origin of this georef.
    114105    def get_yllcorner(self):
     106        """Get the Y coordinate of the origin of this georef."""
     107
    115108        return self.yllcorner
    116109
    117     ##
    118     # @brief Get the zone of this georef.
    119110    def get_zone(self):
     111        """Get the zone of this georef."""
     112
    120113        return self.zone
    121114
    122     ##
    123     # @brief Write <something> to an open NetCDF file.
    124     # @param outfile Handle to open NetCDF file.
    125115    def write_NetCDF(self, outfile):
     116        """Write georef attributes to an open NetCDF file.
     117
     118        outfile  handle to open NetCDF file
     119        """
     120
    126121        outfile.xllcorner = self.xllcorner
    127122        outfile.yllcorner = self.yllcorner
     
    135130        outfile.units = self.units
    136131
    137     ##
    138     # @brief Read data from an open NetCDF file.
    139     # @param infile Handle to open NetCDF file.
    140132    def read_NetCDF(self, infile):
     133        """Set georef attributes from open NetCDF file.
     134
     135        infile Handle to open NetCDF file
     136        """
     137
    141138        self.xllcorner = float(infile.xllcorner[0])
    142139        self.yllcorner = float(infile.yllcorner[0])
     
    189186################################################################################
    190187
    191     ##
    192     # @brief Write georef data to an open text file.
    193     # @param fd Handle to open text file.
    194188    def write_ASCII(self, fd):
     189        """Write georef attriutes to an open text file.
     190
     191        fd  handle to open text file
     192        """
     193
    195194        fd.write(TITLE)
    196195        fd.write(str(self.zone) + "\n")
     
    198197        fd.write(str(self.yllcorner) + "\n")
    199198
    200     ##
    201     # @brief Read georef data from an open text file.
    202     # @param fd Handle to open text file.
    203199    def read_ASCII(self, fd, read_title=None):
     200        """Set georef attribtes from open text file.
     201
     202        fd  handle to open text file
     203        """
     204
    204205        try:
    205206            if read_title == None:
     
    232233################################################################################
    233234
    234     ##
    235     # @brief Change points to be absolute wrt new georef 'points_geo_ref'.
    236     # @param points The points to change.
    237     # @param points_geo_ref The new georef to make points absolute wrt.
    238     # @return The changed points.
    239     # @note If 'points' is a list then a changed list is returned.
    240235    def change_points_geo_ref(self, points, points_geo_ref=None):
    241         """Change the geo reference of a list or numeric array of points to
    242         be this reference.(The reference used for this object)
    243         If the points do not have a geo ref, assume 'absolute' values
    244         """
     236        """Change points to be absolute wrt new georef 'points_geo_ref'.
     237
     238        points          the points to change
     239        points_geo_ref  the new georef to make points absolute wrt
     240
     241        Returns the changed points data.
     242        If the points do not have a georef, assume 'absolute' values.
     243        """
     244
    245245        import copy
    246246       
     
    285285
    286286    def is_absolute(self):
    287         """Return True if xllcorner==yllcorner==0 indicating that points
    288         in question are absolute.
     287        """Test if points in georef are absolute.
     288
     289        Return True if xllcorner==yllcorner==0 indicating that points in
     290        question are absolute.
    289291        """
    290292       
     
    305307
    306308    def get_absolute(self, points):
    307         """Given a set of points geo referenced to this instance,
    308         return the points as absolute values.
     309        """Given a set of points geo referenced to this instance, return the
     310        points as absolute values.
    309311        """
    310312
     
    338340        return points
    339341
    340     ##
    341     # @brief Convert points to relative measurement.
    342     # @param points Points to convert to relative measurements.
    343     # @return A set of points relative to the geo_reference instance.
    344342    def get_relative(self, points):
    345         """Given a set of points in absolute UTM coordinates,
    346         make them relative to this geo_reference instance,
    347         return the points as relative values.
    348 
    349         This is the inverse of get_absolute.
     343        """Convert points to relative measurement.
     344
     345        points Points to convert to relative measurements
     346
     347        Returns a set of points relative to the geo_reference instance.
     348
     349        This is the inverse of get_absolute().
    350350        """
    351351
     
    376376        return points
    377377
    378     ##
    379     # @brief ??
    380     # @param other ??
    381378    def reconcile_zones(self, other):
    382379        if other is None:
     
    402399    #    return [x-self.xllcorner, y - self.xllcorner]
    403400
    404     ##
    405     # @brief Get origin of this geo_reference.
    406     # @return (zone, xllcorner, yllcorner).
    407401    def get_origin(self):
     402        """Get origin of this geo_reference."""
     403     
    408404        return (self.zone, self.xllcorner, self.yllcorner)
    409405
    410     ##
    411     # @brief Get a string representation of this geo_reference instance.
    412406    def __repr__(self):
    413407        return ('(zone=%i easting=%f, northing=%f)'
    414408                % (self.zone, self.xllcorner, self.yllcorner))
    415409
    416     ##
    417     # @brief Compare two geo_reference instances.
    418     # @param self This geo_reference instance.
    419     # @param other Another geo_reference instance to compare against.
    420     # @return 0 if instances have the same attributes, else 1.
    421     # @note Attributes are: zone, xllcorner, yllcorner.
    422410    def __cmp__(self, other):
     411        """Compare two geo_reference instances.
     412
     413        self   this geo_reference instance
     414        other  another geo_reference instance to compare against
     415
     416        Returns 0 if instances have the same attributes, else returns 1.
     417
     418        Note: attributes are: zone, xllcorner, yllcorner.
     419        """
     420
    423421        # FIXME (DSG) add a tolerence
    424422        if other is None:
     
    434432
    435433
    436 ##
    437 # @brief Write a geo_reference to a NetCDF file (usually SWW).
    438 # @param origin A georef instance or parameters to create a georef instance.
    439 # @param outfile Path to file to write.
    440 # @return A normalized geo_reference.
    441434def write_NetCDF_georeference(origin, outfile):
    442     """Write georeference info to a netcdf file, usually sww.
    443 
    444     The origin can be a georef instance or parameters for a geo_ref instance
    445 
    446     outfile is the name of the file to be written to.
     435    """Write georeference info to a NetCDF file, usually a SWW file.
     436
     437    origin   a georef instance or parameters to create a georef instance
     438    outfile  path to file to write
     439
     440    Returns the normalised georef.
    447441    """
    448442
     
    452446
    453447
    454 ##
    455 # @brief Convert an object to a georeference instance.
    456 # @param origin A georef instance or (zone, xllcorner, yllcorner)
    457 # @return A georef object, or None if 'origin' was None.
    458448def ensure_geo_reference(origin):
    459     """
    460     Given a list/tuple of zone, xllcorner and yllcorner of a geo-ref object,
    461     return a geo ref object.
    462 
    463     If the origin is None, return None, so calling this function doesn't
    464     effect code logic
     449    """Create a georef object from a tuple of attributes.
     450
     451    origin  a georef instance or (zone, xllcorner, yllcorner)
     452
     453    If origin is None, return None, so calling this function doesn't
     454    effect code logic.
    465455    """
    466456
  • trunk/anuga_core/source/anuga/coordinate_transforms/test_geo_reference.py

    r7317 r8124  
    473473        else:
    474474            msg = 'Should have raised an exception'
    475             raise msg
     475            raise Exception(msg)
    476476 
    477477    def test_bad_ASCII_title(self):     
  • trunk/anuga_core/source/anuga/culvert_flows/culvert_class.py

    r7735 r8124  
    3232        x = float(x)
    3333    except:
    34         raise Exception, msg
     34        raise Exception(msg)
    3535
    3636
     
    3939        msg = 'Value provided = %.2f, interpolation minimum = %.2f.'\
    4040            % (x, xvec[0])
    41         raise Below_interval, msg
     41        raise Below_interval(msg)
    4242       
    4343    if x > xvec[-1]:
    4444        msg = 'Value provided = %.2f, interpolation maximum = %.2f.'\
    4545            %(x, xvec[-1])
    46         raise Above_interval, msg       
     46        raise Above_interval(msg)
    4747       
    4848       
     
    400400            else:
    401401                msg = 'Triangle not found for point (%f, %f)' %point
    402                 raise Exception, msg
     402                raise Exception(msg)
    403403       
    404404        return enquiry_indices
     
    922922            else:
    923923                msg = 'Triangle not found for point (%f, %f)' %point
    924                 raise Exception, msg
     924                raise Exception(msg)
    925925       
    926926                         
     
    12061206                msg = 'Either diameter or width&height must be specified, '
    12071207                msg += 'but not both.'
    1208                 raise Exception, msg
     1208                raise Exception(msg)
    12091209        else:
    12101210            if height is not None:
     
    12201220            else:
    12211221                msg = 'Either diameter or width&height must be specified.'
    1222                 raise Exception, msg               
     1222                raise Exception(msg)
    12231223               
    12241224            if height == width:
     
    13211321            else:
    13221322                msg = 'Triangle not found for point (%f, %f)' %point
    1323                 raise Exception, msg
     1323                raise Exception(msg)
    13241324       
    13251325                         
     
    14601460                    # This is possible since w and z are taken at different locations
    14611461                    #msg = 'D < 0.0: %f' %d
    1462                     #raise msg
     1462                    #raise Exception(msg)
    14631463                    d = 0.0
    14641464               
  • trunk/anuga_core/source/anuga/culvert_flows/new_culvert_class.py

    r7735 r8124  
    3232        x = float(x)
    3333    except:
    34         raise Exception, msg
     34        raise Exception(msg)
    3535
    3636
     
    3939        msg = 'Value provided = %.2f, interpolation minimum = %.2f.'\
    4040            % (x, xvec[0])
    41         raise Below_interval, msg
     41        raise Below_interval(msg)
    4242       
    4343    if x > xvec[-1]:
    4444        msg = 'Value provided = %.2f, interpolation maximum = %.2f.'\
    4545            %(x, xvec[-1])
    46         raise Above_interval, msg       
     46        raise Above_interval(msg)
    4747       
    4848       
     
    403403            else:
    404404                msg = 'Triangle not found for point (%f, %f)' %point
    405                 raise Exception, msg
     405                raise Exception(msg)
    406406       
    407407        return enquiry_indices
     
    925925            else:
    926926                msg = 'Triangle not found for point (%f, %f)' %point
    927                 raise Exception, msg
     927                raise Exception(msg)
    928928       
    929929                         
     
    12091209                msg = 'Either diameter or width&height must be specified, '
    12101210                msg += 'but not both.'
    1211                 raise Exception, msg
     1211                raise Exception(msg)
    12121212        else:
    12131213            if height is not None:
     
    12231223            else:
    12241224                msg = 'Either diameter or width&height must be specified.'
    1225                 raise Exception, msg               
     1225                raise Exception(msg)
    12261226               
    12271227            if height == width:
     
    13241324            else:
    13251325                msg = 'Triangle not found for point (%f, %f)' %point
    1326                 raise Exception, msg
     1326                raise Exception(msg)
    13271327       
    13281328                         
     
    14631463                    # This is possible since w and z are taken at different locations
    14641464                    #msg = 'D < 0.0: %f' %d
    1465                     #raise msg
     1465                    #raise Exception(msg)
    14661466                    d = 0.0
    14671467               
  • trunk/anuga_core/source/anuga/file/urs.py

    r7766 r8124  
    4040        if self.points_num < 0:
    4141            mux_file.close()
    42             raise ANUGAError, msg
     42            raise ANUGAError(msg)
    4343        if self.time_step_count < 0:
    4444            mux_file.close()
    45             raise ANUGAError, msg
     45            raise ANUGAError(msg)
    4646        if self.time_step < 0:
    4747            mux_file.close()
    48             raise ANUGAError, msg
     48            raise ANUGAError(msg)
    4949
    5050        # The depth is in meters, and it is the distance from the ocean
     
    209209            msg = 'Caching was requested, but caching module' \
    210210                  'could not be imported'
    211             raise msg
     211            raise Exception(msg)
    212212
    213213        geo = cache(_calculate_boundary_points,
     
    267267    if lat_long_set == frozenset([]):
    268268        msg = "URS region specified and polygon does not overlap."
    269         raise ValueError, msg
     269        raise ValueError(msg)
    270270
    271271    # Warning there is no info in geospatial saying the hemisphere of
  • trunk/anuga_core/source/anuga/file_conversion/test_file_conversion.py

    r7780 r8124  
    12111211            os.remove(elevation_dir_filename2)
    12121212            os.rmdir(elevation_dir)
    1213             raise 'Should raise exception'
     1213            raise Exception('Should raise exception')
    12141214
    12151215            os.remove(ucur_dir_filename1)
     
    19141914            self.delete_mux(files)
    19151915            msg = 'Should have raised exception'
    1916             raise msg
     1916            raise Exception(msg)
    19171917        sww_file = base_name + '.sww'
    19181918        self.delete_mux(files)
     
    19271927            self.delete_mux(files)
    19281928            msg = 'Should have raised exception'
    1929             raise msg
     1929            raise Exception(msg)
    19301930           
    19311931    def test_urs2sww(self):
     
    23932393        else:
    23942394            msg = 'Should have raised exception'
    2395             raise msg
     2395            raise Exception(msg)
    23962396       
    23972397    def test_lon_lat2gridII(self):
     
    24072407        else:
    24082408            msg = 'Should have raised exception'
    2409             raise msg
     2409            raise Exception(msg)
    24102410       
    24112411
  • trunk/anuga_core/source/anuga/file_conversion/urs2sww.py

    r7858 r8124  
    155155            mux[quantity].close()
    156156        msg = "Due to mint and maxt there's no time info in the boundary SWW."
    157         raise Exception, msg
     157        raise Exception(msg)
    158158
    159159    # If this raise is removed there is currently no downstream errors
  • trunk/anuga_core/source/anuga/fit_interpolate/interpolate.py

    r7854 r8124  
    800800            # This message is time consuming to form due to the conversion of
    801801            msg = 'Time must be a monotonuosly increasing sequence %s' % time
    802             raise Exception, msg
     802            raise Exception(msg)
    803803
    804804        # Check if quantities is a single array only
     
    859859            #no longer true. sts files have spatial = True but
    860860            #if self.spatial is False:
    861             #    raise 'Triangles and vertex_coordinates must be specified'
     861            #    raise Exception('Triangles and vertex_coordinates must be specified')
    862862            #
    863863            try:
     
    868868                      'or a list of points\n'
    869869                msg += 'Got: %s.' %(str(self.interpolation_points)[:60] + '...')
    870                 raise msg
     870                raise Exception(msg)
    871871
    872872            # Ensure 'mesh_boundary_polygon' is defined
     
    11031103                if x is not None and y is not None:
    11041104                    # Interpolate to x, y
    1105                     raise 'x,y interpolation not yet implemented'
     1105                    raise Exception('x,y interpolation not yet implemented')
    11061106                else:
    11071107                    # Use precomputed point
  • trunk/anuga_core/source/anuga/fit_interpolate/test_fit.py

    r7778 r8124  
    976976        else:
    977977            #self.failUnless(0 ==1,  'Bad file did not raise error!')
    978             raise 'Bad file did not raise error!'
     978            raise Exception('Bad file did not raise error!')
    979979           
    980980        #clean up
     
    10091009            pass
    10101010        else:
    1011             raise 'Bad file did not raise error!'
     1011            raise Exception('Bad file did not raise error!')
    10121012           
    10131013        #clean up
     
    10521052            pass
    10531053        else:
    1054             raise 'Bad file did not raise error!'
     1054            raise Exception('Bad file did not raise error!')
    10551055       
    10561056        #clean up
     
    10861086            pass
    10871087        else:
    1088             raise 'Verts with no triangles did not raise error!'
     1088            raise Exception('Verts with no triangles did not raise error!')
    10891089       
    10901090        #f = interp.fit(data_coords, z)
  • trunk/anuga_core/source/anuga/fit_interpolate/test_interpolate.py

    r7796 r8124  
    11701170            pass
    11711171        else:
    1172             raise 'Should raise exception'
     1172            raise Exception('Should raise exception')
    11731173
    11741174        try:
     
    11771177            pass
    11781178        else:
    1179             raise 'Should raise exception'       
     1179            raise Exception('Should raise exception')
    11801180
    11811181
     
    12351235            pass
    12361236        else:
    1237             raise 'Should raise exception'
     1237            raise Exception('Should raise exception')
    12381238
    12391239           
     
    12941294            pass
    12951295        else:
    1296             raise 'Should raise exception'
     1296            raise Exception('Should raise exception')
    12971297
    12981298
     
    15041504            pass
    15051505        else:
    1506             raise 'Should raise exception'
     1506            raise Exception('Should raise exception')
    15071507
    15081508
     
    16671667            pass
    16681668        else:
    1669             raise 'Should raise exception due to time being non-monotoneous'           
     1669            raise Exception('Should raise exception due to time being non-monotoneous')
    16701670     
    16711671
  • trunk/anuga_core/source/anuga/fit_interpolate/test_search_functions.py

    r8120 r8124  
    3131                compile(FN)
    3232            except:
    33                 raise 'Could not compile %s' %FN
     33                raise Exception('Could not compile %s' % FN)
    3434            else:
    3535                import search_functions_ext
  • trunk/anuga_core/source/anuga/geospatial_data/geospatial_data.py

    r7780 r8124  
    216216            self.data_points = None
    217217            msg = 'There is no data or file provided!'
    218             raise ValueError, msg
     218            raise ValueError(msg)
    219219        else:
    220220            self.data_points = ensure_numeric(data_points)
     
    245245                msg = ("Attribute '%s' (%s) could not be converted to a"
    246246                       "numeric vector" % (str(key), str(attributes[key])))
    247                 raise Exception, msg
     247                raise Exception(msg)
    248248
    249249        self.attributes = attributes
     
    272272            msg = ('Argument geo_reference must be a valid Geo_reference '
    273273                   'object or None.')
    274             raise Expection, msg
     274            raise Expection(msg)
    275275
    276276        # If a geo_reference already exists, change the point data according to
     
    296296        else:
    297297            msg = 'Illegal value: %s' % str(verbose)
    298             raise Exception, msg
     298            raise Exception(msg)
    299299
    300300    ##
     
    494494                    msg = ('Geospatial data must have the same '
    495495                           'attributes to allow addition.')
    496                     raise Exception, msg
     496                    raise Exception(msg)
    497497
    498498                new_attributes = None
     
    508508                        msg = ('Geospatial data must have the same '
    509509                               'attributes to allow addition.')
    510                         raise Exception, msg
     510                        raise Exception(msg)
    511511        else:
    512512            # other is None:
     
    549549        if access(file_name, F_OK) == 0 :
    550550            msg = 'File %s does not exist or is not accessible' % file_name
    551             raise IOError, msg
     551            raise IOError(msg)
    552552
    553553        attributes = {}
     
    558558            except IOError, e:
    559559                msg = 'Could not open file %s ' % file_name
    560                 raise IOError, msg
     560                raise IOError(msg)
    561561        elif file_name[-4:] == ".txt" or file_name[-4:]== ".csv":
    562562            try:
     
    567567                msg = ('Could not open file %s. Check the file location.'
    568568                       % file_name)
    569                 raise IOError, msg
     569                raise IOError(msg)
    570570            except SyntaxError, e:
    571571                # This should only be if there is a format error
    572572                msg = ('Problem with format of file %s.\n%s'
    573573                       % (file_name, Error_message['IOError']))
    574                 raise SyntaxError, msg
     574                raise SyntaxError(msg)
    575575        else:
    576576            msg = 'Extension %s is unknown' % file_name[-4:]
    577             raise IOError, msg
     577            raise IOError(msg)
    578578
    579579        self.data_points = data_points
     
    636636        else:
    637637            msg = 'Unknown file type %s ' %file_name
    638             raise IOError, msg
     638            raise IOError(msg)
    639639
    640640    ##
     
    878878                    msg = ('Geo reference given, then not given.'
    879879                           ' This should not happen.')
    880                     raise ValueError, msg
     880                    raise ValueError(msg)
    881881                geo = Geospatial_data(pointlist, att_dict, geo_ref)
    882882            except StopIteration:
     
    897897                msg = ('Could not open file %s.\n%s'
    898898                       % (self.file_name, Error_message['IOError']))
    899                 raise SyntaxError, msg
     899                raise SyntaxError(msg)
    900900        return geo
    901901
     
    934934        msg = ('A georeference is specified yet latitude and longitude '
    935935               'are also specified!')
    936         raise ValueError, msg
     936        raise ValueError(msg)
    937937
    938938    if data_points is not None and not points_are_lats_longs:
    939939        msg = ('Data points are specified yet latitude and longitude are '
    940940               'also specified.')
    941         raise ValueError, msg
     941        raise ValueError(msg)
    942942
    943943    if points_are_lats_longs:
    944944        if data_points is None:
    945945            msg = "Data points are not specified."
    946             raise ValueError, msg
     946            raise ValueError(msg)
    947947        lats_longs = ensure_numeric(data_points)
    948948        latitudes = num.ravel(lats_longs[:,0:1])
     
    951951    if latitudes is None and longitudes is None:
    952952        msg = "Latitudes and Longitudes are not specified."
    953         raise ValueError, msg
     953        raise ValueError(msg)
    954954
    955955    if latitudes is None:
    956956        msg = "Longitudes are specified yet latitudes aren't."
    957         raise ValueError, msg
     957        raise ValueError(msg)
    958958
    959959    if longitudes is None:
    960960        msg = "Latitudes are specified yet longitudes aren't."
    961         raise ValueError, msg
     961        raise ValueError(msg)
    962962
    963963    data_points, zone  = convert_from_latlon_to_utm(latitudes=latitudes,
     
    999999        fid.close()
    10001000        msg = "Expected keyword 'points' but could not find it"
    1001         raise IOError, msg
     1001        raise IOError(msg)
    10021002
    10031003    attributes = {}
     
    11231123                msg = ('File load error. '
    11241124                       'There might be a problem with the file header.')
    1125                 raise SyntaxError, msg
     1125                raise SyntaxError(msg)
    11261126            for i,n in enumerate(numbers):
    11271127                n.strip()
     
    11751175        fid.close()
    11761176        msg = "Expected keyword 'points' but could not find it."
    1177         raise IOError, msg
     1177        raise IOError(msg)
    11781178
    11791179    if verbose: log.critical('Got %d variables: %s' % (len(keys), keys))
     
    15771577        if no_boundary is True:
    15781578            msg = 'All boundaries must be defined'
    1579             raise Expection, msg
     1579            raise Expection(msg)
    15801580
    15811581        poly_topo = [[east_boundary, south_boundary],
     
    15981598        if access(mesh_file,F_OK) == 0:
    15991599            msg = "file %s doesn't exist!" % mesh_file
    1600             raise IOError, msg
     1600            raise IOError(msg)
    16011601
    16021602    # split topo data
     
    17861786        if no_boundary is True:
    17871787            msg = 'All boundaries must be defined'
    1788             raise Expection, msg
     1788            raise Expection(msg)
    17891789
    17901790        poly_topo = [[east_boundary, south_boundary],
     
    18061806        if access(mesh_file,F_OK) == 0:
    18071807            msg = "file %s doesn't exist!" % mesh_file
    1808             raise IOError, msg
     1808            raise IOError(msg)
    18091809
    18101810    # split topo data
  • trunk/anuga_core/source/anuga/geospatial_data/test_geospatial_data.py

    r7779 r8124  
    118118            pass
    119119        else:
    120             raise Exception, 'Should have raised exception'
     120            raise Exception('Should have raised exception')
    121121
    122122    def test_get_data_points(self):
     
    731731        else:
    732732            msg = 'Different zones in Geo references not caught.'
    733             raise Exception, msg
     733            raise Exception(msg)
    734734
    735735        os.remove(fileName)
     
    795795        else:
    796796            msg = 'Bad file did not raise error!'
    797             raise Exception, msg
     797            raise Exception(msg)
    798798        os.remove(fileName)
    799799
     
    824824        else:
    825825            msg = 'Bad file did not raise error!'
    826             raise Exception, msg
     826            raise Exception(msg)
    827827        os.remove(fileName)
    828828
     
    847847        else:
    848848            msg = 'Bad file did not raise error!'
    849             raise Exception, msg
     849            raise Exception(msg)
    850850        os.remove(fileName)
    851851
     
    876876        else:
    877877            msg = 'Bad file did not raise error!'
    878             raise Exception, msg
     878            raise Exception(msg)
    879879        os.remove(fileName)
    880880
     
    11971197        else:
    11981198            msg = 'imaginary file did not raise error!'
    1199             raise Exception, msg
     1199            raise Exception(msg)
    12001200
    12011201    def test_create_from_pts_file(self):
     
    14511451        else:
    14521452            msg = 'Instance must have a filename or data points'
    1453             raise Exception, msg
     1453            raise Exception(msg)
    14541454
    14551455    def test_load_csv_lat_long(self):
     
    15071507        else:
    15081508            msg = 'Different zones in Geo references not caught.'
    1509             raise Exception, msg
     1509            raise Exception(msg)
    15101510
    15111511        os.remove(fileName)
  • trunk/anuga_core/source/anuga/get_version.py

    r1806 r8124  
    3838    msg = 'Command %s could not execute.'
    3939    msg += 'Make sure the program SubWCRev.exe is available on your path'
    40     raise msg
     40    raise Exception(msg)
    4141
    4242
  • trunk/anuga_core/source/anuga/mesh_engine/mesh_engine.py

    r7779 r8124  
    4949    except ValueError:
    5050        msg = 'ERROR: Inconsistent points array.'
    51         raise ANUGAError, msg
     51        raise ANUGAError(msg)
    5252    if points.shape[1] <>2:
    5353        msg = 'ERROR: Bad shape points array.'
    54         raise ANUGAError, msg
     54        raise ANUGAError(msg)
    5555
    5656    # This is after points is numeric
     
    6464    except ValueError:
    6565        msg = 'ERROR: Inconsistent segments array.'
    66         raise ANUGAError, msg
     66        raise ANUGAError(msg)
    6767   
    6868    # This is after segments is numeric
     
    7474    except ValueError:
    7575        msg = 'ERROR: Inconsistent holess array.'
    76         raise ANUGAError, msg
     76        raise ANUGAError(msg)
    7777
    7878   
     
    8282    except  (ValueError, TypeError):
    8383        msg = 'ERROR: Inconsistent regions array.'
    84         raise ANUGAError, msg
     84        raise ANUGAError(msg)
    8585       
    8686    if not regions.shape[0] == 0 and regions.shape[1] <= 2:
    8787        msg = 'ERROR: Bad shape points array.'
    88         raise ANUGAError, msg
     88        raise ANUGAError(msg)
    8989   
    9090    try:
     
    9292    except (ValueError, TypeError):
    9393        msg = 'ERROR: Inconsistent point attributes array.'
    94         raise ANUGAError, msg
     94        raise ANUGAError(msg)
    9595
    9696    if pointatts.shape[0] <> points.shape[0]:
    9797        msg = """ERROR: Point attributes array not the same shape as
    9898        point array."""
    99         raise ANUGAError, msg
     99        raise ANUGAError(msg)
    100100    if len(pointatts.shape) == 1:
    101101        pointatts = num.reshape(pointatts,(pointatts.shape[0],1))
     
    105105    except ValueError:
    106106        msg = 'ERROR: Inconsistent point attributes array.'
    107         raise ANUGAError, msg
     107        raise ANUGAError(msg)
    108108    if segatts.shape[0] <> segments.shape[0]:
    109109        msg = """ERROR: Segment attributes array not the same shape as
    110110        segment array."""
    111         raise ANUGAError, msg
     111        raise ANUGAError(msg)
    112112   
    113113    if mode.find('n'):
     
    186186                #len(region) <= 2:
    187187                #msg = 'ERROR: Inconsistent regions array.'
    188                 #raise msg
     188                #raise Exception(msg)
    189189            #elif
    190190    return regions
  • trunk/anuga_core/source/anuga/pmesh/Pmw.py

    r3491 r8124  
    4343def setversion(version):
    4444    if version != _VERSION:
    45         raise ValueError, 'Dynamic versioning not available'
     45        raise ValueError('Dynamic versioning not available')
    4646
    4747def setalphaversions(*alpha_versions):
    4848    if alpha_versions != ():
    49         raise ValueError, 'Dynamic versioning not available'
     49        raise ValueError('Dynamic versioning not available')
    5050
    5151def version(alpha = 0):
     
    258258        # It's not a valid type
    259259        else:
    260             raise TypeError, 'toPart must be attribute name, function or method'
     260            raise TypeError('toPart must be attribute name, function or method')
    261261
    262262    # get the full set of candidate methods
     
    524524
    525525        if self.__componentInfo.has_key(componentName):
    526             raise ValueError, 'Component "%s" already exists' % componentName
     526            raise ValueError('Component "%s" already exists' % componentName)
    527527
    528528        if '_' in componentName:
    529             raise ValueError, \
    530                     'Component name "%s" must not contain "_"' % componentName
     529            raise ValueError('Component name "%s" must not contain "_"'
     530                             % componentName)
    531531
    532532        if hasattr(self, '_constructorKeywords'):
     
    654654                else:
    655655                    text = 'Unknown options "'
    656                 raise KeyError, text + string.join(unusedOptions, ', ') + \
    657                         '" for ' + self.__class__.__name__
     656                raise KeyError(text + string.join(unusedOptions, ', ')
     657                               + '" for ' + self.__class__.__name__)
    658658
    659659            # Call the configuration callback function for every option.
     
    733733                # Make sure it is not an initialisation option.
    734734                if optionInfo[option][FUNCTION] is INITOPT:
    735                     raise KeyError, \
    736                             'Cannot configure initialisation option "' \
    737                             + option + '" for ' + self.__class__.__name__
     735                    raise KeyError('Cannot configure initialisation option "'
     736                                   + option + '" for '
     737                                   + self.__class__.__name__)
    738738                optionInfo[option][VALUE] = value
    739739                directOptions.append(option)
     
    768768                        if len(componentConfigFuncs) == 0 and \
    769769                                component not in self._dynamicGroups:
    770                             raise KeyError, 'Unknown option "' + option + \
    771                                     '" for ' + self.__class__.__name__
     770                            raise KeyError('Unknown option "' + option + '" for '
     771                                           + self.__class__.__name__)
    772772
    773773                    # Add the configure method(s) (may be more than
     
    780780                                = value
    781781                else:
    782                     raise KeyError, 'Unknown option "' + option + \
    783                             '" for ' + self.__class__.__name__
     782                    raise KeyError('Unknown option "' + option + '" for '
     783                                   + self.__class__.__name__)
    784784
    785785        # Call the configure methods for any components.
     
    874874                            return componentCget(componentOption)
    875875
    876         raise KeyError, 'Unknown option "' + option + \
    877                 '" for ' + self.__class__.__name__
     876        raise KeyError('Unknown option "' + option + '" for '
     877                       + self.__class__.__name__)
    878878
    879879    __getitem__ = cget
     
    11671167    def activate(self, globalMode = 0, geometry = 'centerscreenfirst'):
    11681168        if self._active:
    1169             raise ValueError, 'Window is already active'
     1169            raise ValueError('Window is already active')
    11701170        if self.state() == 'normal':
    11711171            self.withdraw()
     
    14081408            _toplevelBusyInfo[window]['busyCursorName'] = value
    14091409        else:
    1410             raise KeyError, 'Unknown busycursor attribute "' + name + '"'
     1410            raise KeyError('Unknown busycursor attribute "' + name + '"')
    14111411
    14121412def _addRootToToplevelBusyInfo():
     
    14231423def busycallback(command, updateFunction = None):
    14241424    if not callable(command):
    1425         raise ValueError, \
    1426             'cannot register non-command busy callback %s %s' % \
    1427                 (repr(command), type(command))
     1425        raise ValueError('cannot register non-command busy callback %s %s'
     1426                         % (repr(command), type(command)))
    14281427    wrapper = _BusyWrapper(command, updateFunction)
    14291428    return wrapper.callback
     
    15931592                _traceTkFile.write('CALL  TK> stack:\n')
    15941593                traceback.print_stack()
    1595             raise Tkinter.TclError, errorString
     1594            raise Tkinter.TclError(errorString)
    15961595
    15971596        _recursionCounter = _recursionCounter - 1
     
    18121811            return apply(self.func, args)
    18131812        except SystemExit, msg:
    1814             raise SystemExit, msg
     1813            raise SystemExit(msg)
    18151814        except:
    18161815            _reporterror(self.func, args)
     
    20442043        pos = self['buttonboxpos']
    20452044        if pos not in 'nsew':
    2046             raise ValueError, \
    2047                 'bad buttonboxpos option "%s":  should be n, s, e, or w' \
    2048                     % pos
     2045            raise ValueError('bad buttonboxpos option "%s":  should be n, s, e, or w'
     2046                             % pos)
    20492047
    20502048        if pos in 'ns':
     
    21412139        buttons = self['buttons']
    21422140        if type(buttons) != types.TupleType and type(buttons) != types.ListType:
    2143             raise ValueError, \
    2144                 'bad buttons option "%s": should be a tuple' % str(buttons)
     2141            raise ValueError('bad buttons option "%s": should be a tuple'
     2142                             % str(buttons))
    21452143        if self.oldButtons == buttons:
    21462144          return
     
    21952193  inputList = string.split(string.strip(text), separator)
    21962194  if len(inputList) != 3:
    2197     raise ValueError, 'invalid value: ' + text
     2195    raise ValueError('invalid value: ' + text)
    21982196
    21992197  sign = 1
     
    22042202
    22052203  if re.search('[^0-9]', string.join(inputList, '')) is not None:
    2206     raise ValueError, 'invalid value: ' + text
     2204    raise ValueError('invalid value: ' + text)
    22072205
    22082206  hour = string.atoi(inputList[0])
     
    22112209
    22122210  if minute >= 60 or second >= 60:
    2213     raise ValueError, 'invalid value: ' + text
     2211    raise ValueError('invalid value: ' + text)
    22142212  return sign * (hour * 60 * 60 + minute * 60 + second)
    22152213
     
    22292227  inputList = string.split(string.strip(text), separator)
    22302228  if len(inputList) != 3:
    2231     raise ValueError, 'invalid value: ' + text
     2229    raise ValueError('invalid value: ' + text)
    22322230
    22332231  if re.search('[^0-9]', string.join(inputList, '')) is not None:
    2234     raise ValueError, 'invalid value: ' + text
     2232    raise ValueError('invalid value: ' + text)
    22352233  formatList = list(format)
    22362234  day = string.atoi(inputList[formatList.index('d')])
     
    22472245  jdn = ymdtojdn(year, month, day)
    22482246  if jdntoymd(jdn) != (year, month, day):
    2249     raise ValueError, 'invalid value: ' + text
     2247    raise ValueError('invalid value: ' + text)
    22502248  return jdn
    22512249
     
    23282326    if separator != '.':
    23292327        if string.find(text, '.') >= 0:
    2330             raise ValueError, 'invalid value: ' + text
     2328            raise ValueError('invalid value: ' + text)
    23312329        index = string.find(text, separator)
    23322330        if index >= 0:
     
    25462544    def _state(self):
    25472545        if self['state'] not in ('both', 'balloon', 'status', 'none'):
    2548             raise ValueError, 'bad state option ' + repr(self['state']) + \
    2549                 ': should be one of \'both\', \'balloon\', ' + \
    2550                 '\'status\' or \'none\''
     2546            raise ValueError('bad state option ' + repr(self['state'])
     2547                             + ": should be one of 'both', 'balloon', "
     2548                             + "'status' or 'none'")
    25512549
    25522550    def _relmouse(self):
    25532551        if self['relmouse'] not in ('both', 'x', 'y', 'none'):
    2554             raise ValueError, 'bad relmouse option ' + repr(self['relmouse'])+ \
    2555                 ': should be one of \'both\', \'x\', ' + '\'y\' or \'none\''
     2552            raise ValueError("bad relmouse option %s: should be one of 'both', 'x', "
     2553                             "'y' or 'none'" % repr(self['relmouse']))
    25562554
    25572555    def _enter(self, event, widget, statusHelp, balloonHelp, isItem):
     
    27472745            interior.grid_rowconfigure(columnOrRow, weight = 1)
    27482746        else:
    2749             raise ValueError, 'bad orient option ' + repr(orient) + \
    2750                 ': must be either \'horizontal\' or \'vertical\''
     2747            raise ValueError("bad orient option %s: must be either 'horizontal' or "
     2748                             "'vertical'" % repr(orient))
    27512749
    27522750        # Initialise instance variables.
     
    27822780                return index
    27832781            else:
    2784                 raise ValueError, 'index "%s" is out of range' % index
     2782                raise ValueError('index "%s" is out of range' % index)
    27852783        elif index is END:
    27862784            if forInsert:
     
    27892787                return listLength - 1
    27902788            else:
    2791                 raise ValueError, 'ButtonBox has no buttons'
     2789                raise ValueError('ButtonBox has no buttons')
    27922790        elif index is DEFAULT:
    27932791            if self._defaultButton is not None:
    27942792                return self._defaultButton
    2795             raise ValueError, 'ButtonBox has no default'
     2793            raise ValueError('ButtonBox has no default')
    27962794        else:
    27972795            names = map(lambda t: t[0], self._buttonList)
     
    27992797                return names.index(index)
    28002798            validValues = 'a name, a number, END or DEFAULT'
    2801             raise ValueError, \
    2802                 'bad index "%s": must be %s' % (index, validValues)
     2799            raise ValueError('bad index "%s": must be %s' % (index, validValues))
    28032800
    28042801    def insert(self, componentName, beforeComponent = 0, **kw):
    28052802        if componentName in self.components():
    2806             raise ValueError, 'button "%s" already exists' % componentName
     2803            raise ValueError('button "%s" already exists' % componentName)
    28072804        if not kw.has_key('text'):
    28082805            kw['text'] = componentName
     
    31123109            msg = 'bad %s value "%s":  must be a function or one of ' \
    31133110                'the standard validators %s or extra validators %s'
    3114             raise ValueError, msg % (option, validator, standard, extra)
     3111            raise ValueError(msg % (option, validator, standard, extra))
    31153112
    31163113    def _executeCommand(self, event = None):
     
    36383635
    36393636        if (menuName) in self.components():
    3640             raise ValueError, 'menu "%s" already exists' % menuName
     3637            raise ValueError('menu "%s" already exists' % menuName)
    36413638
    36423639        menukw = {}
     
    36973694            command = menu.add_cascade
    36983695        else:
    3699             raise ValueError, 'unknown menuitem type "%s"' % itemType
     3696            raise ValueError('unknown menuitem type "%s"' % itemType)
    37003697
    37013698        self._menuInfo[menuName][1].append(statusHelp)
     
    38753872
    38763873        if (menuName + '-menu') in self.components():
    3877             raise ValueError, 'menu "%s" already exists' % menuName
     3874            raise ValueError('menu "%s" already exists' % menuName)
    38783875
    38793876        menukw = {}
     
    39403937            command = menu.add_cascade
    39413938        else:
    3942             raise ValueError, 'unknown menuitem type "%s"' % itemType
     3939            raise ValueError('unknown menuitem type "%s"' % itemType)
    39433940
    39443941        self._menuInfo[menuName][1].append(statusHelp)
     
    42064203                    Tkinter.Label, (interior,))
    42074204            if iconpos not in 'nsew':
    4208                 raise ValueError, \
    4209                     'bad iconpos option "%s":  should be n, s, e, or w' \
    4210                         % iconpos
     4205                raise ValueError('bad iconpos option "%s":  should be n, s, e, or w'
     4206                                 % iconpos)
    42114207
    42124208            if iconpos in 'nw':
     
    42734269        tabpos = self['tabpos']
    42744270        if tabpos is not None and tabpos != 'n':
    4275             raise ValueError, \
    4276                 'bad tabpos option %s:  should be n or None' % repr(tabpos)
     4271            raise ValueError('bad tabpos option %s:  should be n or None'
     4272                             % repr(tabpos))
    42774273        self._withTabs = (tabpos is not None)
    42784274        self._pageMargin = self['pagemargin']
     
    43664362        if self._pageAttrs.has_key(pageName):
    43674363            msg = 'Page "%s" already exists.' % pageName
    4368             raise ValueError, msg
     4364            raise ValueError(msg)
    43694365
    43704366        # Do this early to catch bad <before> spec before creating any items.
     
    43884384                del kw[key]
    43894385            else:
    4390                 raise KeyError, 'Unknown option "' + key + '"'
     4386                raise KeyError('Unknown option "' + key + '"')
    43914387
    43924388        # Create the frame to contain the page.
     
    45134509                return index
    45144510            else:
    4515                 raise ValueError, 'index "%s" is out of range' % index
     4511                raise ValueError('index "%s" is out of range' % index)
    45164512        elif index is END:
    45174513            if forInsert:
     
    45204516                return listLength - 1
    45214517            else:
    4522                 raise ValueError, 'NoteBook has no pages'
     4518                raise ValueError('NoteBook has no pages')
    45234519        elif index is SELECT:
    45244520            if listLength == 0:
    4525                 raise ValueError, 'NoteBook has no pages'
     4521                raise ValueError('NoteBook has no pages')
    45264522            return self._pageNames.index(self.getcurselection())
    45274523        else:
     
    45294525                return self._pageNames.index(index)
    45304526            validValues = 'a name, a number, END or SELECT'
    4531             raise ValueError, \
    4532                 'bad index "%s": must be %s' % (index, validValues)
     4527            raise ValueError('bad index "%s": must be %s' % (index, validValues))
    45334528
    45344529    def selectpage(self, page):
     
    49774972                return index
    49784973            else:
    4979                 raise ValueError, 'index "%s" is out of range' % index
     4974                raise ValueError('index "%s" is out of range' % index)
    49804975        elif index is END:
    49814976            if listLength > 0:
    49824977                return listLength - 1
    49834978            else:
    4984                 raise ValueError, 'OptionMenu has no items'
     4979                raise ValueError('OptionMenu has no items')
    49854980        else:
    49864981            if index is SELECT:
     
    49884983                    index = self.getcurselection()
    49894984                else:
    4990                     raise ValueError, 'OptionMenu has no items'
     4985                    raise ValueError('OptionMenu has no items')
    49914986            if index in self._itemList:
    49924987                return self._itemList.index(index)
    4993             raise ValueError, \
    4994                     'bad index "%s": must be a ' \
    4995                     'name, a number, END or SELECT' % (index,)
     4988            raise ValueError('bad index "%s": must be a name, a number, END or SELECT'
     4989                             % (index,))
    49964990
    49974991    def invoke(self, index = SELECT):
     
    50435037
    50445038        if self['orient'] not in ('horizontal', 'vertical'):
    5045             raise ValueError, 'bad orient option ' + repr(self['orient']) + \
    5046                 ': must be either \'horizontal\' or \'vertical\''
     5039            raise ValueError("bad orient option %s: must be either 'horizontal' or "
     5040                             "'vertical'" % repr(self['orient']))
    50475041
    50485042        self._separatorThickness = self['separatorthickness']
     
    52375231                self._max[name], self._relmax[name] = value, relvalue
    52385232            else:
    5239                 raise ValueError, 'keyword must be "size", "min", or "max"'
     5233                raise ValueError('keyword must be "size", "min", or "max"')
    52405234
    52415235    def _absSize(self, relvalue):
     
    57435737            self._singleSelect = 0
    57445738        else:
    5745             raise ValueError, 'bad selectmode option "' + \
    5746                     self['selectmode'] + '": should be single or multiple'
     5739            raise ValueError('bad selectmode option "' + self['selectmode']
     5740                             + '": should be single or multiple')
    57475741
    57485742        if self['buttontype'] == 'button':
     
    57565750            self.buttonClass = Tkinter.Checkbutton
    57575751        else:
    5758             raise ValueError, 'bad buttontype option "' + \
    5759                     self['buttontype'] + \
    5760                     '": should be button, radiobutton or checkbutton'
     5752            raise ValueError('bad buttontype option "' + self['buttontype']
     5753                             + '": should be button, radiobutton or checkbutton')
    57615754
    57625755        if self._singleSelect:
     
    57665759
    57675760        if self['orient'] not in ('horizontal', 'vertical'):
    5768             raise ValueError, 'bad orient option ' + repr(self['orient']) + \
    5769                 ': must be either \'horizontal\' or \'vertical\''
     5761            raise ValueError('bad orient option ' + repr(self['orient'])
     5762                             + ': must be either \'horizontal\' or \'vertical\'')
    57705763
    57715764        # Check keywords and initialise options.
     
    58175810                return index
    58185811            else:
    5819                 raise ValueError, 'index "%s" is out of range' % index
     5812                raise ValueError('index "%s" is out of range' % index)
    58205813        elif index is END:
    58215814            if listLength > 0:
    58225815                return listLength - 1
    58235816            else:
    5824                 raise ValueError, 'RadioSelect has no buttons'
     5817                raise ValueError('RadioSelect has no buttons')
    58255818        else:
    58265819            for count in range(listLength):
     
    58295822                    return count
    58305823            validValues = 'a name, a number or END'
    5831             raise ValueError, \
    5832                     'bad index "%s": must be %s' % (index, validValues)
     5824            raise ValueError('bad index "%s": must be %s' % (index, validValues))
    58335825
    58345826    def button(self, buttonIndex):
     
    58385830    def add(self, componentName, **kw):
    58395831        if componentName in self._buttonList:
    5840             raise ValueError, 'button "%s" already exists' % componentName
     5832            raise ValueError('button "%s" already exists' % componentName)
    58415833
    58425834        kw['command'] = \
     
    60616053        else:
    60626054            message = 'bad hscrollmode option "%s": should be static, dynamic, or none' % mode
    6063             raise ValueError, message
     6055            raise ValueError(message)
    60646056
    60656057        self._configureScrollCommands()
     
    60816073        else:
    60826074            message = 'bad vscrollmode option "%s": should be static, dynamic, or none' % mode
    6083             raise ValueError, message
     6075            raise ValueError(message)
    60846076
    60856077        self._configureScrollCommands()
     
    64836475        else:
    64846476            message = 'bad hscrollmode option "%s": should be static, dynamic, or none' % mode
    6485             raise ValueError, message
     6477            raise ValueError(message)
    64866478
    64876479    def _vscrollMode(self):
     
    65016493        else:
    65026494            message = 'bad vscrollmode option "%s": should be static, dynamic, or none' % mode
    6503             raise ValueError, message
     6495            raise ValueError(message)
    65046496
    65056497    def _horizflex(self):
     
    65116503            message = 'bad horizflex option "%s": should be one of %s' % \
    65126504                    (flex, str(self._flexoptions))
    6513             raise ValueError, message
     6505            raise ValueError(message)
    65146506
    65156507        self.reposition()
     
    65236515            message = 'bad vertflex option "%s": should be one of %s' % \
    65246516                    (flex, str(self._flexoptions))
    6525             raise ValueError, message
     6517            raise ValueError(message)
    65266518
    65276519        self.reposition()
     
    68186810                self._listbox.selection_set(listitems.index(textOrList))
    68196811            else:
    6820                 raise ValueError, 'no such item "%s"' % textOrList
     6812                raise ValueError('no such item "%s"' % textOrList)
    68216813        else:
    68226814            for item in textOrList:
     
    68246816                    self._listbox.selection_set(listitems.index(item))
    68256817                else:
    6826                     raise ValueError, 'no such item "%s"' % item
     6818                    raise ValueError('no such item "%s"' % item)
    68276819
    68286820    def setlist(self, items):
     
    68616853        else:
    68626854            message = 'bad hscrollmode option "%s": should be static, dynamic, or none' % mode
    6863             raise ValueError, message
     6855            raise ValueError(message)
    68646856
    68656857        self._configureScrollCommands()
     
    68816873        else:
    68826874            message = 'bad vscrollmode option "%s": should be static, dynamic, or none' % mode
    6883             raise ValueError, message
     6875            raise ValueError(message)
    68846876
    68856877        self._configureScrollCommands()
     
    72827274        else:
    72837275            message = 'bad hscrollmode option "%s": should be static, dynamic, or none' % mode
    7284             raise ValueError, message
     7276            raise ValueError(message)
    72857277
    72867278        self._configureScrollCommands()
     
    73027294        else:
    73037295            message = 'bad vscrollmode option "%s": should be static, dynamic, or none' % mode
    7304             raise ValueError, message
     7296            raise ValueError(message)
    73057297
    73067298        self._configureScrollCommands()
     
    80378029        list = string.split(text, ':')
    80388030        if len(list) != 3:
    8039             raise ValueError, 'invalid value: ' + text
     8031            raise ValueError('invalid value: ' + text)
    80408032
    80418033        self._hour = string.atoi(list[0])
     
    83638355                index = list(items).index(text)
    83648356            else:
    8365                 raise IndexError, 'index "%s" not found' % text
     8357                raise IndexError('index "%s" not found' % text)
    83668358        elif setentry:
    83678359            text = self._list.get(0, 'end')[index]
     
    87378729                frame.grid_columnconfigure(0, pad = padx)
    87388730        else:
    8739             raise ValueError, 'bad orient option ' + repr(orient) + \
    8740                 ': must be either \'horizontal\' or \'vertical\''
     8731            raise ValueError('bad orient option ' + repr(orient)
     8732                             + ': must be either \'horizontal\' or \'vertical\'')
    87418733
    87428734        self.createlabel(interior)
     
    88488840            validValues = _counterCommands.keys()
    88498841            validValues.sort()
    8850             raise ValueError, ('bad datatype value "%s":  must be a' +
    8851                     ' function or one of %s') % (datatype, validValues)
     8842            raise ValueError('bad datatype value "%s":  must be a function '
     8843                             'or one of %s' % (datatype, validValues))
    88528844
    88538845    def _forceCount(self, factor):
     
    91059097def logicalfont(name='Helvetica', sizeIncr = 0, **kw):
    91069098  if not _fontInfo.has_key(name):
    9107     raise ValueError, 'font %s does not exist' % name
     9099    raise ValueError('font %s does not exist' % name)
    91089100
    91099101  rtn = []
  • trunk/anuga_core/source/anuga/pmesh/mesh_interface.py

    r8010 r8124  
    110110            msg = 'Caching was requested, but caching module'+\
    111111                  'could not be imported'
    112             raise msg
     112            raise Exception(msg)
    113113
    114114
     
    152152                      %(str(key))
    153153                msg += 'Number of points in bounding polygon = %d' % max_points
    154                 raise SegmentError, msg
     154                raise SegmentError(msg)
    155155
    156156        for i in range(max_points):
     
    162162                msg = 'Segment %d was not assigned a boundary_tag.' % i
    163163                msg +=  'Default tag "exterior" will be assigned to missing segment'
    164                 #raise Exception, msg
     164                #raise Exception(msg)
    165165                # Fixme: Use proper Python warning
    166166                if verbose: log.critical('WARNING: %s' % msg)
     
    197197
    198198                if fail_if_polygons_outside is True:
    199                     raise PolygonError, msg                   
     199                    raise PolygonError(msg)
    200200                else:
    201201                    msg += ' I will ignore it.'
     
    239239                msg = 'Interior polygon %s is outside bounding polygon: %s'\
    240240                      %(str(interior_polygon), str(bounding_polygon))
    241                 raise PolygonError, msg
     241                raise PolygonError(msg)
    242242
    243243    # Resolve geo referencing       
  • trunk/anuga_core/source/anuga/shallow_water/boundaries.py

    r7861 r8124  
    4848    """
    4949
    50     ##
    51     # @brief Instantiate a Reflective_boundary.
    52     # @param domain
    5350    def __init__(self, domain=None):
    5451        Boundary.__init__(self)
     
    6663        self.conserved_quantities = num.zeros(3, num.float)
    6764
    68     ##
    69     # @brief Return a representation of this instance.
    7065    def __repr__(self):
    7166        return 'Reflective_boundary'
    7267
    73     ##
    74     # @brief Calculate reflections (reverse outward momentum).
    75     # @param vol_id
    76     # @param edge_id
    7768    def evaluate(self, vol_id, edge_id):
    78         """Reflective boundaries reverses the outward momentum
    79         of the volume they serve.
     69        """Calculate reflections (reverse outward momentum).
     70
     71        vol_id   
     72        edge_id 
    8073        """
    8174
  • trunk/anuga_core/source/anuga/shallow_water/forcing.py

    r8116 r8124  
    4444            msg = 'Function %s could not be executed:\n%s' %(f, e)
    4545            # FIXME: Reconsider this semantics
    46             raise Exception, msg
     46            raise Exception(msg)
    4747
    4848        try:
     
    5252                   'be converted into a numeric array of floats.\nSpecified '
    5353                   'function should return either list or array.' % f)
    54             raise Exception, msg
     54            raise Exception(msg)
    5555
    5656        # Is this really what we want?
     
    6363        except:
    6464            msg = '%s must return vector' % func_msg
    65             raise Exception, msg
     65            raise Exception(msg)
    6666        msg = '%s must return vector of length %d' % (func_msg, N)
    6767        assert result_len == N, msg
     
    7272            msg = ('Force field %s must be a scalar value coercible to float.'
    7373                   % str(f))
    74             raise Exception, msg
     74            raise Exception(msg)
    7575
    7676    return f
     
    147147               phi = kwargs['phi']
    148148           else:
    149                raise Exception, 'Assumes two keyword arguments: s=..., phi=....'
     149               raise Exception('Assumes two keyword arguments: s=..., phi=....')
    150150
    151151        if ( self.use_coordinates ):
     
    183183            except:
    184184                msg = 'Speed must be either callable or a scalar: %s' %self.s
    185                 raise msg
     185                raise Exception(msg)
    186186
    187187        if callable(self.phi):
     
    200200            except:
    201201                msg = 'Angle must be either callable or a scalar: %s' %self.phi
    202                 raise msg
     202                raise Exception(msg)
    203203
    204204        assign_windfield_values(xmom_update, ymom_update,
     
    388388                msg = 'No triangles have been identified in '
    389389                msg += 'specified region: %s' % inlet_region
    390                 raise Exception, msg
     390                raise Exception(msg)
    391391
    392392            # Compute exchange area as the sum of areas of triangles identified
     
    421421                default_rate(0.0)
    422422            except:
    423                 raise Exception, msg
     423                raise Exception(msg)
    424424
    425425        self.default_rate = default_rate
     
    437437            rate = self.update_rate(t)
    438438        except Modeltime_too_early, e:
    439             raise Modeltime_too_early, e
     439            raise Modeltime_too_early(e)
    440440        except Modeltime_too_late, e:
    441441            if self.default_rate is None:
     
    443443                msg += 'You can specify keyword argument default_rate in the '
    444444                msg += 'forcing function to tell it what to do in the absence of time data.'
    445                 raise Modeltime_too_late, msg   
     445                raise Modeltime_too_late(msg)
    446446            else:
    447447                # Pass control to default rate function
     
    464464            msg = ('Attribute rate must be specified in General_forcing '
    465465                   'or its descendants before attempting to call it')
    466             raise Exception, msg
     466            raise Exception(msg)
    467467
    468468        # Now rate is a number
     
    947947               self.use_coordinates = kwargs['use_coordinates']
    948948           else:
    949                raise Exception, 'Assumes one keyword argument: p=... or two keyword arguments p=...,use_coordinates=...'
     949               raise Exception('Assumes one keyword argument: p=... or two '
     950                               'keyword arguments p=...,use_coordinates=...')
    950951
    951952        if ( self.use_coordinates ):
     
    980981            except:
    981982                msg = 'Pressure must be either callable or a scalar: %s' %self.s
    982                 raise msg
     983                raise Exception(msg)
    983984
    984985        stage = domain.quantities['stage']
     
    10931094                    self.use_coordinates=False
    10941095                else:
    1095                     raise Exception, 'Assumes zero or two keyword arguments filename=...,domain=...'
     1096                    raise Exception('Assumes zero or two keyword arguments '
     1097                                    'filename=...,domain=...')
    10961098
    10971099                if ( self.use_coordinates ):
     
    11101112               self.use_coordinates = False
    11111113           else:
    1112                raise Exception, 'Assumes one keyword argument: p=f(t,x,y,) or three keyword arguments p=f(t,i),filename=...,domain=...'
     1114               raise Exception('Assumes one keyword argument: p=f(t,x,y,) or '
     1115                               'three keyword arguments '
     1116                               'p=f(t,i),filename=...,domain=...')
    11131117
    11141118        if ( self.use_coordinates ):
     
    11261130            msg = 'pressure_file.starttime > domain.starttime'
    11271131            if (self.file_time[0]>domain.starttime):
    1128                 raise Exception, msg
     1132                raise Exception(msg)
    11291133
    11301134            msg = 'pressure_file[-1] < domain.starttime'
    11311135            if (self.file_time[-1]<domain.starttime):
    1132                 raise Exception, msg
     1136                raise Exception(msg)
    11331137
    11341138            msg = 'No pressure values exist for times greater than domain.starttime'
     
    11851189            except:
    11861190                msg = 'Pressure must be either callable function or a scalar: %s' %self.s
    1187                 raise msg
     1191                raise Exception(msg)
    11881192
    11891193        stage = domain.quantities['stage']
     
    12881292               phi = kwargs['phi']
    12891293           else:
    1290                raise Exception, 'Assumes two keyword arguments: s=..., phi=....'
     1294               raise Exception('Assumes two keyword arguments: s=...,phi=....')
    12911295
    12921296        if ( self.use_coordinates ):
     
    13071311            msg = 'wind_file.starttime > domain.starttime'
    13081312            if (self.file_time[0]>domain.starttime):
    1309                 raise Exception, msg
     1313                raise Exception(msg)
    13101314
    13111315            msg = 'wind_file[-1] < domain.starttime'
    13121316            if (self.file_time[-1]<domain.starttime):
    1313                 raise Exception, msg
     1317                raise Exception(msg)
    13141318
    13151319            msg = 'No wind values exist for times greater than domain.starttime'
    13161320            if (self.file_time[-2]<domain.starttime and self.file_time[-1]>domain.starttime):
    1317                 raise Exception, msg
     1321                raise Exception(msg)
    13181322
    13191323            # FIXME(JJ): How do we check that evolve
     
    13731377            except:
    13741378                msg = 'Speed must be either callable or a scalar: %s' %self.s
    1375                 raise msg
     1379                raise Exception(msg)
    13761380
    13771381        if callable(self.phi):
     
    13951399            except:
    13961400                msg = 'Angle must be either callable or a scalar: %s' %self.phi
    1397                 raise msg
     1401                raise Exception(msg)
    13981402
    13991403        assign_windfield_values(xmom_update, ymom_update,
  • trunk/anuga_core/source/anuga/shallow_water/most2nc.py

    r7317 r8124  
    1313
    1414
    15 ##
    16 # @brief Convert a MOST file to NetCDF format.
    17 # @param input_file The input file to convert.
    18 # @param output_file The name of the oputput NetCDF file to create,
    19 # @param inverted_bathymetry ??
    20 # @param verbose True if the function is to be verbose.
    2115def most2nc(input_file, output_file, inverted_bathymetry=False, verbose=True):
     16    """Convert a MOST file to NetCDF format.
     17
     18    input_file           the input file to convert
     19    output_file          the name of the oputput NetCDF file to create
     20    inverted_bathymetry  ??
     21    verbose              True if the function is to be verbose
     22    """
     23
    2224    # variable names
    2325    long_name = 'LON'
  • trunk/anuga_core/source/anuga/shallow_water/shallow_water_domain.py

    r8100 r8124  
    301301            #self.reduction = min  #Looks better near steep slopes
    302302
    303     ##
    304     # @brief Set the minimum depth that will be written to an SWW file.
    305     # @param minimum_storable_height The minimum stored height (in m).
    306303    def set_minimum_storable_height(self, minimum_storable_height):
    307         """Set the minimum depth that will be recognised when writing
    308         to an sww file. This is useful for removing thin water layers
    309         that seems to be caused by friction creep.
    310 
    311         The minimum allowed sww depth is in meters.
     304        """Set the minimum depth that will be written to an SWW file.
     305
     306        minimum_storable_height  minimum allowed SWW depth is in meters
     307
     308        This is useful for removing thin water layers that seems to be caused
     309        by friction creep.
    312310        """
    313311
    314312        self.minimum_storable_height = minimum_storable_height
    315313
    316     ##
    317     # @brief
    318     # @param minimum_allowed_height
    319314    def set_minimum_allowed_height(self, minimum_allowed_height):
    320315        """Set minimum depth that will be recognised in the numerical scheme.
    321316
    322         The minimum allowed depth is in meters.
    323 
    324         The parameter H0 (Minimal height for flux computation)
    325         is also set by this function
     317        minimum_allowed_height  minimum allowed depth in meters
     318
     319        The parameter H0 (Minimal height for flux computation) is also set by
     320        this function.
    326321        """
    327322
     
    335330        self.H0 = minimum_allowed_height
    336331
    337     ##
    338     # @brief
    339     # @param maximum_allowed_speed
    340332    def set_maximum_allowed_speed(self, maximum_allowed_speed):
    341         """Set the maximum particle speed that is allowed in water
    342         shallower than minimum_allowed_height. This is useful for
    343         controlling speeds in very thin layers of water and at the same time
    344         allow some movement avoiding pooling of water.
     333        """Set the maximum particle speed that is allowed in water shallower
     334        than minimum_allowed_height.
     335
     336        maximum_allowed_speed 
     337
     338        This is useful for controlling speeds in very thin layers of water and
     339        at the same time allow some movement avoiding pooling of water.
    345340        """
    346341
    347342        self.maximum_allowed_speed = maximum_allowed_speed
    348343
    349     ##
    350     # @brief
    351     # @param points_file_block_line_size
    352344    def set_points_file_block_line_size(self, points_file_block_line_size):
    353         """Set the minimum depth that will be recognised when writing
    354         to an sww file. This is useful for removing thin water layers
    355         that seems to be caused by friction creep.
    356 
    357         The minimum allowed sww depth is in meters.
    358         """
     345        """
     346        """
     347
    359348        self.points_file_block_line_size = points_file_block_line_size
    360349
    361350       
    362351    # FIXME: Probably obsolete in its curren form   
    363     ##
    364     # @brief Set the quantities that will be written to an SWW file.
    365     # @param q The quantities to be written.
    366     # @note Param 'q' may be None, single quantity or list of quantity strings.
    367     # @note If 'q' is None, no quantities will be stored in the SWW file.
    368352    def set_quantities_to_be_stored(self, q):
    369         """Specify which quantities will be stored in the sww file
     353        """Specify which quantities will be stored in the SWW file.
    370354       
    371355        q must be either:
     
    409393        self.quantities_to_be_stored = q
    410394
    411     ##
    412     # @brief
    413     # @param indices
    414395    def get_wet_elements(self, indices=None):
    415396        """Return indices for elements where h > minimum_allowed_height
     
    439420        return wet_indices
    440421
    441     ##
    442     # @brief
    443     # @param indices
    444422    def get_maximum_inundation_elevation(self, indices=None):
    445423        """Return highest elevation where h > 0
     
    458436                   get_maximum_value(indices=wet_elements)
    459437
    460     ##
    461     # @brief
    462     # @param indices
    463438    def get_maximum_inundation_location(self, indices=None):
    464439        """Return location of highest elevation where h > 0
     
    883858#-----------------
    884859
    885 ## @brief Compute fluxes and timestep suitable for all volumes in domain.
    886 # @param domain The domain to calculate fluxes for.
    887860def compute_fluxes(domain):
    888861    """Compute fluxes and timestep suitable for all volumes in domain.
     
    949922################################################################################
    950923
    951 ##
    952 # @brief Wrapper for C version of extrapolate_second_order_sw.
    953 # @param domain The domain to operate on.
    954 # @note MH090605 The following method belongs to the shallow_water domain class
    955 #       see comments in the corresponding method in shallow_water_ext.c
    956924def extrapolate_second_order_sw(domain):
    957     """Wrapper calling C version of extrapolate_second_order_sw"""
     925    """Wrapper calling C version of extrapolate_second_order_sw.
     926
     927    domain  the domain to operate on
     928
     929    Note MH090605: The following method belongs to the shallow_water domain
     930    class, see comments in the corresponding method in shallow_water_ext.c
     931    """
    958932
    959933    from shallow_water_ext import extrapolate_second_order_sw as extrapol2
     
    980954              int(domain.optimise_dry_cells))
    981955
    982 ##
    983 # @brief Distribution from centroids to vertices specific to the SWW eqn.
    984 # @param domain The domain to operate on.
    985956def distribute_using_vertex_limiter(domain):
    986957    """Distribution from centroids to vertices specific to the SWW equation.
     
    10401011        Q.interpolate_from_vertices_to_edges()
    10411012
    1042 ##
    1043 # @brief Distribution from centroids to edges specific to the SWW eqn.
    1044 # @param domain The domain to operate on.
    10451013def distribute_using_edge_limiter(domain):
    10461014    """Distribution from centroids to edges specific to the SWW eqn.
     
    10811049        Q.interpolate_from_vertices_to_edges()
    10821050
    1083 ##
    1084 # @brief  Protect against infinitesimal heights and associated high velocities.
    1085 # @param domain The domain to operate on.
    10861051def protect_against_infinitesimal_and_negative_heights(domain):
    10871052    """Protect against infinitesimal heights and associated high velocities"""
     
    10981063            domain.epsilon, wc, zc, xmomc, ymomc)
    10991064
    1100 ##
    1101 # @brief Wrapper for C function balance_deep_and_shallow_c().
    1102 # @param domain The domain to operate on.
    11031065def balance_deep_and_shallow(domain):
    11041066    """Compute linear combination between stage as computed by
     
    11421104################################################################################
    11431105
    1144 ##
    1145 # @brief Apply gravitational pull in the presence of bed slope.
    1146 # @param domain The domain to apply gravity to.
    1147 # @note Wrapper for C function gravity_c().
    11481106def gravity(domain):
    11491107    """Apply gravitational pull in the presence of bed slope
     
    11671125    gravity_c(domain.g, height, elevation, point, xmom_update, ymom_update)
    11681126
    1169 ##
    1170 # @brief Apply friction to a surface (implicit).
    1171 # @param domain The domain to apply Manning friction to.
    1172 # @note Wrapper for C function manning_friction_c().
    11731127def manning_friction_implicit(domain):
    11741128    """Apply (Manning) friction to water momentum
     
    12051159   
    12061160
    1207 ##
    1208 # @brief Apply friction to a surface (explicit).
    1209 # @param domain The domain to apply Manning friction to.
    1210 # @note Wrapper for C function manning_friction_c().
    12111161def manning_friction_explicit(domain):
    12121162    """Apply (Manning) friction to water momentum
     
    12441194
    12451195# FIXME (Ole): This was implemented for use with one of the analytical solutions
    1246 ##
    1247 # @brief Apply linear friction to a surface.
    1248 # @param domain The domain to apply Manning friction to.
    1249 # @note Is this still used (30 Oct 2007)?
    12501196def linear_friction(domain):
    12511197    """Apply linear friction to water momentum
  • trunk/anuga_core/source/anuga/shallow_water/sww_interrogate.py

    r7858 r8124  
    1414from anuga.abstract_2d_finite_volumes.neighbour_mesh import segment_midpoints
    1515
    16 ##
    17 # @brief Get values for quantities interpolated to polyline midpoints from SWW.
    18 # @param filename Path to file to read.
    19 # @param quantity_names Quantity names to get.
    20 # @param polyline Representation of desired cross-section.
    21 # @param verbose True if this function is to be verbose.
    22 # @return (segments, i_func) where segments is a list of Triangle_intersection
    23 #         instances and i_func is an instance of Interpolation_function.
    24 # @note For 'polyline' assume absolute UTM coordinates.
     16
    2517def get_interpolated_quantities_at_polyline_midpoints(filename,
    2618                                                      quantity_names=None,
    2719                                                      polyline=None,
    2820                                                      verbose=False):
    29     """Get values for quantities interpolated to polyline midpoints from SWW
    30 
    31     Input:
    32         filename - Name of sww file
    33         quantity_names - Names of quantities to load
    34         polyline: Representation of desired cross section - it may contain
    35                   multiple sections allowing for complex shapes. Assume
    36                   absolute UTM coordinates.
    37                   Format [[x0, y0], [x1, y1], ...]
    38 
    39     Output:
    40         segments: list of instances of class Triangle_intersection
    41         interpolation_function: Instance of class Interpolation_function
    42 
    43 
    44       This function is used by get_flow_through_cross_section and
    45       get_energy_through_cross_section
     21    """Get values for quantities interpolated to polyline midpoints from SWW.
     22
     23    filename        path to file to read
     24    quantity_names  quantity names to get
     25    polyline        representation of desired cross-section
     26                    may contain multiple sections allowing complex shapes
     27                    assume UTM coordinates
     28    verbose         True if this function is to be verbose
     29
     30    Returns (segments, i_func)
     31    where segments is a list of Triangle_intersection instances
     32      and i_func is an instance of Interpolation_function.
     33
     34    Note: For 'polyline' assume absolute UTM coordinates.
     35
     36    This function is used by get_flow_through_cross_section and
     37    get_energy_through_cross_section.
    4638    """
    4739
     
    7668
    7769
    78 ##
    79 # @brief Obtain flow (m^3/s) perpendicular to specified cross section.
    80 # @param filename Path to file to read.
    81 # @param polyline Representation of desired cross-section.
    82 # @param verbose Trie if this function is to be verbose.
    83 # @return (time, Q) where time and Q are lists of time and flow respectively.
    8470def get_flow_through_cross_section(filename, polyline, verbose=False):
    8571    """Obtain flow (m^3/s) perpendicular to specified cross section.
    8672
    87     Inputs:
    88         filename: Name of sww file
    89         polyline: Representation of desired cross section - it may contain
    90                   multiple sections allowing for complex shapes. Assume
    91                   absolute UTM coordinates.
    92                   Format [[x0, y0], [x1, y1], ...]
    93 
    94     Output:
    95         time: All stored times in sww file
    96         Q: Hydrograph of total flow across given segments for all stored times.
     73    filename  path to SWW file to read
     74    polyline  representation of desired cross-section - it may contain
     75              multiple sections allowing for complex shapes. Assume
     76              absolute UTM coordinates.
     77              Format [[x0, y0], [x1, y1], ...]
     78    verbose   True if this function is to be verbose
     79
     80    Return (time, Q)
     81    where time is a list of all stored times in SWW file
     82      and Q is a hydrograph of total flow across given segments for all
     83            stored times.
    9784
    9885    The normal flow is computed for each triangle intersected by the polyline
     
    147134
    148135
    149 ##
    150 # @brief Get average energy across a cross-section.
    151 # @param filename Path to file of interest.
    152 # @param polyline Representation of desired cross-section.
    153 # @param kind Select energy to compute: 'specific' or 'total'.
    154 # @param verbose True if this function is to be verbose.
    155 # @return (time, E) where time and E are lists of timestep and energy.
    156136def get_energy_through_cross_section(filename,
    157137                                     polyline,
     
    160140    """Obtain average energy head [m] across specified cross section.
    161141
    162     Inputs:
    163         polyline: Representation of desired cross section - it may contain
    164                   multiple sections allowing for complex shapes. Assume
    165                   absolute UTM coordinates.
    166                   Format [[x0, y0], [x1, y1], ...]
    167         kind:     Select which energy to compute.
    168                   Options are 'specific' and 'total' (default)
    169 
    170     Output:
    171         E: Average energy [m] across given segments for all stored times.
    172 
    173     The average velocity is computed for each triangle intersected by
    174     the polyline and averaged weighted by segment lengths.
     142    filename  path to file of interest
     143    polyline  representation of desired cross-section - it may contain multiple
     144              sections allowing for complex shapes. Assume absolute UTM
     145              coordinates.  Format [[x0, y0], [x1, y1], ...]
     146    kind      select energy to compute: 'specific' or 'total'
     147    verbose   True if this function is to be verbose
     148
     149    Returns (time, E)
     150    where time is a list of timestep
     151      and E isaAverage energy [m] across given segments for all stored times.
     152
     153    The average velocity is computed for each triangle intersected by the
     154    polyline and averaged weighted by segment lengths.
    175155
    176156    The typical usage of this function would be to get average energy of
     
    247227
    248228
    249 ##
    250 # @brief Return highest elevation where depth > 0.
    251 # @param filename Path to SWW file of interest.
    252 # @param polygon If specified resrict to points inside this polygon.
    253 # @param time_interval If specified resrict to within the time specified.
    254 # @param verbose True if this function is  to be verbose.
    255229def get_maximum_inundation_elevation(filename,
    256230                                     polygon=None,
     
    259233    """Return highest elevation where depth > 0
    260234
     235    filename       path to SWW file containing ANUGA model output
     236    polygon        if specified restrict to points inside this polygon
     237    time_interval  if specified restrict to within the period specified
     238    verbose        True if this function is  to be verbose
     239
     240    If no inundation is found within polygon and time_interval the return value
     241    is None signifying "No Runup" or "Everything is dry".
     242
    261243    Usage:
    262244    max_runup = get_maximum_inundation_elevation(filename,
     
    265247                                                 verbose=False)
    266248
    267     filename is a NetCDF sww file containing ANUGA model output.
    268     Optional arguments polygon and time_interval restricts the maximum
    269     runup calculation
    270     to a points that lie within the specified polygon and time interval.
    271 
    272     If no inundation is found within polygon and time_interval the return value
    273     is None signifying "No Runup" or "Everything is dry".
    274 
    275249    See general function get_maximum_inundation_data for details.
    276250    """
     
    283257
    284258
    285 ##
    286 # @brief Return location of highest elevation where h > 0
    287 # @param filename Path to SWW file to read.
    288 # @param polygon If specified resrict to points inside this polygon.
    289 # @param time_interval If specified resrict to within the time specified.
    290 # @param verbose True if this function is  to be verbose.
    291259def get_maximum_inundation_location(filename,
    292260                                    polygon=None,
     
    295263    """Return location of highest elevation where h > 0
    296264
     265    filename       path to SWW file containing ANUGA model output
     266    polygon        if specified restrict to points inside this polygon
     267    time_interval  if specified restrict to within the period specified
     268    verbose        True if this function is  to be verbose
     269
     270    If no inundation is found within polygon and time_interval the return value
     271    is None signifying "No Runup" or "Everything is dry".
     272
    297273    Usage:
    298274    max_runup_location = get_maximum_inundation_location(filename,
     
    301277                                                         verbose=False)
    302278
    303     filename is a NetCDF sww file containing ANUGA model output.
    304     Optional arguments polygon and time_interval restricts the maximum
    305     runup calculation
    306     to a points that lie within the specified polygon and time interval.
    307 
    308     If no inundation is found within polygon and time_interval the return value
    309     is None signifying "No Runup" or "Everything is dry".
    310 
    311279    See general function get_maximum_inundation_data for details.
    312280    """
     
    319287
    320288
    321 ##
    322 # @brief Compute maximum run up height from SWW file.
    323 # @param filename Path to SWW file to read.
    324 # @param polygon If specified resrict to points inside this polygon.
    325 # @param time_interval If specified resrict to within the time specified.
    326 # @param use_centroid_values
    327 # @param verbose True if this function is to be verbose.
    328 # @return (maximal_runup, maximal_runup_location)
    329289def get_maximum_inundation_data(filename, polygon=None, time_interval=None,
    330290                                use_centroid_values=False,
    331291                                verbose=False):
    332292    """Compute maximum run up height from sww file.
     293
     294    filename             path to SWW file to read
     295    polygon              if specified resrict to points inside this polygon
     296                         assumed absolute coordinates and in same zone as
     297                         domain
     298    time_interval        if specified resrict to within the period specified
     299    use_centroid_values
     300    verbose              True if this function is to be verbose
     301
     302    Returns (maximal_runup, maximal_runup_location).
    333303
    334304    Usage:
     
    339309
    340310    Algorithm is as in get_maximum_inundation_elevation from
    341     shallow_water_domain except that this function works with the sww file and
     311    shallow_water_domain except that this function works with the SWW file and
    342312    computes the maximal runup height over multiple timesteps.
    343 
    344     Optional arguments polygon and time_interval restricts the maximum runup
    345     calculation to a points that lie within the specified polygon and time
    346     interval.
    347 
    348     Polygon is assumed to be in (absolute) UTM coordinates in the same zone
    349     as domain.
    350313
    351314    If no inundation is found within polygon and time_interval the return value
  • trunk/anuga_core/source/anuga/shallow_water/test_shallow_water_domain.py

    r8047 r8124  
    232232            pass
    233233        else:
    234             raise Exception, 'Should have raised an exception'
     234            raise Exception('Should have raised an exception')
    235235
    236236    # Individual flux tests
     
    21312131        else:
    21322132            msg = 'Should have raised exception'
    2133             raise Exception, msg
     2133            raise Exception(msg)
    21342134
    21352135    def Xtest_inflow_outflow_conservation(self):
     
    49674967        else:
    49684968            msg = 'This should have caught NAN at boundary'
    4969             raise Exception, msg
     4969            raise Exception(msg)
    49704970
    49714971        #Cleanup
     
    55055505        except RuntimeError, e:
    55065506            msg = 'Test failed: %s' % str(e)
    5507             raise Exception, msg
     5507            raise Exception,(sg)
    55085508            # clean up in case raise fails
    55095509            os.remove(meshname)
     
    55715571        except AssertionError, e:
    55725572            msg = 'Test failed: %s' % str(e)
    5573             raise Exception, msg
     5573            raise Exception(msg)
    55745574            # Cleanup in case this failed
    55755575            os.remove(meshname)
     
    55825582        except AssertionError, e:
    55835583            msg = 'Test failed: %s' % str(e)
    5584             raise Exception, msg
     5584            raise Exception(msg)
    55855585            # Cleanup in case this failed
    55865586            os.remove(meshname)
  • trunk/anuga_core/source/anuga/shallow_water_balanced/swb_domain.py

    r8072 r8124  
    203203                #Q.extrapolate_second_order_and_limit_by_vertex()
    204204            else:
    205                 raise 'Unknown order'
     205                raise Exception('Unknown order: %s' % str(self._order_))
    206206
    207207
     
    330330                #Q.extrapolate_second_order_and_limit_by_vertex()
    331331            else:
    332                 raise 'Unknown order'
     332                raise Exception('Unknown order: %s' % str(self._order_))
    333333
    334334
  • trunk/anuga_core/source/anuga/shallow_water_balanced/test_swb_basic.py

    r7869 r8124  
    152152            pass
    153153        else:
    154             raise Exception, 'Should have raised an exception'
     154            raise Exception('Should have raised an exception')
    155155
    156156    # Individual flux tests
     
    677677        else:
    678678            msg = 'should have caught wrong time interval'
    679             raise Exception, msg
     679            raise Exception(msg)
    680680
    681681        # Check correct time interval
     
    768768        else:
    769769            msg = 'Time interval should have raised an exception'
    770             raise Exception, msg
     770            raise Exception(msg)
    771771
    772772        # Cleanup
     
    19791979        except RuntimeError, e:
    19801980            msg = 'Test failed: %s' % str(e)
    1981             raise Exception, msg
     1981            raise Exception(msg)
    19821982            # clean up in case raise fails
    19831983            os.remove(meshname)
     
    20332033        except AssertionError, e:
    20342034            msg = 'Test failed: %s' % str(e)
    2035             raise Exception, msg
     2035            raise Exception(msg)
    20362036            # Cleanup in case this failed
    20372037            os.remove(meshname)
     
    20442044        except AssertionError, e:
    20452045            msg = 'Test failed: %s' % str(e)
    2046             raise Exception, msg
     2046            raise Exception(msg)
    20472047            # Cleanup in case this failed
    20482048            os.remove(meshname)
  • trunk/anuga_core/source/anuga/utilities/compile.py

    r7940 r8124  
    175175      msg += 'One way to check this is to run %s on ' %compiler
    176176      msg += 'the commandline.'
    177       raise Exception, msg   
     177      raise Exception(msg)
    178178
    179179 
     
    192192    open(headerfile, 'r')
    193193  except:
    194     raise """Did not find Python header file %s.
     194    raise Exception("""Did not find Python header file %s.
    195195    Make sure files for Python C-extensions are installed.
    196196    In debian linux, for example, you need to install a
    197     package called something like python2.3-dev""" %headerfile
     197    package called something like python2.3-dev""" %headerfile)
    198198
    199199
     
    243243      FN = FN + '.c'
    244244    elif ext.lower() != '.c':
    245       raise Exception, "Unrecognised extension: " + FN
     245      raise Exception("Unrecognised extension: " + FN)
    246246   
    247247    try:
    248248      open(FN, 'r')
    249249    except:
    250       raise Exception, "Could not open: " + FN
     250      raise Exception("Could not open: " + FN)
    251251
    252252    if not object_files: root1 = root  #Remember first filename       
     
    293293      err = os.system(s)
    294294      if err != 0:
    295           raise 'Attempting to compile %s failed - please try manually' %FN
     295          raise Exception('Attempting to compile %s failed - please try manually' %FN)
    296296    except:
    297       raise 'Could not compile %s - please try manually' %FN 
     297      raise Exception('Could not compile %s - please try manually' %FN)
    298298
    299299 
     
    314314    err=os.system(s)
    315315    if err != 0:       
    316         raise 'Attempting to link %s failed - please try manually' %root1     
     316        raise Exception('Attempting to link %s failed - please try manually'
     317                        % root1)
    317318  except:
    318     raise 'Could not link %s - please try manually' %root1
     319    raise Exception('Could not link %s - please try manually' % root1)
    319320   
    320321
     
    352353                    msg = 'C extension %s seems to compile OK, '
    353354                    msg += 'but it can still not be imported.'
    354                     raise msg
     355                    raise Exception(msg)
    355356                else:
    356357                    C=True
     
    441442              msg = 'Could not compile C extension %s\n' %filename
    442443              msg += str(e)
    443               raise Exception, msg
     444              raise Exception(msg)
    444445          else:
    445446              print 'C extension %s OK' %filename
  • trunk/anuga_core/source/anuga/utilities/sparse.py

    r7887 r8124  
    2222                A = num.array(args[0])
    2323            except:
    24                 raise 'Input must be convertable to a numeric array'
     24                raise Exception('Input must be convertable to a numeric array')
    2525
    2626            assert len(A.shape) == 2, 'Input must be a 2d matrix'
     
    3737            self.N = args[1]
    3838        else:
    39             raise 'Invalid construction'
     39            raise Exception('Invalid construction')
    4040           
    4141        self.shape = (self.M, self.N)
     
    112112        except:
    113113            msg = 'FIXME: Only numeric types implemented so far'
    114             raise msg
     114            raise Exception(msg)
    115115           
    116116
     
    150150           
    151151        else:
    152             raise ValueError, 'Dimension too high: d=%d' %len(B.shape)
     152            raise ValueError('Dimension too high: d=%d' %len(B.shape))
    153153
    154154        return R
     
    176176        except:
    177177            msg = 'Sparse matrix can only "right-multiply" onto a scalar'
    178             raise TypeError, msg
     178            raise TypeError(msg)
    179179        else:
    180180            new = self.copy()
     
    214214
    215215        else:
    216             raise 'Can only multiply with 1d array'
     216            raise Exception('Can only multiply with 1d array')
    217217
    218218        return R
     
    271271            self.N       = A.N
    272272        else:
    273             raise ValueError, "Sparse_CSR(A) expects A == Sparse Matrix"
     273            raise ValueError("Sparse_CSR(A) expects A == Sparse Matrix")
    274274           
    275275    def __repr__(self):
  • trunk/anuga_core/source/anuga/utilities/test_file_utils.py

    r7847 r8124  
    6262            pass
    6363        else:
    64             raise 'Should have raised exception'
     64            raise Exception('Should have raised exception')
    6565       
    6666    def test_get_all_swwfiles1(self):
  • trunk/anuga_core/source/anuga/utilities/test_numerical_tools.py

    r7276 r8124  
    273273                compile(FN)
    274274            except:
    275                 raise 'Could not compile %s' %FN
     275                raise Exception('Could not compile %s' % FN)
    276276            else:
    277277                import util_ext
  • trunk/anuga_core/source/anuga/utilities/test_sparse.py

    r7276 r8124  
    148148            pass
    149149        else:
    150             raise 'Should have failed'
     150            raise Exception('Should have failed')
    151151
    152152    def test_sparse_addition(self):
Note: See TracChangeset for help on using the changeset viewer.