Skip to content

Commit

Permalink
Moved case_21 in the infrastructure_risk tests
Browse files Browse the repository at this point in the history
  • Loading branch information
micheles committed Nov 7, 2024
1 parent cd1e400 commit 7864a8d
Show file tree
Hide file tree
Showing 32 changed files with 31 additions and 68 deletions.
90 changes: 30 additions & 60 deletions openquake/calculators/tests/infrastructure_risk_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import numpy
from openquake.baselib import InvalidFile
from openquake.qa_tests_data.infrastructure_risk import (
case_15, five_nodes_demsup_directed, five_nodes_demsup_directedunweighted,
case_1, case_2, five_nodes_demsup_directed, five_nodes_demsup_directedunweighted,
five_nodes_demsup_multidirected, demand_supply, directed, eff_loss_random,
multidirected, multigraph, undirected)
from openquake.calculators.export import export
Expand Down Expand Up @@ -49,102 +49,72 @@ def _check_csv_outputs(self, outputs_list, datastore, testcase,
if replace_expected:
raise ValueError('Remember to set replace_expected to False!')

def test_case_15(self):
self.run_calc(case_15.__file__, 'job.ini')
ds = self.calc.datastore

def test_case_1(self):
self.run_calc(case_1.__file__, 'job.ini')
outputs_list = (
'node_el avg_loss event_ccl event_efl event_pcl event_wcl'
' dem_cl').split()
self._check_csv_outputs(outputs_list, self.calc.datastore, case_1)

self._check_csv_outputs(outputs_list, ds, case_15)
def test_case_2(self):
# infrastructure risk for structural, liquefaction and landslides
out = self.run_calc(case_2.__file__, 'job.ini', exports='csv')
[agg_csv, aggparent_csv] = out[('aggrisk', 'csv')]
self.assertEqualFiles('expected/aggrisk.csv', agg_csv)
self.assertEqualFiles('expected/aggrisk-parent.csv', aggparent_csv)

def test_demand_supply(self):
self.run_calc(demand_supply.__file__, 'job.ini')
ds = self.calc.datastore

outputs_list = (
'avg_loss event_ccl event_efl event_pcl event_wcl node_el'
' dem_cl').split()

self._check_csv_outputs(outputs_list, ds, demand_supply)
self._check_csv_outputs(outputs_list, self.calc.datastore, demand_supply)

def test_directed(self):
self.run_calc(directed.__file__, 'job.ini')
ds = self.calc.datastore

outputs_list = (
'avg_loss event_efl event_pcl event_wcl node_el taz_cl').split()

self._check_csv_outputs(outputs_list, ds, directed)
outputs_list = 'avg_loss event_efl event_pcl event_wcl node_el taz_cl'.split()
self._check_csv_outputs(outputs_list, self.calc.datastore, directed)

def test_eff_loss_random(self):
self.run_calc(eff_loss_random.__file__, 'job.ini')
ds = self.calc.datastore

outputs_list = (
'avg_loss event_efl node_el').split()
outputs_list = 'avg_loss event_efl node_el'.split()

self._check_csv_outputs(outputs_list, ds, eff_loss_random)
self._check_csv_outputs(outputs_list, self.calc.datastore, eff_loss_random)

def test_five_nodes_demsup_directed(self):
self.run_calc(five_nodes_demsup_directed.__file__, 'job.ini')
ds = self.calc.datastore

outputs_list = (
'avg_loss event_ccl event_efl event_pcl event_wcl node_el'
' dem_cl').split()

self._check_csv_outputs(outputs_list, ds, five_nodes_demsup_directed)
outputs_list = ('avg_loss event_ccl event_efl event_pcl event_wcl node_el'
' dem_cl').split()
self._check_csv_outputs(outputs_list, self.calc.datastore, five_nodes_demsup_directed)

def test_five_nodes_demsup_directedunweighted(self):
self.run_calc(five_nodes_demsup_directedunweighted.__file__, 'job.ini')
ds = self.calc.datastore

outputs_list = (
'avg_loss event_ccl event_efl event_pcl event_wcl node_el'
' dem_cl').split()

outputs_list = ('avg_loss event_ccl event_efl event_pcl event_wcl node_el'
' dem_cl').split()
self._check_csv_outputs(
outputs_list, ds, five_nodes_demsup_directedunweighted)
outputs_list, self.calc.datastore, five_nodes_demsup_directedunweighted)

