Changeset 8125
- Timestamp:
- Mar 4, 2011, 2:34:28 PM (14 years ago)
- 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 258 258 # FIXME: Use geo_reference to read and write xllcorner... 259 259 260 import time, calendar , types260 import time, calendar 261 261 from anuga.config import time_format 262 262 … … 266 266 fid = NetCDFFile(filename, netcdf_mode_r) 267 267 268 if type(quantity_names) == types.StringType:268 if isinstance(quantity_names, basestring): 269 269 quantity_names = [quantity_names] 270 270 -
trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/generic_domain.py
r8124 r8125 13 13 """ 14 14 15 import types16 15 from time import time as walltime 17 16 … … 90 89 91 90 # Determine whether source is a mesh filename or coordinates 92 if type(source) == types.StringType:91 if isinstance(source, basestring): 93 92 mesh_filename = source 94 93 else: … … 861 860 def _set_region(self, functions): 862 861 # coerce to an iterable (list or tuple) 863 if type(functions) not in [types.ListType, types.TupleType]:862 if not isinstance(functions, (list, tuple)): 864 863 functions = [functions] 865 864 … … 1160 1159 if quantities is None: 1161 1160 quantities = self.evolved_quantities 1162 elif type(quantities) == types.StringType:1161 elif isinstance(quantities, basestring): 1163 1162 quantities = [quantities] #Turn it into a list 1164 1163 1165 1164 msg = ('Keyword argument quantities must be either None, ' 1166 1165 'string or list. I got %s') % str(quantities) 1167 assert type(quantities) == types.ListType, msg1166 assert isinstance(quantities, list), msg 1168 1167 1169 1168 if tags is None: 1170 1169 tags = self.get_boundary_tags() 1171 elif type(tags) == types.StringType:1170 elif isinstance(tags, basestring): 1172 1171 tags = [tags] #Turn it into a list 1173 1172 1174 1173 msg = ('Keyword argument tags must be either None, ' 1175 1174 'string or list. I got %s') % str(tags) 1176 assert type(tags) == types.ListType, msg1175 assert isinstance(tags, list), msg 1177 1176 1178 1177 # Determine width of longest quantity name (for cosmetic purposes) -
trunk/anuga_core/source/anuga/abstract_2d_finite_volumes/quantity.py
r8124 r8125 15 15 """ 16 16 17 from types import FloatType, IntType, LongType, NoneType 17 import types 18 18 19 19 from anuga.utilities.numerical_tools import ensure_numeric, is_scalar … … 432 432 else: 433 433 # Check that numeric is as constant 434 assert type(numeric) in [FloatType, IntType, LongType], msg434 assert isinstance(numeric, (float, int, long)), msg 435 435 436 436 location = 'centroids' … … 464 464 465 465 msg = 'Indices must be a list, array or None' 466 assert isinstance(indices, ( NoneType, list, num.ndarray)), msg466 assert isinstance(indices, (types.NoneType, list, num.ndarray)), msg 467 467 468 468 # Determine which 'set_values_from_...' to use … … 875 875 """ 876 876 877 from types import StringType878 879 877 msg = 'Filename must be a text string' 880 assert type(filename) == StringType, msg878 assert isinstance(filename, basestring), msg 881 879 882 880 if location != 'vertices': … … 1194 1192 1195 1193 msg = '\'indices\' must be a list, array or None' 1196 assert isinstance(indices, ( NoneType, list, num.ndarray)), msg1194 assert isinstance(indices, (types.NoneType, list, num.ndarray)), msg 1197 1195 1198 1196 if location == 'centroids': -
trunk/anuga_core/source/anuga/caching/caching.py
r8124 r8125 269 269 # Imports and input checks 270 270 # 271 import t ypes, time, string271 import time, string 272 272 273 273 if not cachedir: … … 285 285 286 286 # Handle the case cache('clear') 287 if type(my_F) == types.StringType:287 if isinstance(my_F, basestring): 288 288 if string.lower(my_F) == 'clear': 289 289 clear_cache(CD,verbose=verbose) … … 291 291 292 292 # Handle the case cache(my_F, 'clear') 293 if type(args) == types.StringType:293 if isinstance(args, basestring): 294 294 if string.lower(args) == 'clear': 295 295 clear_cache(CD,my_F,verbose=verbose) … … 297 297 298 298 # Force singleton arg into a tuple 299 if type(args) != types.TupleType:299 if not isinstance(args, tuple): 300 300 args = tuple([args]) 301 301 302 302 # Check that kwargs is a dictionary 303 if type(kwargs) != types.DictType:303 if not isinstance(kwargs, dict): 304 304 raise TypeError 305 305 … … 309 309 # Get sizes and timestamps for files listed in dependencies. 310 310 # 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)): 313 312 dependencies = tuple([dependencies]) 314 313 deps = get_depstats(dependencies) … … 833 832 """ 834 833 835 import time, string , types834 import time, string 836 835 837 836 # Assess whether cached result exists - compressed or not. … … 1043 1042 """ 1044 1043 1045 import time, os, sys , types1044 import time, os, sys 1046 1045 1047 1046 (argsfile, compressed) = myopen(CD+FN+'_'+file_types[1], 'wb', compression) … … 1077 1076 """ 1078 1077 1079 import time, os, sys , types1078 import time, os, sys 1080 1079 1081 1080 (datafile, compressed1) = myopen(CD+FN+'_'+file_types[0],'wb',compression) … … 1415 1414 """ 1416 1415 1417 from types import TupleType, ListType, DictType, InstanceType1418 1419 1416 # Keep track of unique id's to protect against infinite recursion 1420 1417 if ids is None: ids = {} … … 1437 1434 1438 1435 # Compare recursively based on argument type 1439 if type(A) in [TupleType, ListType]:1436 if isinstance(A, (tuple, list)): 1440 1437 N = len(A) 1441 1438 if len(B) != N: … … 1447 1444 identical = False; break 1448 1445 1449 elif type(A) == DictType:1446 elif isinstance(A, dict): 1450 1447 if len(A) != len(B): 1451 1448 identical = False … … 1461 1458 identical = num.alltrue(A==B) 1462 1459 1463 elif type(A) == InstanceType:1460 elif type(A) == types.InstanceType: 1464 1461 # Take care of special case where elements are instances 1465 1462 # Base comparison on attributes … … 1520 1517 """ 1521 1518 1522 import types,string1519 import string 1523 1520 1524 1521 if type(my_F) == types.FunctionType: … … 1549 1546 get_bytecode(my_F) 1550 1547 """ 1551 1552 import types1553 1548 1554 1549 if type(my_F) == types.FunctionType: … … 1601 1596 """ 1602 1597 1603 import types1604 1605 1598 d = {} 1606 1599 if dependencies: … … 1620 1613 1621 1614 for FN in expanded_dependencies: 1622 if not type(FN) == types.StringType:1615 if not isinstance(FN, basestring): 1623 1616 errmsg = 'ERROR (caching.py): Dependency must be a string.\n' 1624 1617 errmsg += ' Dependency given: %s' %FN … … 2096 2089 """ 2097 2090 2098 import types2099 2100 2091 sortlist = [] 2101 2092 keylist = Dict.keys() 2102 2093 for key in keylist: 2103 2094 rec = Dict[key] 2104 if not type(rec) in [types.ListType, types.TupleType]:2095 if not isinstance(rec, (list, tuple)): 2105 2096 rec = [rec] 2106 2097 … … 2390 2381 """ 2391 2382 2392 import types2393 2394 2383 if level > 10: 2395 2384 # Protect against circular structures … … 2398 2387 WasTruncated = 0 2399 2388 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): 2402 2391 argstr = argstr + "'"+str(args)+"'" 2403 2392 else: … … 2413 2402 argstr = argstr + str(args) 2414 2403 else: 2415 if type(args) == types.DictType:2404 if isinstance(args, dict): 2416 2405 argstr = argstr + "{" 2417 2406 for key in args.keys(): … … 2425 2414 2426 2415 else: 2427 if type(args) == types.TupleType:2416 if isinstance(args, tuple): 2428 2417 lc = '(' 2429 2418 rc = ')' … … 2440 2429 # Strip off trailing comma and space unless singleton tuple 2441 2430 # 2442 if type(args) == types.TupleTypeand len(args) == 1:2431 if isinstance(args, tuple) and len(args) == 1: 2443 2432 argstr = argstr[:-1] 2444 2433 else: -
trunk/anuga_core/source/anuga/coordinate_transforms/geo_reference.py
r8124 r8125 7 7 #and unit test 8 8 9 import types,sys9 import sys 10 10 import copy 11 11 … … 227 227 self.yllcorner = self.yllcorner[0] 228 228 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) 232 232 233 233 ################################################################################ -
trunk/anuga_core/source/anuga/coordinate_transforms/test_geo_reference.py
r8124 r8125 122 122 new_lofl = g.change_points_geo_ref(lofl) 123 123 124 self.failUnless( type(new_lofl) == types.ListType, ' failed')124 self.failUnless(isinstance(new_lofl, list), ' failed') 125 125 self.failUnless(type(new_lofl) == type(lofl), ' failed') 126 126 for point,new_point in map(None,lofl,new_lofl): … … 136 136 new_lofl = g.change_points_geo_ref(lofl) 137 137 138 self.failUnless( type(new_lofl) == types.ListType, ' failed')138 self.failUnless(isinstance(new_lofl, list), ' failed') 139 139 self.failUnless(type(new_lofl) == type(lofl), ' failed') 140 140 for point,new_point in map(None,lofl,new_lofl): … … 149 149 new_lofl = g.change_points_geo_ref(lofl) 150 150 151 self.failUnless( type(new_lofl) == types.ListType, ' failed')151 self.failUnless(isinstance(new_lofl, list), ' failed') 152 152 self.failUnless(type(new_lofl) == type(lofl), ' failed') 153 153 for point,new_point in map(None,[lofl],new_lofl): … … 208 208 new_lofl = g.change_points_geo_ref(lofl,points_geo_ref=points_geo_ref) 209 209 210 self.failUnless( type(new_lofl) == types.ListType, ' failed')210 self.failUnless(isinstance(new_lofl, list), ' failed') 211 211 self.failUnless(type(new_lofl) == type(lofl), ' failed') 212 212 for point,new_point in map(None,lofl,new_lofl): -
trunk/anuga_core/source/anuga/damage_modelling/inundation_damage.py
r7743 r8125 8 8 from Scientific.Functions.Interpolation import InterpolatingFunction 9 9 from random import choice 10 from types import StringType11 10 12 11 import numpy as num … … 68 67 name to get the output file name 69 68 """ 70 if type(exposure_files_in) == StringType:69 if isinstance(exposure_files_in, basestring): 71 70 exposure_files_in = [exposure_files_in] 72 71 -
trunk/anuga_core/source/anuga/file/csv_file.py
r7858 r8125 158 158 """ 159 159 160 import types161 162 160 # Check that kwargs is a dictionary 163 if type(kwargs) != types.DictType:161 if not isinstance(kwargs, dict): 164 162 raise TypeError 165 163 -
trunk/anuga_core/source/anuga/file_conversion/urs2sts.py
r7778 r8125 83 83 import os 84 84 from Scientific.IO.NetCDF import NetCDFFile 85 from types import ListType,StringType86 85 from operator import __and__ 87 86 88 if not isinstance(basename_in, ListType):87 if not isinstance(basename_in, list): 89 88 if verbose: log.critical('Reading single source') 90 89 basename_in = [basename_in] … … 96 95 97 96 # 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)): 99 98 msg= 'basename_in must be a string or list of strings' 100 99 raise Exception, msg -
trunk/anuga_core/source/anuga/fit_interpolate/fit.py
r7804 r8125 26 26 save time/memory. 27 27 """ 28 import types29 28 30 29 from anuga.abstract_2d_finite_volumes.neighbour_mesh import Mesh … … 324 323 325 324 # 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): 327 326 msg = "Don't set a point origin when reading from a file" 328 327 assert point_origin is None, msg -
trunk/anuga_core/source/anuga/fit_interpolate/interpolate.py
r8124 r8125 789 789 790 790 from anuga.config import time_format 791 import types792 791 793 792 if verbose is True: … … 803 802 804 803 # Check if quantities is a single array only 805 if type(quantities) != types.DictType:804 if not isinstance(quantities, dict): 806 805 quantities = ensure_numeric(quantities) 807 806 quantity_names = ['Attribute'] -
trunk/anuga_core/source/anuga/geometry/test_geometry.py
r7866 r8125 8 8 from aabb import AABB 9 9 from quad import Cell 10 11 import types12 10 13 11 #------------------------------------------------------------- … … 77 75 78 76 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' 81 78 82 79 self.assertEqual(len(result), 4) … … 90 87 91 88 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' 94 90 assert(len(result) == 1) 95 91 data, _ = result[0] -
trunk/anuga_core/source/anuga/pmesh/Pmw.py
r8124 r8125 241 241 242 242 # Allow an attribute name (String) or a function to determine the instance 243 if type(toPart) != types.StringType:243 if not isinstance(toPart, basestring): 244 244 245 245 # check that it is something like a function … … 279 279 for method, func in dict.items(): 280 280 d = {'method': method, 'func': func} 281 if type(toPart) == types.StringType:281 if isinstance(toPart, basestring): 282 282 execString = \ 283 283 __stringBody % {'method' : method, 'attribute' : toPart} … … 582 582 if widgetClass is None: 583 583 return None 584 if len(widgetArgs) == 1 and type(widgetArgs[0]) == types.TupleType:584 if len(widgetArgs) == 1 and isinstance(widgetArgs[0], tuple): 585 585 # Arguments to the constructor can be specified as either 586 586 # multiple trailing arguments to createcomponent() or as a … … 1121 1121 # winfo_parent() should return the parent widget, but the 1122 1122 # the current version of Tkinter returns a string. 1123 if type(parent) == types.StringType:1123 if isinstance(parent, basestring): 1124 1124 parent = self._hull._nametowidget(parent) 1125 1125 master = parent.winfo_toplevel() … … 1133 1133 1134 1134 parent = self.winfo_parent() 1135 if type(parent) == types.StringType:1135 if isinstance(parent, basestring): 1136 1136 parent = self._hull._nametowidget(parent) 1137 1137 … … 1208 1208 # winfo_parent() should return the parent widget, but the 1209 1209 # the current version of Tkinter returns a string. 1210 if type(parent) == types.StringType:1210 if isinstance(parent, basestring): 1211 1211 parent = self._hull._nametowidget(parent) 1212 1212 master = parent.winfo_toplevel() … … 1574 1574 1575 1575 _callToTkReturned = 0 1576 if len(args) == 1 and type(args[0]) == types.TupleType:1576 if len(args) == 1 and isinstance(args[0], tuple): 1577 1577 argStr = str(args[0]) 1578 1578 else: … … 1843 1843 msg = msg + ' Args: %s\n' % str(args) 1844 1844 1845 if type(args) == types.TupleTypeand len(args) > 0 and \1845 if isinstance(args, tuple) and len(args) > 0 and \ 1846 1846 hasattr(args[0], 'type'): 1847 1847 eventArg = 1 … … 2138 2138 def _buttons(self): 2139 2139 buttons = self['buttons'] 2140 if type(buttons) != types.TupleType and type(buttons) != types.ListType:2140 if not isinstance(buttons, (tuple, list)): 2141 2141 raise ValueError('bad buttons option "%s": should be a tuple' 2142 2142 % str(buttons)) … … 2774 2774 def index(self, index, forInsert = 0): 2775 2775 listLength = len(self._buttonList) 2776 if type(index) == types.IntType:2776 if isinstance(index, int): 2777 2777 if forInsert and index <= listLength: 2778 2778 return index … … 3001 3001 3002 3002 sequences = root.bind_class(tag) 3003 if type(sequences) is types.StringType:3003 if isinstance(sequences, basestring): 3004 3004 # In old versions of Tkinter, bind_class returns a string 3005 3005 sequences = root.tk.splitlist(sequences) … … 3053 3053 } 3054 3054 opt = self['validate'] 3055 if type(opt) is types.DictionaryType:3055 if isinstance(opt, dict): 3056 3056 dict.update(opt) 3057 3057 else: … … 3089 3089 self._previousText = None 3090 3090 3091 if type(dict['min']) == types.StringTypeand strFunction is not None:3091 if isinstance(dict['min'], basestring) and strFunction is not None: 3092 3092 dict['min'] = apply(strFunction, (dict['min'],), args) 3093 if type(dict['max']) == types.StringTypeand strFunction is not None:3093 if isinstance(dict['max'], basestring) and strFunction is not None: 3094 3094 dict['max'] = apply(strFunction, (dict['max'],), args) 3095 3095 … … 3705 3705 return 3706 3706 3707 if type(traverseSpec) == types.IntType:3707 if isinstance(traverseSpec, int): 3708 3708 kw['underline'] = traverseSpec 3709 3709 return … … 3729 3729 name = kw['label'] 3730 3730 3731 if type(traverseSpec) == types.StringType:3731 if isinstance(traverseSpec, basestring): 3732 3732 lowerLetter = string.lower(traverseSpec) 3733 3733 if traverseSpec in name and lowerLetter not in hotkeyList: … … 3948 3948 return 3949 3949 3950 if type(traverseSpec) == types.IntType:3950 if isinstance(traverseSpec, int): 3951 3951 kw['underline'] = traverseSpec 3952 3952 return … … 3981 3981 name = kw[textKey] 3982 3982 3983 if type(traverseSpec) == types.StringType:3983 if isinstance(traverseSpec, basestring): 3984 3984 lowerLetter = string.lower(traverseSpec) 3985 3985 if traverseSpec in name and lowerLetter not in hotkeyList: … … 4503 4503 def index(self, index, forInsert = 0): 4504 4504 listLength = len(self._pageNames) 4505 if type(index) == types.IntType:4505 if isinstance(index, int): 4506 4506 if forInsert and index <= listLength: 4507 4507 return index … … 4968 4968 def index(self, index): 4969 4969 listLength = len(self._itemList) 4970 if type(index) == types.IntType:4970 if isinstance(index, int): 4971 4971 if index < listLength: 4972 4972 return index … … 5218 5218 # Parse <args> for options. 5219 5219 for arg, value in args.items(): 5220 if type(value) == types.FloatType:5220 if isinstance(value, float): 5221 5221 relvalue = value 5222 5222 value = self._absSize(relvalue) … … 5806 5806 5807 5807 listLength = len(self._buttonList) 5808 if type(index) == types.IntType:5808 if isinstance(index, int): 5809 5809 if index < listLength: 5810 5810 return index … … 6416 6416 def xview(self, mode = None, value = None, units = None): 6417 6417 6418 if type(value) == types.StringType:6418 if isinstance(value, basestring): 6419 6419 value = string.atof(value) 6420 6420 if mode is None: … … 6438 6438 def yview(self, mode = None, value = None, units = None): 6439 6439 6440 if type(value) == types.StringType:6440 if isinstance(value, basestring): 6441 6441 value = string.atof(value) 6442 6442 if mode is None: … … 6732 6732 # Add the items specified by the initialisation option. 6733 6733 items = self['items'] 6734 if type(items) != types.TupleType:6734 if not isinstance(items, tuple): 6735 6735 items = tuple(items) 6736 6736 if len(items) > 0: … … 6806 6806 self._listbox.selection_clear(0, 'end') 6807 6807 listitems = list(self._listbox.get(0, 'end')) 6808 if type(textOrList) == types.StringType:6808 if isinstance(textOrList, basestring): 6809 6809 if textOrList in listitems: 6810 6810 self._listbox.selection_set(listitems.index(textOrList)) … … 6821 6821 self._listbox.delete(0, 'end') 6822 6822 if len(items) > 0: 6823 if type(items) != types.TupleType:6823 if not isinstance(items, tuple): 6824 6824 items = tuple(items) 6825 6825 apply(self._listbox.insert, (0,) + items) … … 8349 8349 8350 8350 def selectitem(self, index, setentry=1): 8351 if type(index) == types.StringType:8351 if isinstance(index, basestring): 8352 8352 text = index 8353 8353 items = self._list.get(0, 'end') … … 8823 8823 datatype = self['datatype'] 8824 8824 8825 if type(datatype) is types.DictionaryType:8825 if isinstance(datatype, dict): 8826 8826 self._counterArgs = datatype.copy() 8827 8827 if self._counterArgs.has_key('counter'): -
trunk/anuga_core/source/anuga/pmesh/PmwBlt.py
r3491 r8125 32 32 33 33 import string 34 import types35 34 import Tkinter 36 35 … … 227 226 self._name, 'search', start, end)) 228 227 def set(self, list): 229 if type(list) != types.TupleType:228 if not isinstance(list, tuple): 230 229 list = tuple(list) 231 230 self.tk.call(self._name, 'set', list) … … 315 314 def axis_configure(self, axes, option=None, **kw): 316 315 # <axes> may be a list of axisNames. 317 if type(axes) == types.StringType:316 if isinstance(axes, basestring): 318 317 axes = [axes] 319 318 subcommand = (self._w, 'axis', 'configure') + tuple(axes) … … 443 442 def element_configure(self, names, option=None, **kw): 444 443 # <names> may be a list of elemNames. 445 if type(names) == types.StringType:444 if isinstance(names, basestring): 446 445 names = [names] 447 446 subcommand = (self._w, 'element', 'configure') + tuple(names) … … 505 504 def pen_configure(self, names, option=None, **kw): 506 505 # <names> may be a list of penNames. 507 if type(names) == types.StringType:506 if isinstance(names, basestring): 508 507 names = [names] 509 508 subcommand = (self._w, 'pen', 'configure') + tuple(names) … … 544 543 def marker_configure(self, names, option=None, **kw): 545 544 # <names> may be a list of markerIds. 546 if type(names) == types.StringType:545 if isinstance(names, basestring): 547 546 names = [names] 548 547 subcommand = (self._w, 'marker', 'configure') + tuple(names) … … 649 648 def tab_configure(self, tabIndexes, option=None, **kw): 650 649 # <tabIndexes> may be a list of tabs. 651 if type(tabIndexes) in (types.StringType, types.IntType):650 if isinstance(tabIndexes, (basestring, int)): 652 651 tabIndexes = [tabIndexes] 653 652 subcommand = (self._w, 'tab', 'configure') + tuple(tabIndexes) -
trunk/anuga_core/source/anuga/pmesh/test_meshquad.py
r7861 r8125 7 7 from anuga.abstract_2d_finite_volumes.general_mesh import General_mesh as Mesh 8 8 9 import types,sys9 import sys 10 10 11 11 #------------------------------------------------------------- … … 44 44 # test a point that falls within a triangle 45 45 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' 48 47 49 48 self.assertEqual(result[0][0][0], 1) -
trunk/anuga_core/source/anuga/shallow_water/forcing.py
r8124 r8125 16 16 from anuga.geometry.polygon import is_inside_polygon, inside_polygon, \ 17 17 polygon_area 18 from types import IntType, FloatType19 18 from anuga.geospatial_data.geospatial_data import ensure_geospatial 20 19 … … 408 407 'or a function of time.\nI got %s.' % str(default_rate)) 409 408 assert (default_rate is None or 410 type(default_rate) in [IntType, FloatType]or409 isinstance(default_rate, (int, float)) or 411 410 callable(default_rate)), msg 412 411 -
trunk/anuga_core/source/anuga/shallow_water/shallow_water_domain.py
r8124 r8125 87 87 import anuga.utilities.log as log 88 88 89 import types90 89 91 90 class Domain(Generic_Domain): … … 390 389 assert quantity_name in self.quantities, msg 391 390 392 assert type(q) == types.DictType391 assert isinstance(q, dict) 393 392 self.quantities_to_be_stored = q 394 393 -
trunk/anuga_core/source/anuga/structures/boyd_box_operator.py
r8095 r8125 1 1 import anuga 2 2 import math 3 import types4 3 5 4 class Boyd_box_operator(anuga.Structure_operator): … … 50 49 verbose) 51 50 52 if type(losses) == types.DictType:51 if isinstance(losses, dict): 53 52 self.sum_loss = sum(losses.values()) 54 elif type(losses) == types.ListType:53 elif isinstance(losses, list): 55 54 self.sum_loss = sum(losses) 56 55 else: -
trunk/anuga_core/source/anuga/structures/boyd_box_operator_Amended3.py
r8034 r8125 1 1 import anuga 2 2 import math 3 import types4 3 5 4 class Boyd_box_operator(anuga.Structure_operator): … … 50 49 51 50 52 if type(losses) == types.DictType:51 if isinstance(losses, dict): 53 52 self.sum_loss = sum(losses.values()) 54 elif type(losses) == types.ListType:53 elif isinstance(losses, list): 55 54 self.sum_loss = sum(losses) 56 55 else: -
trunk/anuga_core/source/anuga/structures/boyd_pipe_operator.py
r8097 r8125 1 1 import anuga 2 2 import math 3 import types4 3 5 4 class Boyd_pipe_operator(anuga.Structure_operator): … … 49 48 50 49 51 if type(losses) == types.DictType:50 if isinstance(losses, dict): 52 51 self.sum_loss = sum(losses.values()) 53 elif type(losses) == types.ListType:52 elif isinstance(losses, list): 54 53 self.sum_loss = sum(losses) 55 54 else: -
trunk/anuga_core/source/anuga/utilities/compile.py
r8124 r8125 20 20 # it has only really been used with gcc. 21 21 22 import os, string, sys , types22 import os, string, sys 23 23 24 24 separation_line = '---------------------------------------' … … 40 40 assert not FNs is None, 'No filename provided' 41 41 42 if not type(FNs) == types.ListType:42 if not isinstance(FNs, list): 43 43 FNs = [FNs] 44 44 -
trunk/anuga_core/source/anuga/utilities/numerical_tools.py
r8073 r8125 58 58 """ 59 59 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)) 65 61 66 62 def angle(v1, v2=None):
Note: See TracChangeset
for help on using the changeset viewer.