Changeset 8125


Ignore:
Timestamp:
Mar 4, 2011, 2:34:28 PM (14 years ago)
Author:
wilsonr
Message:

Changes to address ticket 360.

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

Legend:

Unmodified
Added
Removed
  • trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/file_function.py

    r8124 r8125  
    258258    # FIXME: Use geo_reference to read and write xllcorner...
    259259
    260     import time, calendar, types
     260    import time, calendar
    261261    from anuga.config import time_format
    262262
     
    266266    fid = NetCDFFile(filename, netcdf_mode_r)
    267267
    268     if type(quantity_names) == types.StringType:
     268    if isinstance(quantity_names, basestring):
    269269        quantity_names = [quantity_names]       
    270270
  • trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/generic_domain.py

    r8124 r8125  
    1313"""
    1414
    15 import types
    1615from time import time as walltime
    1716
     
    9089       
    9190        # Determine whether source is a mesh filename or coordinates
    92         if type(source) == types.StringType:
     91        if isinstance(source, basestring):
    9392            mesh_filename = source
    9493        else:
     
    861860    def _set_region(self, functions):
    862861        # coerce to an iterable (list or tuple)
    863         if type(functions) not in [types.ListType, types.TupleType]:
     862        if not isinstance(functions, (list, tuple)):
    864863            functions = [functions]
    865864
     
    11601159        if quantities is None:
    11611160            quantities = self.evolved_quantities
    1162         elif type(quantities) == types.StringType:
     1161        elif isinstance(quantities, basestring):
    11631162            quantities = [quantities] #Turn it into a list
    11641163
    11651164        msg = ('Keyword argument quantities must be either None, '
    11661165               'string or list. I got %s') % str(quantities)
    1167         assert type(quantities) == types.ListType, msg
     1166        assert isinstance(quantities, list), msg
    11681167
    11691168        if tags is None:
    11701169            tags = self.get_boundary_tags()
    1171         elif type(tags) == types.StringType:
     1170        elif isinstance(tags, basestring):
    11721171            tags = [tags] #Turn it into a list
    11731172
    11741173        msg = ('Keyword argument tags must be either None, '
    11751174               'string or list. I got %s') % str(tags)
    1176         assert type(tags) == types.ListType, msg
     1175        assert isinstance(tags, list), msg
    11771176
    11781177        # Determine width of longest quantity name (for cosmetic purposes)
  • trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/quantity.py

    r8124 r8125  
    1515"""
    1616
    17 from types import FloatType, IntType, LongType, NoneType
     17import types
    1818
    1919from anuga.utilities.numerical_tools import ensure_numeric, is_scalar
     
    432432            else:
    433433                # Check that numeric is as constant
    434                 assert type(numeric) in [FloatType, IntType, LongType], msg
     434                assert isinstance(numeric, (float, int, long)), msg
    435435
    436436            location = 'centroids'
     
    464464
    465465        msg = 'Indices must be a list, array or None'
    466         assert isinstance(indices, (NoneType, list, num.ndarray)), msg
     466        assert isinstance(indices, (types.NoneType, list, num.ndarray)), msg
    467467
    468468        # Determine which 'set_values_from_...' to use
     
    875875        """
    876876
    877         from types import StringType
    878 
    879877        msg = 'Filename must be a text string'
    880         assert type(filename) == StringType, msg
     878        assert isinstance(filename, basestring), msg
    881879
    882880        if location != 'vertices':
     
    11941192
    11951193        msg = '\'indices\' must be a list, array or None'
    1196         assert isinstance(indices, (NoneType, list, num.ndarray)), msg
     1194        assert isinstance(indices, (types.NoneType, list, num.ndarray)), msg
    11971195
    11981196        if location == 'centroids':
  • trunk/anuga_core/source/anuga/caching/caching.py

    r8124 r8125  
    269269  # Imports and input checks
    270270  #
    271   import types, time, string
     271  import time, string
    272272
    273273  if not cachedir:
     
    285285
    286286  # Handle the case cache('clear')
    287   if type(my_F) == types.StringType:
     287  if isinstance(my_F, basestring):
    288288    if string.lower(my_F) == 'clear':
    289289      clear_cache(CD,verbose=verbose)
     
    291291
    292292  # Handle the case cache(my_F, 'clear')
    293   if type(args) == types.StringType:
     293  if isinstance(args, basestring):
    294294    if string.lower(args) == 'clear':
    295295      clear_cache(CD,my_F,verbose=verbose)
     
    297297
    298298  # Force singleton arg into a tuple
    299   if type(args) != types.TupleType:
     299  if not isinstance(args, tuple):
    300300    args = tuple([args])
    301301 
    302302  # Check that kwargs is a dictionary
    303   if type(kwargs) != types.DictType:
     303  if not isinstance(kwargs, dict):
    304304    raise TypeError   
    305305   
     
    309309  # Get sizes and timestamps for files listed in dependencies.
    310310  # Force singletons into a tuple.
    311   if dependencies and type(dependencies) != types.TupleType \
    312                   and type(dependencies) != types.ListType:
     311  if dependencies and not isinstance(dependencies, (tuple, list)):
    313312    dependencies = tuple([dependencies])
    314313  deps = get_depstats(dependencies)
     
    833832  """
    834833
    835   import time, string, types
     834  import time, string
    836835
    837836  # Assess whether cached result exists - compressed or not.
     
    10431042  """
    10441043
    1045   import time, os, sys, types
     1044  import time, os, sys
    10461045
    10471046  (argsfile, compressed) = myopen(CD+FN+'_'+file_types[1], 'wb', compression)
     
    10771076  """
    10781077
    1079   import time, os, sys, types
     1078  import time, os, sys
    10801079
    10811080  (datafile, compressed1) = myopen(CD+FN+'_'+file_types[0],'wb',compression)
     
    14151414    """
    14161415
    1417     from types import TupleType, ListType, DictType, InstanceType
    1418    
    14191416    # Keep track of unique id's to protect against infinite recursion
    14201417    if ids is None: ids = {}
     
    14371434 
    14381435    # Compare recursively based on argument type
    1439     if type(A) in [TupleType, ListType]:
     1436    if isinstance(A, (tuple, list)):
    14401437        N = len(A)
    14411438        if len(B) != N:
     
    14471444                    identical = False; break
    14481445                   
    1449     elif type(A) == DictType:
     1446    elif isinstance(A, dict):
    14501447        if len(A) != len(B):
    14511448            identical = False
     
    14611458        identical = num.alltrue(A==B)
    14621459
    1463     elif type(A) == InstanceType:
     1460    elif type(A) == types.InstanceType:
    14641461        # Take care of special case where elements are instances           
    14651462        # Base comparison on attributes     
     
    15201517  """
    15211518
    1522   import types, string
     1519  import string
    15231520
    15241521  if type(my_F) == types.FunctionType:
     
    15491546    get_bytecode(my_F)
    15501547  """
    1551 
    1552   import types
    15531548
    15541549  if type(my_F) == types.FunctionType:
     
    16011596  """
    16021597
    1603   import types
    1604 
    16051598  d = {}
    16061599  if dependencies:
     
    16201613   
    16211614    for FN in expanded_dependencies:
    1622       if not type(FN) == types.StringType:
     1615      if not isinstance(FN, basestring):
    16231616        errmsg = 'ERROR (caching.py): Dependency must be a string.\n'
    16241617        errmsg += '                   Dependency given: %s' %FN
     
    20962089  """
    20972090
    2098   import types
    2099 
    21002091  sortlist  = []
    21012092  keylist = Dict.keys()
    21022093  for key in keylist:
    21032094    rec = Dict[key]
    2104     if not type(rec) in [types.ListType, types.TupleType]:
     2095    if not isinstance(rec, (list, tuple)):
    21052096      rec = [rec]
    21062097
     
    23902381  """
    23912382
    2392   import types
    2393 
    23942383  if level > 10:
    23952384      # Protect against circular structures
     
    23982387  WasTruncated = 0
    23992388
    2400   if not type(args) in [types.TupleType, types.ListType, types.DictType]:
    2401     if type(args) == types.StringType:
     2389  if not isinstance(args, (tuple, list, dict)):
     2390    if isinstance(args, basestring):
    24022391      argstr = argstr + "'"+str(args)+"'"
    24032392    else:
     
    24132402      argstr = argstr + str(args)
    24142403  else:
    2415     if type(args) == types.DictType:
     2404    if isinstance(args, dict):
    24162405      argstr = argstr + "{"
    24172406      for key in args.keys():
     
    24252414
    24262415    else:
    2427       if type(args) == types.TupleType:
     2416      if isinstance(args, tuple):
    24282417        lc = '('
    24292418        rc = ')'
     
    24402429      # Strip off trailing comma and space unless singleton tuple
    24412430      #
    2442       if type(args) == types.TupleType and len(args) == 1:
     2431      if isinstance(args, tuple) and len(args) == 1:
    24432432        argstr = argstr[:-1]   
    24442433      else:
  • trunk/anuga_core/source/anuga/coordinate_transforms/geo_reference.py

    r8124 r8125  
    77#and unit test
    88
    9 import types, sys
     9import sys
    1010import copy
    1111
     
    227227            self.yllcorner = self.yllcorner[0]
    228228
    229         assert (type(self.xllcorner) == types.FloatType)
    230         assert (type(self.yllcorner) == types.FloatType)
    231         assert (type(self.zone) == types.IntType)
     229        assert isinstance(self.xllcorner, float)
     230        assert isinstance(self.yllcorner, float)
     231        assert isinstance(self.zone, int)
    232232
    233233################################################################################
  • trunk/anuga_core/source/anuga/coordinate_transforms/test_geo_reference.py

    r8124 r8125  
    122122        new_lofl = g.change_points_geo_ref(lofl)
    123123
    124         self.failUnless(type(new_lofl) == types.ListType, ' failed')
     124        self.failUnless(isinstance(new_lofl, list), ' failed')
    125125        self.failUnless(type(new_lofl) == type(lofl), ' failed')
    126126        for point,new_point in map(None,lofl,new_lofl):
     
    136136        new_lofl = g.change_points_geo_ref(lofl)
    137137
    138         self.failUnless(type(new_lofl) == types.ListType, ' failed')
     138        self.failUnless(isinstance(new_lofl, list), ' failed')
    139139        self.failUnless(type(new_lofl) == type(lofl), ' failed')
    140140        for point,new_point in map(None,lofl,new_lofl):
     
    149149        new_lofl = g.change_points_geo_ref(lofl)
    150150
    151         self.failUnless(type(new_lofl) == types.ListType, ' failed')
     151        self.failUnless(isinstance(new_lofl, list), ' failed')
    152152        self.failUnless(type(new_lofl) == type(lofl), ' failed')
    153153        for point,new_point in map(None,[lofl],new_lofl):
     
    208208        new_lofl = g.change_points_geo_ref(lofl,points_geo_ref=points_geo_ref)
    209209
    210         self.failUnless(type(new_lofl) == types.ListType, ' failed')
     210        self.failUnless(isinstance(new_lofl, list), ' failed')
    211211        self.failUnless(type(new_lofl) == type(lofl), ' failed')
    212212        for point,new_point in map(None,lofl,new_lofl):
  • trunk/anuga_core/source/anuga/damage_modelling/inundation_damage.py

    r7743 r8125  
    88from Scientific.Functions.Interpolation import InterpolatingFunction
    99from random import choice
    10 from types import StringType
    1110
    1211import numpy as num
     
    6867                                name to get the output file name
    6968    """
    70     if type(exposure_files_in) == StringType:
     69    if isinstance(exposure_files_in, basestring):
    7170        exposure_files_in = [exposure_files_in]
    7271
  • trunk/anuga_core/source/anuga/file/csv_file.py

    r7858 r8125  
    158158    """
    159159
    160     import types
    161 
    162160    # Check that kwargs is a dictionary
    163     if type(kwargs) != types.DictType:
     161    if not isinstance(kwargs, dict):
    164162        raise TypeError
    165163
  • trunk/anuga_core/source/anuga/file_conversion/urs2sts.py

    r7778 r8125  
    8383    import os
    8484    from Scientific.IO.NetCDF import NetCDFFile
    85     from types import ListType,StringType
    8685    from operator import __and__
    8786
    88     if not isinstance(basename_in, ListType):
     87    if not isinstance(basename_in, list):
    8988        if verbose: log.critical('Reading single source')
    9089        basename_in = [basename_in]
     
    9695
    9796    # Check that basename is a list of strings
    98     if not reduce(__and__, map(lambda z:isinstance(z,StringType), basename_in)):
     97    if not reduce(__and__, map(lambda z:isinstance(z,basestring), basename_in)):
    9998        msg= 'basename_in must be a string or list of strings'
    10099        raise Exception, msg
  • trunk/anuga_core/source/anuga/fit_interpolate/fit.py

    r7804 r8125  
    2626      save time/memory.
    2727"""
    28 import types
    2928
    3029from anuga.abstract_2d_finite_volumes.neighbour_mesh import Mesh
     
    324323       
    325324        # Use blocking to load in the point info
    326         if type(point_coordinates_or_filename) == types.StringType:
     325        if isinstance(point_coordinates_or_filename, basestring):
    327326            msg = "Don't set a point origin when reading from a file"
    328327            assert point_origin is None, msg
  • trunk/anuga_core/source/anuga/fit_interpolate/interpolate.py

    r8124 r8125  
    789789
    790790        from anuga.config import time_format
    791         import types
    792791
    793792        if verbose is True:
     
    803802
    804803        # Check if quantities is a single array only
    805         if type(quantities) != types.DictType:
     804        if not isinstance(quantities, dict):
    806805            quantities = ensure_numeric(quantities)
    807806            quantity_names = ['Attribute']
  • trunk/anuga_core/source/anuga/geometry/test_geometry.py

    r7866 r8125  
    88from aabb import AABB
    99from quad import Cell
    10 
    11 import types
    1210
    1311#-------------------------------------------------------------
     
    7775
    7876        result = cell.retrieve()
    79         assert type(result) in [types.ListType,types.TupleType], \
    80                             'should be a list'
     77        assert isinstance(result, (list, tuple)), 'should be a list'
    8178
    8279        self.assertEqual(len(result), 4)
     
    9087
    9188        result = cell.search([8.5, 1.5])
    92         assert type(result) in [types.ListType, types.TupleType], \
    93                             'should be a list'
     89        assert isinstance(result, (list, tuple)), 'should be a list'
    9490        assert(len(result) == 1)
    9591        data, _ = result[0]
  • trunk/anuga_core/source/anuga/pmesh/Pmw.py

    r8124 r8125  
    241241
    242242    # Allow an attribute name (String) or a function to determine the instance
    243     if type(toPart) != types.StringType:
     243    if not isinstance(toPart, basestring):
    244244
    245245        # check that it is something like a function
     
    279279    for method, func in dict.items():
    280280        d = {'method': method, 'func': func}
    281         if type(toPart) == types.StringType:
     281        if isinstance(toPart, basestring):
    282282            execString = \
    283283                __stringBody % {'method' : method, 'attribute' : toPart}
     
    582582        if widgetClass is None:
    583583            return None
    584         if len(widgetArgs) == 1 and type(widgetArgs[0]) == types.TupleType:
     584        if len(widgetArgs) == 1 and isinstance(widgetArgs[0], tuple):
    585585            # Arguments to the constructor can be specified as either
    586586            # multiple trailing arguments to createcomponent() or as a
     
    11211121                # winfo_parent() should return the parent widget, but the
    11221122                # the current version of Tkinter returns a string.
    1123                 if type(parent) == types.StringType:
     1123                if isinstance(parent, basestring):
    11241124                    parent = self._hull._nametowidget(parent)
    11251125                master = parent.winfo_toplevel()
     
    11331133
    11341134        parent = self.winfo_parent()
    1135         if type(parent) == types.StringType:
     1135        if isinstance(parent, basestring):
    11361136            parent = self._hull._nametowidget(parent)
    11371137
     
    12081208                # winfo_parent() should return the parent widget, but the
    12091209                # the current version of Tkinter returns a string.
    1210                 if type(parent) == types.StringType:
     1210                if isinstance(parent, basestring):
    12111211                    parent = self._hull._nametowidget(parent)
    12121212                master = parent.winfo_toplevel()
     
    15741574
    15751575        _callToTkReturned = 0
    1576         if len(args) == 1 and type(args[0]) == types.TupleType:
     1576        if len(args) == 1 and isinstance(args[0], tuple):
    15771577            argStr = str(args[0])
    15781578        else:
     
    18431843    msg = msg + '  Args: %s\n' % str(args)
    18441844
    1845     if type(args) == types.TupleType and len(args) > 0 and \
     1845    if isinstance(args, tuple) and len(args) > 0 and \
    18461846            hasattr(args[0], 'type'):
    18471847        eventArg = 1
     
    21382138    def _buttons(self):
    21392139        buttons = self['buttons']
    2140         if type(buttons) != types.TupleType and type(buttons) != types.ListType:
     2140        if not isinstance(buttons, (tuple, list)):
    21412141            raise ValueError('bad buttons option "%s": should be a tuple'
    21422142                             % str(buttons))
     
    27742774    def index(self, index, forInsert = 0):
    27752775        listLength = len(self._buttonList)
    2776         if type(index) == types.IntType:
     2776        if isinstance(index, int):
    27772777            if forInsert and index <= listLength:
    27782778                return index
     
    30013001
    30023002                sequences = root.bind_class(tag)
    3003                 if type(sequences) is types.StringType:
     3003                if isinstance(sequences, basestring):
    30043004                    # In old versions of Tkinter, bind_class returns a string
    30053005                    sequences = root.tk.splitlist(sequences)
     
    30533053        }
    30543054        opt = self['validate']
    3055         if type(opt) is types.DictionaryType:
     3055        if isinstance(opt, dict):
    30563056            dict.update(opt)
    30573057        else:
     
    30893089        self._previousText = None
    30903090
    3091         if type(dict['min']) == types.StringType and strFunction is not None:
     3091        if isinstance(dict['min'], basestring) and strFunction is not None:
    30923092            dict['min'] = apply(strFunction, (dict['min'],), args)
    3093         if type(dict['max']) == types.StringType and strFunction is not None:
     3093        if isinstance(dict['max'], basestring) and strFunction is not None:
    30943094            dict['max'] = apply(strFunction, (dict['max'],), args)
    30953095
     
    37053705            return
    37063706
    3707         if type(traverseSpec) == types.IntType:
     3707        if isinstance(traverseSpec, int):
    37083708            kw['underline'] = traverseSpec
    37093709            return
     
    37293729        name = kw['label']
    37303730
    3731         if type(traverseSpec) == types.StringType:
     3731        if isinstance(traverseSpec, basestring):
    37323732            lowerLetter = string.lower(traverseSpec)
    37333733            if traverseSpec in name and lowerLetter not in hotkeyList:
     
    39483948            return
    39493949
    3950         if type(traverseSpec) == types.IntType:
     3950        if isinstance(traverseSpec, int):
    39513951            kw['underline'] = traverseSpec
    39523952            return
     
    39813981        name = kw[textKey]
    39823982
    3983         if type(traverseSpec) == types.StringType:
     3983        if isinstance(traverseSpec, basestring):
    39843984            lowerLetter = string.lower(traverseSpec)
    39853985            if traverseSpec in name and lowerLetter not in hotkeyList:
     
    45034503    def index(self, index, forInsert = 0):
    45044504        listLength = len(self._pageNames)
    4505         if type(index) == types.IntType:
     4505        if isinstance(index, int):
    45064506            if forInsert and index <= listLength:
    45074507                return index
     
    49684968    def index(self, index):
    49694969        listLength = len(self._itemList)
    4970         if type(index) == types.IntType:
     4970        if isinstance(index, int):
    49714971            if index < listLength:
    49724972                return index
     
    52185218        # Parse <args> for options.
    52195219        for arg, value in args.items():
    5220             if type(value) == types.FloatType:
     5220            if isinstance(value, float):
    52215221                relvalue = value
    52225222                value = self._absSize(relvalue)
     
    58065806
    58075807        listLength = len(self._buttonList)
    5808         if type(index) == types.IntType:
     5808        if isinstance(index, int):
    58095809            if index < listLength:
    58105810                return index
     
    64166416    def xview(self, mode = None, value = None, units = None):
    64176417
    6418         if type(value) == types.StringType:
     6418        if isinstance(value, basestring):
    64196419            value = string.atof(value)
    64206420        if mode is None:
     
    64386438    def yview(self, mode = None, value = None, units = None):
    64396439
    6440         if type(value) == types.StringType:
     6440        if isinstance(value, basestring):
    64416441            value = string.atof(value)
    64426442        if mode is None:
     
    67326732        # Add the items specified by the initialisation option.
    67336733        items = self['items']
    6734         if type(items) != types.TupleType:
     6734        if not isinstance(items, tuple):
    67356735            items = tuple(items)
    67366736        if len(items) > 0:
     
    68066806        self._listbox.selection_clear(0, 'end')
    68076807        listitems = list(self._listbox.get(0, 'end'))
    6808         if type(textOrList) == types.StringType:
     6808        if isinstance(textOrList, basestring):
    68096809            if textOrList in listitems:
    68106810                self._listbox.selection_set(listitems.index(textOrList))
     
    68216821        self._listbox.delete(0, 'end')
    68226822        if len(items) > 0:
    6823             if type(items) != types.TupleType:
     6823            if not isinstance(items, tuple):
    68246824                items = tuple(items)
    68256825            apply(self._listbox.insert, (0,) + items)
     
    83498349
    83508350    def selectitem(self, index, setentry=1):
    8351         if type(index) == types.StringType:
     8351        if isinstance(index, basestring):
    83528352            text = index
    83538353            items = self._list.get(0, 'end')
     
    88238823        datatype = self['datatype']
    88248824
    8825         if type(datatype) is types.DictionaryType:
     8825        if isinstance(datatype, dict):
    88268826            self._counterArgs = datatype.copy()
    88278827            if self._counterArgs.has_key('counter'):
  • trunk/anuga_core/source/anuga/pmesh/PmwBlt.py

    r3491 r8125  
    3232
    3333import string
    34 import types
    3534import Tkinter
    3635
     
    227226                self._name, 'search', start, end))
    228227    def set(self, list):
    229         if type(list) != types.TupleType:
     228        if not isinstance(list, tuple):
    230229            list = tuple(list)
    231230        self.tk.call(self._name, 'set', list)
     
    315314    def axis_configure(self, axes, option=None, **kw):
    316315        # <axes> may be a list of axisNames.
    317         if type(axes) == types.StringType:
     316        if isinstance(axes, basestring):
    318317            axes = [axes]
    319318        subcommand = (self._w, 'axis', 'configure') + tuple(axes)
     
    443442    def element_configure(self, names, option=None, **kw):
    444443        # <names> may be a list of elemNames.
    445         if type(names) == types.StringType:
     444        if isinstance(names, basestring):
    446445            names = [names]
    447446        subcommand = (self._w, 'element', 'configure') + tuple(names)
     
    505504    def pen_configure(self, names, option=None, **kw):
    506505        # <names> may be a list of penNames.
    507         if type(names) == types.StringType:
     506        if isinstance(names, basestring):
    508507            names = [names]
    509508        subcommand = (self._w, 'pen', 'configure') + tuple(names)
     
    544543    def marker_configure(self, names, option=None, **kw):
    545544        # <names> may be a list of markerIds.
    546         if type(names) == types.StringType:
     545        if isinstance(names, basestring):
    547546            names = [names]
    548547        subcommand = (self._w, 'marker', 'configure') + tuple(names)
     
    649648    def tab_configure(self, tabIndexes, option=None, **kw):
    650649        # <tabIndexes> may be a list of tabs.
    651         if type(tabIndexes) in (types.StringType, types.IntType):
     650        if isinstance(tabIndexes, (basestring, int)):
    652651            tabIndexes = [tabIndexes]
    653652        subcommand = (self._w, 'tab', 'configure') + tuple(tabIndexes)
  • trunk/anuga_core/source/anuga/pmesh/test_meshquad.py

    r7861 r8125  
    77from anuga.abstract_2d_finite_volumes.general_mesh import General_mesh as Mesh
    88
    9 import types, sys
     9import sys
    1010
    1111#-------------------------------------------------------------
     
    4444        # test a point that falls within a triangle
    4545        result = Q.search([10, 10])
    46         assert type(result) in [types.ListType,types.TupleType],\
    47                             'should be a list'
     46        assert isinstance(result, (list, tuple)), 'should be a list'
    4847                           
    4948        self.assertEqual(result[0][0][0], 1)
  • trunk/anuga_core/source/anuga/shallow_water/forcing.py

    r8124 r8125  
    1616from anuga.geometry.polygon import is_inside_polygon, inside_polygon, \
    1717                                    polygon_area
    18 from types import IntType, FloatType
    1918from anuga.geospatial_data.geospatial_data import ensure_geospatial
    2019
     
    408407               'or a function of time.\nI got %s.' % str(default_rate))
    409408        assert (default_rate is None or
    410                 type(default_rate) in [IntType, FloatType] or
     409                isinstance(default_rate, (int, float)) or
    411410                callable(default_rate)), msg
    412411
  • trunk/anuga_core/source/anuga/shallow_water/shallow_water_domain.py

    r8124 r8125  
    8787import anuga.utilities.log as log
    8888
    89 import types
    9089
    9190class Domain(Generic_Domain):
     
    390389            assert quantity_name in self.quantities, msg
    391390
    392         assert type(q) == types.DictType   
     391        assert isinstance(q, dict)
    393392        self.quantities_to_be_stored = q
    394393
  • trunk/anuga_core/source/anuga/structures/boyd_box_operator.py

    r8095 r8125  
    11import anuga
    22import math
    3 import types
    43
    54class Boyd_box_operator(anuga.Structure_operator):
     
    5049                                          verbose)     
    5150       
    52         if type(losses) == types.DictType:
     51        if isinstance(losses, dict):
    5352            self.sum_loss = sum(losses.values())
    54         elif type(losses) == types.ListType:
     53        elif isinstance(losses, list):
    5554            self.sum_loss = sum(losses)
    5655        else:
  • trunk/anuga_core/source/anuga/structures/boyd_box_operator_Amended3.py

    r8034 r8125  
    11import anuga
    22import math
    3 import types
    43
    54class Boyd_box_operator(anuga.Structure_operator):
     
    5049       
    5150       
    52         if type(losses) == types.DictType:
     51        if isinstance(losses, dict):
    5352            self.sum_loss = sum(losses.values())
    54         elif type(losses) == types.ListType:
     53        elif isinstance(losses, list):
    5554            self.sum_loss = sum(losses)
    5655        else:
  • trunk/anuga_core/source/anuga/structures/boyd_pipe_operator.py

    r8097 r8125  
    11import anuga
    22import math
    3 import types
    43
    54class Boyd_pipe_operator(anuga.Structure_operator):
     
    4948
    5049 
    51         if type(losses) == types.DictType:
     50        if isinstance(losses, dict):
    5251            self.sum_loss = sum(losses.values())
    53         elif type(losses) == types.ListType:
     52        elif isinstance(losses, list):
    5453            self.sum_loss = sum(losses)
    5554        else:
  • trunk/anuga_core/source/anuga/utilities/compile.py

    r8124 r8125  
    2020# it has only really been used with gcc.
    2121
    22 import os, string, sys, types
     22import os, string, sys
    2323
    2424separation_line = '---------------------------------------'     
     
    4040  assert not FNs is None, 'No filename provided'
    4141
    42   if not type(FNs) == types.ListType:
     42  if not isinstance(FNs, list):
    4343    FNs = [FNs]
    4444
  • trunk/anuga_core/source/anuga/utilities/numerical_tools.py

    r8073 r8125  
    5858    """
    5959
    60     from types import IntType, FloatType
    61     if type(x) in [IntType, FloatType]:
    62         return True
    63     else:
    64         return False
     60    return isinstance(x, (int, float))
    6561
    6662def angle(v1, v2=None):
Note: See TracChangeset for help on using the changeset viewer.