def test_five_nodes_demsup_multidirected(self):
self.run_calc(five_nodes_demsup_multidirected.__file__, 'job.ini')
ds = self.calc.datastore

outputs_list = (
'avg_loss event_ccl event_efl event_pcl event_wcl node_el'
' dem_cl').split()

outputs_list = ('avg_loss event_ccl event_efl event_pcl event_wcl node_el'
' dem_cl').split()
self._check_csv_outputs(
outputs_list, ds, five_nodes_demsup_multidirected)
outputs_list, self.calc.datastore, five_nodes_demsup_multidirected)

def test_multidirected(self):
self.run_calc(multidirected.__file__, 'job.ini')
ds = self.calc.datastore

outputs_list = (
'avg_loss event_efl event_pcl event_wcl node_el taz_cl').split()

self._check_csv_outputs(outputs_list, ds, multidirected)
outputs_list = 'avg_loss event_efl event_pcl event_wcl node_el taz_cl'.split()
self._check_csv_outputs(outputs_list, self.calc.datastore, multidirected)

def test_multigraph(self):
self.run_calc(multigraph.__file__, 'job.ini')
ds = self.calc.datastore

outputs_list = (
'avg_loss event_efl event_pcl event_wcl node_el taz_cl').split()

self._check_csv_outputs(outputs_list, ds, multigraph)
outputs_list = 'avg_loss event_efl event_pcl event_wcl node_el taz_cl'.split()
self._check_csv_outputs(outputs_list, self.calc.datastore, multigraph)

def test_undirected(self):
self.run_calc(undirected.__file__, 'job.ini')
ds = self.calc.datastore

outputs_list = (
'avg_loss event_efl event_pcl event_wcl node_el taz_cl').split()

self._check_csv_outputs(outputs_list, ds, undirected)
outputs_list = 'avg_loss event_efl event_pcl event_wcl node_el taz_cl'.split()
self._check_csv_outputs(outputs_list, self.calc.datastore, undirected)

def test_missing_mandatory_column(self):
with self.assertRaises(InvalidFile) as exc:
Expand Down
9 changes: 1 addition & 8 deletions openquake/calculators/tests/scenario_damage_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from openquake.qa_tests_data.scenario_damage import (
case_1, case_1c, case_2, case_3, case_4, case_4b, case_5, case_5a,
case_6, case_7, case_8, case_9, case_10, case_11, case_12, case_13,
case_14, case_16, case_17, case_18, case_19, case_20, case_21, case_22)
case_14, case_16, case_17, case_18, case_19, case_20, case_22)
from openquake.calculators.tests import CalculatorTestCase, strip_calc_id
from openquake.calculators.extract import extract
from openquake.calculators.export import export
Expand Down Expand Up @@ -288,13 +288,6 @@ def test_case_20(self):
[fname] = out[('aggrisk', 'csv')]
self.assertEqualFiles('expected/aggrisk.csv', fname)

def test_case_21(self):
# infrastructure risk for structural, liquefaction and landslides
out = self.run_calc(case_21.__file__, 'job.ini', exports='csv')
[agg_csv, aggparent_csv] = out[('aggrisk', 'csv')]
self.assertEqualFiles('expected/aggrisk.csv', agg_csv)
self.assertEqualFiles('expected/aggrisk-parent.csv', aggparent_csv)

def test_case_22(self):
# losses with liquefaction and landslides
self.run_calc(case_22.__file__, 'job_h.ini')
Expand Down

0 comments on commit 7864a8d

Please sign in to comment.