Skip to content

Commit

Permalink
removed a few remaining python 2.7 functions
Browse files Browse the repository at this point in the history
  • Loading branch information
stoiveroberts committed Nov 8, 2022
1 parent 01c00d8 commit ebb286f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
15 changes: 8 additions & 7 deletions anuga/damage_modelling/exposure.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from past.builtins import cmp

from builtins import zip
from builtins import range
from builtins import object
Expand All @@ -17,7 +17,8 @@
X_TITLE = 'x'
Y_TITLE = 'y'


def cmp_0(a, b):
return (a > b) - (a < b)

class Exposure(object):
"""Class for National Exposure Database storage (NEXIS).
Expand Down Expand Up @@ -110,17 +111,17 @@ def __cmp__(self, other):

#check that 'other' is an instance of this class
if isinstance(self, type(other)):
result = cmp(self._attribute_dic, other._attribute_dic)
result = cmp_0(self._attribute_dic, other._attribute_dic)
if result != 0:
return result

# The order of the columns is important. Therefore..
result = cmp(self._title_index_dic, other._title_index_dic)
result = cmp_0(self._title_index_dic, other._title_index_dic)
if result != 0:
return result
for self_ls, other_ls in zip(self._attribute_dic,
other._attribute_dic):
result = cmp(self._attribute_dic[self_ls],
result = cmp_0(self._attribute_dic[self_ls],
other._attribute_dic[other_ls])
if result != 0:
return result
Expand Down Expand Up @@ -161,12 +162,12 @@ def __eq__(self, other):
# return result

# The order of the columns is important. Therefore..
#result = cmp(self._title_index_dic, other._title_index_dic)
#result = cmp_0(self._title_index_dic, other._title_index_dic)
#if result != 0:
# return result
#for self_ls, other_ls in zip(self._attribute_dic,
# other._attribute_dic):
# result = cmp(self._attribute_dic[self_ls],
# result = cmp_0(self._attribute_dic[self_ls],
# other._attribute_dic[other_ls])
# if result != 0:
# return result
Expand Down
4 changes: 2 additions & 2 deletions anuga/utilities/model_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
from anuga.utilities.model_tools import get_BUILDING_polygon_value_list
"""

from past.builtins import execfile

import os
import glob
import numpy
Expand Down Expand Up @@ -434,7 +434,7 @@ def Create_culvert_bridge_Operator(domain,culvert_bridge_file):
globals={}
locals={}

execfile(culvert_bridge_file, globals, locals)
exec(open(culvert_bridge_file).read(), globals, locals)
#print locals
#if 'height' and 'z1' and 'z2' in locals:
if 'z1' and 'z2' in locals:
Expand Down
5 changes: 2 additions & 3 deletions run_validations.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
from __future__ import print_function
from past.builtins import execfile

import os


os.chdir('validation_tests')
print()
print(20*'=' + ' anuga automated validation tests ' + 20*'=')
print('Changing to', os.getcwd()) # This is now different from buildroot
execfile('run_auto_validation_tests.py')
exec(open('run_auto_validation_tests.py').read())

0 comments on commit ebb286f

Please sign in to comment.