Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add format_int to all impact functions and the tests per #449

  • Loading branch information...
commit 61ae925eeb83a74a93a96ae8b57126192090964b 1 parent 97fb81a
Ismail Sunni ismailsunni authored
26 safe/engine/impact_functions_for_testing/BNPB_earthquake_guidelines.py
View
@@ -12,8 +12,10 @@
import numpy
-from safe.impact_functions.core import FunctionProvider
-from safe.impact_functions.core import get_hazard_layer, get_exposure_layer
+from safe.impact_functions.core import (FunctionProvider,
+ get_hazard_layer,
+ get_exposure_layer,
+ format_int)
from safe.storage.vector import Vector
from safe.common.utilities import ugettext as tr
from safe.impact_functions.mappings import osm2bnpb
@@ -122,17 +124,17 @@ def run(self, layers):
impact_summary = ('<table border="0" width="320px">'
' <tr><th><b>%s</b></th><th><b>%s</b></th></th>'
' <tr></tr>'
- ' <tr><td>%s&#58;</td><td>%i</td></tr>'
- ' <tr><td>%s (10-25%%)&#58;</td><td>%i</td></tr>'
- ' <tr><td>%s (25-50%%)&#58;</td><td>%i</td></tr>'
- ' <tr><td>%s (50-100%%)&#58;</td><td>%i</td></tr>'
+ ' <tr><td>%s&#58;</td><td>%s</td></tr>'
+ ' <tr><td>%s (10-25%%)&#58;</td><td>%s</td></tr>'
+ ' <tr><td>%s (25-50%%)&#58;</td><td>%s</td></tr>'
+ ' <tr><td>%s (50-100%%)&#58;</td><td>%s</td></tr>'
% (tr('Buildings'), tr('Total'),
- tr('All'), N,
- tr('Low damage'), count1,
- tr('Medium damage'), count2,
- tr('High damage'), count3))
- impact_summary += (' <tr><td>%s (NaN)&#58;</td><td>%i</td></tr>'
- % ('Unknown', count_unknown))
+ tr('All'), format_int(N),
+ tr('Low damage'), format_int(count1),
+ tr('Medium damage'), format_int(count2),
+ tr('High damage'), format_int(count3)))
+ impact_summary += (' <tr><td>%s (NaN)&#58;</td><td>%s</td></tr>'
+ % ('Unknown', format_int(count_unknown)))
impact_summary += '</table>'
# Create style
19 safe/engine/impact_functions_for_testing/HKV_flood_study.py
View
@@ -1,6 +1,8 @@
import numpy
-from safe.impact_functions.core import FunctionProvider
-from safe.impact_functions.core import get_hazard_layer, get_exposure_layers
+from safe.impact_functions.core import (FunctionProvider,
+ get_hazard_layer,
+ get_exposure_layers,
+ format_int)
from safe.storage.raster import Raster
from safe.common.utilities import verify
@@ -40,7 +42,6 @@ def run(layers):
# Depth above which people are regarded affected [m]
threshold = 0.1
-
# Identify hazard and exposure layers
inundation = get_hazard_layer(layers) # Flood inundation [m]
@@ -101,8 +102,8 @@ def run(layers):
I_male = I - I_female
# Generate text with result for this study
- total = str(int(sum(P.flat) / 1000))
- count = str(int(sum(I.flat) / 1000))
+ total = format_int(int(sum(P.flat) / 1000))
+ count = format_int(int(sum(I.flat) / 1000))
# Create report
impact_summary = ('<table border="0" width="320px">'
@@ -110,8 +111,8 @@ def run(layers):
'<td align="right"><b>%s</b></td></tr>'
% ('Jumlah Penduduk', total))
if gender_ratio is not None:
- total_female = str(int(sum(P_female.flat) / 1000))
- total_male = str(int(sum(P_male.flat) / 1000))
+ total_female = format_int(int(sum(P_female.flat) / 1000))
+ total_male = format_int(int(sum(P_male.flat) / 1000))
impact_summary += (' <tr><td>%s&#58;</td>'
'<td align="right">%s</td></tr>'
@@ -127,8 +128,8 @@ def run(layers):
count))
if gender_ratio is not None:
- affected_female = str(int(sum(I_female.flat) / 1000))
- affected_male = str(int(sum(I_male.flat) / 1000))
+ affected_female = format_int(int(sum(I_female.flat) / 1000))
+ affected_male = format_int(int(sum(I_male.flat) / 1000))
impact_summary += (' <tr><td>%s&#58;</td>'
'<td align="right">%s</td></tr>'
34 safe/engine/impact_functions_for_testing/allen_fatality_model.py
View
@@ -1,5 +1,7 @@
-from safe.impact_functions.core import FunctionProvider
-from safe.impact_functions.core import get_hazard_layer, get_exposure_layers
+from safe.impact_functions.core import (FunctionProvider,
+ get_hazard_layer,
+ get_exposure_layers,
+ format_int)
from safe.impact_functions.styles import earthquake_fatality_style
from safe.storage.raster import Raster
import numpy
@@ -89,21 +91,25 @@ def run(layers,
# Create report
impact_summary = ('<table border="0" width="320px">'
- ' <tr><td>%s&#58;</td><td>%i</td></tr>'
- % ('Jumlah Penduduk', int(total)))
+ ' <tr><td>%s&#58;</td><td>%s</td></tr>'
+ % ('Jumlah Penduduk', format_int(int(total))))
if gender_ratio is not None:
- impact_summary += (' <tr><td>%s&#58;</td><td>%i</td></tr>'
- % (' - Wanita', int(numpy.nansum(P_female.flat))))
- impact_summary += (' <tr><td>%s&#58;</td><td>%i</td></tr>'
- % (' - Pria', int(numpy.nansum(P_male.flat))))
- impact_summary += (' <tr><td>%s&#58;</td><td>%i</td></tr>'
- % ('Perkiraan Orang Meninggal', int(count)))
+ impact_summary += (' <tr><td>%s&#58;</td><td>%s</td></tr>'
+ % (' - Wanita',
+ format_int(int(numpy.nansum(P_female.flat)))))
+ impact_summary += (' <tr><td>%s&#58;</td><td>%s</td></tr>'
+ % (' - Pria',
+ format_int(int(numpy.nansum(P_male.flat)))))
+ impact_summary += (' <tr><td>%s&#58;</td><td>%s</td></tr>'
+ % ('Perkiraan Orang Meninggal', format_int(int(count))))
if gender_ratio is not None:
- impact_summary += (' <tr><td>%s&#58;</td><td>%i</td></tr>'
- % (' - Wanita', int(numpy.nansum(F_female.flat))))
- impact_summary += (' <tr><td>%s&#58;</td><td>%i</td></tr>'
- % (' - Pria', int(numpy.nansum(F_male.flat))))
+ impact_summary += (' <tr><td>%s&#58;</td><td>%s</td></tr>'
+ % (' - Wanita',
+ format_int(int(numpy.nansum(F_female.flat)))))
+ impact_summary += (' <tr><td>%s&#58;</td><td>%s</td></tr>'
+ % (' - Pria',
+ format_int(int(numpy.nansum(F_male.flat)))))
impact_summary += '</table>'
32 safe/impact_functions/earthquake/earthquake_building_impact.py
View
@@ -1,6 +1,8 @@
-from safe.impact_functions.core import FunctionProvider
-from safe.impact_functions.core import get_hazard_layer, get_exposure_layer
-from safe.impact_functions.core import get_question
+from safe.impact_functions.core import (FunctionProvider,
+ get_hazard_layer,
+ get_exposure_layer,
+ get_question,
+ format_int)
from safe.storage.vector import Vector
from safe.common.utilities import ugettext as tr
from safe.common.tables import Table, TableRow
@@ -145,24 +147,24 @@ def run(self, layers):
tr('Buildings value ($M)'),
tr('Contents value ($M)')],
header=True),
- TableRow([class_1, lo,
- building_values[1],
- contents_values[1]]),
- TableRow([class_2, me,
- building_values[2],
- contents_values[2]]),
- TableRow([class_3, hi,
- building_values[3],
- contents_values[3]])]
+ TableRow([class_1, format_int(lo),
+ format_int(building_values[1]),
+ format_int(contents_values[1])]),
+ TableRow([class_2, format_int(me),
+ format_int(building_values[2]),
+ format_int(contents_values[2])]),
+ TableRow([class_3, format_int(hi),
+ format_int(building_values[3]),
+ format_int(contents_values[3])])]
else:
# Generate simple impact report for unspecific buildings
table_body = [question,
TableRow([tr('Hazard Level'),
tr('Buildings Affected')],
header=True),
- TableRow([class_1, str(lo)]),
- TableRow([class_2, str(me)]),
- TableRow([class_3, str(hi)])]
+ TableRow([class_1, format_int(lo)]),
+ TableRow([class_2, format_int(me)]),
+ TableRow([class_3, format_int(hi)])]
table_body.append(TableRow(tr('Notes'), header=True))
table_body.append(tr('High hazard is defined as shake levels greater '
9 safe/impact_functions/earthquake/itb_earthquake_fatality_model.py
View
@@ -1,7 +1,8 @@
-from safe.impact_functions.core import FunctionProvider
-from safe.impact_functions.core import get_hazard_layer, get_exposure_layer
-from safe.impact_functions.core import get_question
-from safe.impact_functions.core import format_int
+from safe.impact_functions.core import (FunctionProvider,
+ get_hazard_layer,
+ get_exposure_layer,
+ get_question,
+ format_int)
from safe.storage.raster import Raster
from safe.common.utilities import (ugettext as tr,
get_defaults)
17 safe/impact_functions/earthquake/padang_building_impact_model.py
View
@@ -20,9 +20,11 @@
9 Timber frame residential 10.5 0.15
"""
-from safe.impact_functions.core import FunctionProvider
-from safe.impact_functions.core import get_hazard_layer, get_exposure_layer
-from safe.impact_functions.core import get_question
+from safe.impact_functions.core import (FunctionProvider,
+ get_hazard_layer,
+ get_exposure_layer,
+ get_question,
+ format_int)
from safe.storage.vector import Vector
from safe.common.utilities import ugettext as tr
from safe.common.numerics import lognormal_cdf
@@ -125,10 +127,11 @@ def run(self, layers):
TableRow([tr('Buildings'), tr('Total')],
header=True),
TableRow([tr('All'), N]),
- TableRow([tr('No damage'), str(count_none)]),
- TableRow([tr('Low damage'), str(count_low)]),
- TableRow([tr('Medium damage'), str(count_medium)]),
- TableRow([tr('High damage'), str(count_high)])]
+ TableRow([tr('No damage'), format_int(count_none)]),
+ TableRow([tr('Low damage'), format_int(count_low)]),
+ TableRow([tr('Medium damage'),
+ format_int(count_medium)]),
+ TableRow([tr('High damage'), format_int(count_high)])]
table_body.append(TableRow(tr('Notes'), header=True))
table_body.append(tr('Levels of impact are defined by post 2009 '
16 safe/impact_functions/generic/categorised_hazard_building_impact.py
View
@@ -1,6 +1,8 @@
-from safe.impact_functions.core import FunctionProvider
-from safe.impact_functions.core import get_hazard_layer, get_exposure_layer
-from safe.impact_functions.core import get_question
+from safe.impact_functions.core import (FunctionProvider,
+ get_hazard_layer,
+ get_exposure_layer,
+ get_question,
+ format_int)
from safe.storage.vector import Vector
from safe.common.utilities import ugettext as tr
from safe.common.tables import Table, TableRow
@@ -99,10 +101,10 @@ def run(self, layers):
table_body = [question,
TableRow([tr('Category'), tr('Affected')],
header=True),
- TableRow([tr('High'), count2]),
- TableRow([tr('Medium'), count1]),
- TableRow([tr('Low'), count0]),
- TableRow([tr('All'), N])]
+ TableRow([tr('High'), format_int(count2)]),
+ TableRow([tr('Medium'), format_int(count1)]),
+ TableRow([tr('Low'), format_int(count0)]),
+ TableRow([tr('All'), format_int(N)])]
table_body.append(TableRow(tr('Notes'), header=True))
table_body.append(tr('Categorised hazard has only 3'
17 safe/impact_functions/generic/categorised_hazard_population.py
View
@@ -1,7 +1,10 @@
import numpy
-from safe.impact_functions.core import FunctionProvider
-from safe.impact_functions.core import get_hazard_layer, get_exposure_layer
-from safe.impact_functions.core import get_question, get_function_title
+from safe.impact_functions.core import (FunctionProvider,
+ get_hazard_layer,
+ get_exposure_layer,
+ get_question,
+ get_function_title,
+ format_int)
from safe.impact_functions.styles import flood_population_style as style_info
from safe.storage.raster import Raster
from safe.common.utilities import ugettext as tr
@@ -94,16 +97,16 @@ def run(self, layers):
# Generate impact report for the pdf map
table_body = [question,
TableRow([tr('People impacted '),
- '%i' % total_impact],
+ '%s' % format_int(total_impact)],
header=True),
TableRow([tr('People in high hazard area '),
- '%i' % high],
+ '%s' % format_int(high)],
header=True),
TableRow([tr('People in medium hazard area '),
- '%i' % medium],
+ '%s' % format_int(medium)],
header=True),
TableRow([tr('People in low hazard area'),
- '%i' % low],
+ '%s' % format_int(low)],
header=True)]
## TableRow([tr('Needs per week'), tr('Total')],
16 safe/impact_functions/inundation/flood_OSM_building_impact.py
View
@@ -1,6 +1,8 @@
-from safe.impact_functions.core import FunctionProvider
-from safe.impact_functions.core import get_hazard_layer, get_exposure_layer
-from safe.impact_functions.core import get_question
+from safe.impact_functions.core import (FunctionProvider,
+ get_hazard_layer,
+ get_exposure_layer,
+ get_question,
+ format_int)
from safe.storage.vector import Vector
from safe.storage.utilities import DEFAULT_ATTRIBUTE
from safe.common.utilities import ugettext as tr
@@ -200,7 +202,7 @@ def run(self, layers):
tr('Number flooded'),
tr('Total')],
header=True),
- TableRow([tr('All'), count, N])]
+ TableRow([tr('All'), format_int(count), format_int(N)])]
## fid.write('%s, %s, %s\n' % (tr('Building type'),
## tr('Temporarily closed'),
@@ -233,7 +235,7 @@ def run(self, layers):
# FIXME (Sunni) : I change affected_buildings[usage] to string
# because it will be replace with &nbsp in html
building_list.append([building_type.capitalize(),
- str(affected_buildings[usage]),
+ format_int(affected_buildings[usage]),
buildings[usage]])
if building_type == 'school':
school_closed = affected_buildings[usage]
@@ -270,12 +272,12 @@ def run(self, layers):
if school_closed > 0:
table_body.append(TableRow(tr('Where will the students from the %d'
' closed schools go to study?') %
- school_closed))
+ format_int(school_closed)))
if hospital_closed > 0:
table_body.append(TableRow(tr('Where will the patients from the %d'
' closed hospitals go for treatment '
'and how will we transport them?') %
- hospital_closed))
+ format_int(hospital_closed)))
table_body.append(TableRow(tr('Notes'), header=True))
assumption = tr('Buildings are said to be flooded when ')
12 safe/impact_functions/inundation/flood_population_evacuation.py
View
@@ -1,8 +1,10 @@
import numpy
-from safe.impact_functions.core import FunctionProvider
-from safe.impact_functions.core import get_hazard_layer, get_exposure_layer
-from safe.impact_functions.core import get_question, get_function_title
-from safe.impact_functions.core import format_int
+from safe.impact_functions.core import (FunctionProvider,
+ get_hazard_layer,
+ get_exposure_layer,
+ get_question,
+ get_function_title,
+ format_int)
from safe.impact_functions.styles import flood_population_style as style_info
from safe.storage.raster import Raster
from safe.common.utilities import (ugettext as tr,
@@ -55,7 +57,7 @@ def run(self, layers):
Map of population exposed to flood levels exceeding the threshold
Table with number of people evacuated and supplies required
"""
-
+ print 'AAAAAAAAAAAAAAA'
# Identify hazard and exposure layers
inundation = get_hazard_layer(layers) # Flood inundation [m]
population = get_exposure_layer(layers)
25 safe/impact_functions/inundation/flood_population_evacuation_polygon_hazard.py
View
@@ -1,7 +1,9 @@
import numpy
-from safe.impact_functions.core import FunctionProvider
-from safe.impact_functions.core import get_hazard_layer, get_exposure_layer
-from safe.impact_functions.core import get_question
+from safe.impact_functions.core import (FunctionProvider,
+ get_hazard_layer,
+ get_exposure_layer,
+ get_question,
+ format_int)
from safe.storage.vector import Vector
from safe.common.utilities import ugettext as tr
from safe.common.tables import Table, TableRow
@@ -51,7 +53,7 @@ def run(self, layers):
Map of population exposed to flooding
Table with number of people evacuated and supplies required
"""
-
+ print 'BBBBBBBBBBBBBBBBBBB'
# Identify hazard and exposure layers
H = get_hazard_layer(layers) # Flood inundation
E = get_exposure_layer(layers)
@@ -152,17 +154,18 @@ def run(self, layers):
# Generate impact report for the pdf map
table_body = [question,
TableRow([tr('People needing evacuation'),
- '%i' % evacuated],
+ '%s' % format_int(evacuated)],
header=True),
TableRow(tr('Map shows population affected in each flood'
' prone area ')),
TableRow([tr('Needs per week'), tr('Total')],
header=True),
- [tr('Rice [kg]'), int(rice)],
- [tr('Drinking Water [l]'), int(drinking_water)],
- [tr('Clean Water [l]'), int(water)],
- [tr('Family Kits'), int(family_kits)],
- [tr('Toilets'), int(toilets)]]
+ [tr('Rice [kg]'), format_int(int(rice))],
+ [tr('Drinking Water [l]'),
+ format_int(int(drinking_water))],
+ [tr('Clean Water [l]'), format_int(int(water))],
+ [tr('Family Kits'), format_int(int(family_kits))],
+ [tr('Toilets'), format_int(int(toilets))]]
impact_table = Table(table_body).toNewlineFreeString()
table_body.append(TableRow(tr('Action Checklist:'), header=True))
@@ -177,7 +180,7 @@ def run(self, layers):
# Extend impact report for on-screen display
table_body.extend([TableRow(tr('Notes'), header=True),
- tr('Total population: %i') % total,
+ tr('Total population: %s') % format_int(total),
tr('People need evacuation if in area identified '
'as "Flood Prone"'),
tr('Minimum needs are defined in BNPB '
21 safe/impact_functions/volcanic/volcano_building_impact.py
View
@@ -1,12 +1,14 @@
import numpy
-from safe.impact_functions.core import FunctionProvider
-from safe.impact_functions.core import get_hazard_layer, get_exposure_layer
-from safe.impact_functions.core import get_question
+from safe.impact_functions.core import (FunctionProvider,
+ get_hazard_layer,
+ get_exposure_layer,
+ get_question,
+ format_int)
from safe.storage.vector import Vector
from safe.common.utilities import ugettext as tr
from safe.common.tables import Table, TableRow
-from safe.engine.interpolation import assign_hazard_values_to_exposure_data
-from safe.engine.interpolation import make_circular_polygon
+from safe.engine.interpolation import (assign_hazard_values_to_exposure_data,
+ make_circular_polygon)
from safe.common.exceptions import InaSAFEError
from third_party.odict import OrderedDict
@@ -131,13 +133,14 @@ def run(self, layers):
table_body = [question,
TableRow([tr('Buildings'), tr('Total'), tr('Cumulative')],
header=True),
- TableRow([tr('All'), str(total_affected), ''])]
+ TableRow([tr('All'), format_int(total_affected), ''])]
cum = 0
for name in category_names:
count = categories[name]
cum += count
- table_body.append(TableRow([name, str(count), str(cum)]))
+ table_body.append(TableRow([name, format_int(count),
+ format_int(cum)]))
table_body.append(TableRow(tr('Map shows buildings affected in '
'each of volcano hazard polygons.')))
@@ -145,8 +148,8 @@ def run(self, layers):
# Extend impact report for on-screen display
table_body.extend([TableRow(tr('Notes'), header=True),
- tr('Total number of buildings %i in the viewable '
- 'area') % total,
+ tr('Total number of buildings %s in the viewable '
+ 'area') % format_int(total),
tr('Only buildings available in OpenStreetMap '
'are considered.')])
impact_summary = Table(table_body).toNewlineFreeString()
13 safe/impact_functions/volcanic/volcano_population_evacuation_polygon_hazard.py
View
@@ -1,13 +1,14 @@
import numpy
-from safe.impact_functions.core import FunctionProvider
-from safe.impact_functions.core import get_hazard_layer, get_exposure_layer
-from safe.impact_functions.core import get_question
-from safe.impact_functions.core import format_int
+from safe.impact_functions.core import (FunctionProvider,
+ get_hazard_layer,
+ get_exposure_layer,
+ get_question,
+ format_int)
from safe.storage.vector import Vector
from safe.common.utilities import ugettext as tr
from safe.common.tables import Table, TableRow
-from safe.engine.interpolation import assign_hazard_values_to_exposure_data
-from safe.engine.interpolation import make_circular_polygon
+from safe.engine.interpolation import (assign_hazard_values_to_exposure_data,
+ make_circular_polygon)
from safe.common.exceptions import InaSAFEError
57 safe_qgis/test_dock.py
View
@@ -685,7 +685,7 @@ def test_runEarthQuakeGuidelinesFunction(self):
myMessage = ('Unexpected result returned for Earthquake guidelines'
'function. Expected:\n "All" count of 2993, '
'received: \n %s' % myResult)
- assert '2993' in myResult, myMessage
+ assert format_int(2993) in myResult, myMessage
def test_runEarthquakeFatalityFunction_small(self):
"""Padang 2009 fatalities estimated correctly (small extent)"""
@@ -736,12 +736,12 @@ def test_runEarthquakeFatalityFunction_small(self):
myMessage = ('Unexpected result returned for Earthquake Fatality '
'Function Expected: fatality count of '
'116 , received: \n %s' % myResult)
- assert '116' in myResult, myMessage
+ assert format_int(116) in myResult, myMessage
myMessage = ('Unexpected result returned for Earthquake Fatality '
'Function Expected: total population count of '
'847529 , received: \n %s' % myResult)
- assert '847529' in myResult, myMessage
+ assert format_int(847529) in myResult, myMessage
def test_runEarthquakeFatalityFunction_Padang_full(self):
"""Padang 2009 fatalities estimated correctly (large extent)"""
@@ -791,12 +791,12 @@ def test_runEarthquakeFatalityFunction_Padang_full(self):
myMessage = ('Unexpected result returned for Earthquake Fatality '
'Function Expected: fatality count of '
'500 , received: \n %s' % myResult)
- assert '500' in myResult, myMessage
+ assert format_int(500) in myResult, myMessage
myMessage = ('Unexpected result returned for Earthquake Fatality '
'Function Expected: total population count of '
'31372262 , received: \n %s' % myResult)
- assert '31372262' in myResult, myMessage
+ assert format_int(31372262) in myResult, myMessage
def test_runTsunamiBuildingImpactFunction(self):
"""Tsunami function runs in GUI as expected."""
@@ -836,8 +836,8 @@ def test_runTsunamiBuildingImpactFunction(self):
#All 7 17
myMessage = 'Result not as expected: %s' % myResult
- assert '17' in myResult, myMessage
- assert '7' in myResult, myMessage
+ assert format_int(17) in myResult, myMessage
+ assert format_int(7) in myResult, myMessage
def test_runFloodPopulationImpactFunction(self):
"""Flood function runs in GUI with Jakarta data
@@ -868,7 +868,7 @@ def test_runFloodPopulationImpactFunction(self):
# Marco Hartman form HKV
myMessage = 'Result not as expected: %s' % myResult
# This is the expected impact number
- assert '2480' in myResult, myMessage
+ assert format_int(2480) in myResult, myMessage
def test_runFloodPopulationImpactFunction_scaling(self):
"""Flood function runs in GUI with 5x5km population data
@@ -893,8 +893,9 @@ def test_runFloodPopulationImpactFunction_scaling(self):
myMessage = 'Result not as expected: %s' % myResult
# Check numbers are OK (within expected errors from resampling)
+ # These are expected impact number
assert format_int(10484) in myResult, myMessage
- assert '977' in myResult, myMessage # These are expected impact number
+ assert format_int(977) in myResult, myMessage
def test_runFloodPopulationPolygonHazardImpactFunction(self):
"""Flood function runs in GUI with Jakarta polygon flood hazard data.
@@ -918,7 +919,7 @@ def test_runFloodPopulationPolygonHazardImpactFunction(self):
myMessage = 'Result not as expected: %s' % myResult
# This is the expected number of people needing evacuation
- assert '134953000' in myResult, myMessage
+ assert format_int(134953000) in myResult, myMessage
def test_runCategorizedHazardBuildingImpact(self):
"""Flood function runs in GUI with Flood in Jakarta hazard data
@@ -942,9 +943,9 @@ def test_runCategorizedHazardBuildingImpact(self):
myMessage = 'Result not as expected: %s' % myResult
# This is the expected number of building might be affected
- assert '535' in myResult, myMessage
- assert '453' in myResult, myMessage
- assert '436' in myResult, myMessage
+ assert format_int(535) in myResult, myMessage
+ assert format_int(453) in myResult, myMessage
+ assert format_int(436) in myResult, myMessage
def test_runCategorisedHazardPopulationImpactFunction(self):
"""Flood function runs in GUI with Flood in Jakarta hazard data
@@ -968,9 +969,9 @@ def test_runCategorisedHazardPopulationImpactFunction(self):
myMessage = 'Result not as expected: %s' % myResult
# This is the expected number of population might be affected
- assert '30938000' in myResult, myMessage
- assert '68280000' in myResult, myMessage
- assert '157551000' in myResult, myMessage
+ assert format_int(30938000) in myResult, myMessage
+ assert format_int(68280000) in myResult, myMessage
+ assert format_int(157551000) in myResult, myMessage
def test_runEarthquakeBuildingImpactFunction(self):
"""Earthquake function runs in GUI with An earthquake in Yogyakarta
@@ -995,9 +996,9 @@ def test_runEarthquakeBuildingImpactFunction(self):
myMessage = 'Result not as expected: %s' % myResult
# This is the expected number of building might be affected
- assert '786' in myResult, myMessage
- assert '15528' in myResult, myMessage
- assert '177' in myResult, myMessage
+ assert format_int(786) in myResult, myMessage
+ assert format_int(15528) in myResult, myMessage
+ assert format_int(177) in myResult, myMessage
def test_runVolcanoBuildingImpact(self):
"""Volcano function runs in GUI with An donut (merapi hazard map)
@@ -1022,7 +1023,7 @@ def test_runVolcanoBuildingImpact(self):
myMessage = 'Result not as expected: %s' % myResult
# This is the expected number of building might be affected
- assert '288' in myResult, myMessage
+ assert format_int(288) in myResult, myMessage
def test_runVolcanoPopulationImpact(self):
"""Volcano function runs in GUI with a donut (merapi hazard map)
@@ -1051,9 +1052,9 @@ def test_runVolcanoPopulationImpact(self):
# Kawasan Rawan Bencana III 45.000 45.000
# Kawasan Rawan Bencana II 84.000 129.000
# Kawasan Rawan Bencana I 28.000 157.000
- assert '45' in myResult, myMessage
- assert '84' in myResult, myMessage
- assert '28' in myResult, myMessage
+ assert format_int(45) in myResult, myMessage
+ assert format_int(84) in myResult, myMessage
+ assert format_int(28) in myResult, myMessage
def test_runVolcanoCirclePopulation(self):
"""Volcano function runs in GUI with a circular evacutation zone
@@ -1085,9 +1086,9 @@ def test_runVolcanoCirclePopulation(self):
# 3 15.000 15.000
# 5 17.000 32.000
# 10 124.000 156.000
- assert '15' in myResult, myMessage
- assert '17' in myResult, myMessage
- assert '124' in myResult, myMessage
+ assert format_int(15) in myResult, myMessage
+ assert format_int(17) in myResult, myMessage
+ assert format_int(124) in myResult, myMessage
# disabled this test until further coding
def Xtest_printMap(self):
@@ -1185,7 +1186,7 @@ def test_Issue47(self):
myResult = DOCK.wvResults.page().currentFrame().toPlainText()
myMessage = 'Result not as expected: %s' % myResult
- assert '2366' in myResult, myMessage
+ assert format_int(2366) in myResult, myMessage
def test_issue45(self):
"""Points near the edge of a raster hazard layer are interpolated OK"""
@@ -1408,7 +1409,7 @@ def test_issue_160(self):
myResult = DOCK.wvResults.page().currentFrame().toPlainText()
myMessage = 'Result not as expected: %s' % myResult
- assert '68' in myResult, myMessage
+ assert format_int(68) in myResult, myMessage
def test_state(self):
"""Check if the save/restore state methods work. See also
Please sign in to comment.
Something went wrong with that request. Please try again.