Skip to content

Commit 899d8f0

Browse files
committed
add test to check that eai_exp and aai_agg are nan for forecasts
1 parent 6fe29f0 commit 899d8f0

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

climada/engine/test/test_impact_calc.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -720,6 +720,26 @@ def test_impact_forecast_empty_impmat_error(self):
720720
"Please set save_mat=True.",
721721
)
722722

723+
def test_impact_forecast_blocked_nonsense_attrs(self):
724+
"""Test that nonsense attributes are blocked when computing impact forecast"""
725+
lead_time = pd.timedelta_range("1h", periods=6).to_numpy()
726+
member = np.arange(6)
727+
haz = Hazard.from_hdf5(get_test_file("test_hazard_US_flood_random_locations"))
728+
haz_fc = HazardForecast.from_hazard(haz, lead_time=lead_time, member=member)
729+
730+
exp = Exposures.from_hdf5(
731+
get_test_file("test_exposure_US_flood_random_locations")
732+
)
733+
impf_set = ImpactFuncSet.from_excel(
734+
Path(__file__).parent / "data" / "flood_imp_func_set.xls"
735+
)
736+
impact = ImpactCalc(exp, impf_set, haz_fc).impact(
737+
assign_centroids=False, save_mat=True
738+
)
739+
assert np.isnan(impact.aai_agg)
740+
assert np.all(np.isnan(impact.eai_exp))
741+
assert impact.eai_exp.shape == (len(exp.gdf),)
742+
723743

724744
class TestImpactMatrixCalc(unittest.TestCase):
725745
"""Verify the computation of the impact matrix"""

0 commit comments

Comments
 (0)