Skip to content

Commit

Permalink
Update tests to reflect previous changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioannis-vm committed Nov 6, 2024
1 parent 736b573 commit 70b1975
Show file tree
Hide file tree
Showing 12 changed files with 114 additions and 123 deletions.
5 changes: 3 additions & 2 deletions pelicun/tests/basic/test_loss_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def test___init__(self, loss_model: LossModel) -> None:
assert len(loss_model._loss_models) == 2

def test_decision_variables(self, loss_model: LossModel) -> None:
dvs = ('Carbon', 'Cost', 'Energy', 'Time')
dvs = ('Cost', 'Time')
assert loss_model.decision_variables == dvs
assert loss_model.ds_model.decision_variables == dvs
assert loss_model.lf_model.decision_variables == dvs
Expand Down Expand Up @@ -337,14 +337,15 @@ def test_aggregate_losses_when_no_loss(
) -> None:
# tests that aggregate losses works when there is no loss.
loss_model = LossModel(assessment_instance)
loss_model.decision_variables = ('Cost', 'Time', 'Carbon', 'Energy')
df_agg = loss_model.aggregate_losses()
assert isinstance(df_agg, pd.DataFrame)
pd.testing.assert_frame_equal(
df_agg,
pd.DataFrame(
{
'repair_carbon': 0.0,
'repair_cost': 0.00,
'repair_carbon': 0.0,
'repair_energy': 0.00,
'repair_time-sequential': 0.00,
'repair_time-parallel': 0.00,
Expand Down
23 changes: 11 additions & 12 deletions pelicun/tests/dl_calculation/e1/test_e1.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,17 @@ def test_dl_calculation_1(obtain_temp_dir: str) -> None:
os.chdir(temp_dir)

# run
with pytest.warns(PelicunWarning):
run_pelicun(
demand_file='response.csv',
config_path='8000-AIM.json',
output_path=None,
coupled_edp=True,
realizations=100,
auto_script_path='PelicunDefault/Hazus_Earthquake_IM.py',
detailed_results=False,
output_format=None,
custom_model_dir=None,
)
run_pelicun(
demand_file='response.csv',
config_path='8000-AIM.json',
output_path=None,
coupled_edp=True,
realizations=100,
auto_script_path='PelicunDefault/Hazus_Earthquake_IM.py',
detailed_results=False,
output_format=None,
custom_model_dir=None,
)

#
# Test files
Expand Down
23 changes: 11 additions & 12 deletions pelicun/tests/dl_calculation/e1_no_autopop/test_e1.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,17 @@ def test_dl_calculation_1(obtain_temp_dir: str) -> None:
os.chdir(temp_dir)

# run
with pytest.warns(PelicunWarning):
run_pelicun(
demand_file='response.csv',
config_path='8000-AIM.json',
output_path=None,
coupled_edp=True,
realizations=100,
auto_script_path=None,
detailed_results=False,
output_format=None,
custom_model_dir=None,
)
run_pelicun(
demand_file='response.csv',
config_path='8000-AIM.json',
output_path=None,
coupled_edp=True,
realizations=100,
auto_script_path=None,
detailed_results=False,
output_format=None,
custom_model_dir=None,
)

#
# Test files
Expand Down
23 changes: 11 additions & 12 deletions pelicun/tests/dl_calculation/e2/test_e2.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,18 +80,17 @@ def test_dl_calculation_2(obtain_temp_dir: tuple[str, str]) -> None:
os.chdir(temp_dir)

# run
with pytest.warns(PelicunWarning):
run_pelicun(
demand_file='response.csv',
config_path='1-AIM.json',
output_path=None,
coupled_edp=True,
realizations=100,
auto_script_path='PelicunDefault/Hazus_Earthquake_Story.py',
detailed_results=False,
output_format=None,
custom_model_dir=None,
)
run_pelicun(
demand_file='response.csv',
config_path='1-AIM.json',
output_path=None,
coupled_edp=True,
realizations=100,
auto_script_path='PelicunDefault/Hazus_Earthquake_Story.py',
detailed_results=False,
output_format=None,
custom_model_dir=None,
)

#
# Test files
Expand Down
23 changes: 11 additions & 12 deletions pelicun/tests/dl_calculation/e3/test_e3.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,17 @@ def test_dl_calculation_3(obtain_temp_dir: tuple[str, str]) -> None:
os.chdir(temp_dir)

# run
with pytest.warns(PelicunWarning):
run_pelicun(
demand_file='response.csv',
config_path='170-AIM.json',
output_path=None,
coupled_edp=False,
realizations=100,
auto_script_path='PelicunDefault/Hazus_Earthquake_Story.py',
detailed_results=False,
output_format=None,
custom_model_dir=None,
)
run_pelicun(
demand_file='response.csv',
config_path='170-AIM.json',
output_path=None,
coupled_edp=False,
realizations=100,
auto_script_path='PelicunDefault/Hazus_Earthquake_Story.py',
detailed_results=False,
output_format=None,
custom_model_dir=None,
)

#
# Test files
Expand Down
23 changes: 11 additions & 12 deletions pelicun/tests/dl_calculation/e4/test_e4.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,18 +83,17 @@ def test_dl_calculation_4(obtain_temp_dir: tuple[str, str]) -> None:
os.chdir(temp_dir)

# run
with pytest.warns(PelicunWarning):
run_pelicun(
demand_file='response.csv',
config_path='0-AIM.json',
output_path=None,
coupled_edp=True,
realizations=100,
auto_script_path='PelicunDefault/Hazus_Earthquake_Story.py',
detailed_results=False,
output_format=None,
custom_model_dir=None,
)
run_pelicun(
demand_file='response.csv',
config_path='0-AIM.json',
output_path=None,
coupled_edp=True,
realizations=100,
auto_script_path='PelicunDefault/Hazus_Earthquake_Story.py',
detailed_results=False,
output_format=None,
custom_model_dir=None,
)

#
# Test files
Expand Down
23 changes: 11 additions & 12 deletions pelicun/tests/dl_calculation/e5/test_e5.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,18 +83,17 @@ def test_dl_calculation_5(obtain_temp_dir: tuple[str, str]) -> None:
os.chdir(temp_dir)

# run
with pytest.warns(PelicunWarning):
run_pelicun(
demand_file='response.csv',
config_path='1-AIM.json',
output_path=None,
coupled_edp=True,
realizations=100,
auto_script_path='PelicunDefault/Hazus_Earthquake_IM.py',
detailed_results=False,
output_format=None,
custom_model_dir=None,
)
run_pelicun(
demand_file='response.csv',
config_path='1-AIM.json',
output_path=None,
coupled_edp=True,
realizations=100,
auto_script_path='PelicunDefault/Hazus_Earthquake_IM.py',
detailed_results=False,
output_format=None,
custom_model_dir=None,
)

#
# Test files
Expand Down
23 changes: 11 additions & 12 deletions pelicun/tests/dl_calculation/e6/test_e6.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,18 +83,17 @@ def test_dl_calculation_6(obtain_temp_dir: tuple[str, str]) -> None:
os.chdir(temp_dir)

# run
with pytest.warns(PelicunWarning):
run_pelicun(
demand_file='response.csv',
config_path='1-AIM.json',
output_path=None,
coupled_edp=True,
realizations=100,
auto_script_path='PelicunDefault/Hazus_Earthquake_IM.py',
detailed_results=False,
output_format=None,
custom_model_dir=None,
)
run_pelicun(
demand_file='response.csv',
config_path='1-AIM.json',
output_path=None,
coupled_edp=True,
realizations=100,
auto_script_path='PelicunDefault/Hazus_Earthquake_IM.py',
detailed_results=False,
output_format=None,
custom_model_dir=None,
)

#
# Test files
Expand Down
23 changes: 11 additions & 12 deletions pelicun/tests/dl_calculation/e7/test_e7.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,18 +95,17 @@ def test_dl_calculation_7(obtain_temp_dir: tuple[str, str]) -> None:
os.chdir(temp_dir)

# run
with pytest.warns(PelicunWarning):
run_pelicun(
demand_file='response.csv',
config_path='1-AIM.json',
output_path=None,
coupled_edp=True,
realizations=100,
auto_script_path='auto_HU_NJ.py',
detailed_results=False,
output_format=None,
custom_model_dir=None,
)
run_pelicun(
demand_file='response.csv',
config_path='1-AIM.json',
output_path=None,
coupled_edp=True,
realizations=100,
auto_script_path='auto_HU_NJ.py',
detailed_results=False,
output_format=None,
custom_model_dir=None,
)

# now remove the ruleset files and auto script
for file_path in ruleset_files:
Expand Down
23 changes: 11 additions & 12 deletions pelicun/tests/dl_calculation/e8/test_e8.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,18 +94,17 @@ def test_dl_calculation_8(obtain_temp_dir: tuple[str, str]) -> None:
os.chdir(temp_dir)

# run
with pytest.warns(PelicunWarning):
run_pelicun(
demand_file='response.csv',
config_path='1-AIM.json',
output_path=None,
coupled_edp=True,
realizations=100,
auto_script_path='auto_HU_LA.py',
detailed_results=False,
output_format=None,
custom_model_dir=None,
)
run_pelicun(
demand_file='response.csv',
config_path='1-AIM.json',
output_path=None,
coupled_edp=True,
realizations=100,
auto_script_path='auto_HU_LA.py',
detailed_results=False,
output_format=None,
custom_model_dir=None,
)

# now remove the ruleset files and auto script
for file_path in ruleset_files:
Expand Down
2 changes: 1 addition & 1 deletion pelicun/tests/dl_calculation/e9/custom_pop.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def auto_populate(aim):
"Damage": {"DamageProcess": "None"},
"Demands": {},
"Losses": {
"BldgRepair": {
"Repair": {
"ConsequenceDatabase": "None",
"ConsequenceDatabasePath": (
"CustomDLDataFolder/loss_repair_Tsunami.csv"
Expand Down
23 changes: 11 additions & 12 deletions pelicun/tests/dl_calculation/e9/test_e9.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,18 +94,17 @@ def test_dl_calculation_9(obtain_temp_dir: tuple[str, str]) -> None:
os.chdir(temp_dir)

# run
with pytest.warns(PelicunWarning):
run_pelicun(
demand_file='response.csv',
config_path='3500-AIM.json',
output_path=None,
coupled_edp=True,
realizations=100,
auto_script_path='custom_pop.py',
detailed_results=False,
output_format=None,
custom_model_dir='./CustomDLModels',
)
run_pelicun(
demand_file='response.csv',
config_path='3500-AIM.json',
output_path=None,
coupled_edp=True,
realizations=100,
auto_script_path='custom_pop.py',
detailed_results=False,
output_format=None,
custom_model_dir='./CustomDLModels',
)

# now remove the ruleset files and auto script
for file_path in ruleset_files:
Expand Down

0 comments on commit 70b1975

Please sign in to comment.