Skip to content

Commit 3ed1b5c

Browse files
committed
Updates calc_impact code and docstring
1 parent 8d6ef87 commit 3ed1b5c

1 file changed

Lines changed: 27 additions & 2 deletions

File tree

climada/entity/measures/measure.py

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323

2424
from pandas.tseries.offsets import BaseOffset
2525

26+
from climada.engine.impact import Impact
27+
2628
__all__ = ["Measure"]
2729

2830
import copy
@@ -490,7 +492,30 @@ def apply(
490492
)
491493
return changed_exposures, changed_impfset, changed_hazard
492494

493-
def calc_impact(self, exposures, impfset, hazard):
495+
def calc_impact(
496+
self, exposures: Exposures, impfset: ImpactFuncSet, hazard: Hazard
497+
) -> Impact:
498+
"""Compute impact with the active measure.
499+
500+
This convenience method allow to compute an ``Impact`` object from an
501+
(Exposure, ImpactFuncSet, Hazard) triplet by first applying the measure
502+
to that triplet.
503+
504+
Parameters
505+
----------
506+
exposures : Exposures
507+
The initial (no adaptation) exposures
508+
impfset : ImpactFuncSet
509+
The initial (no adaptation) impact function set
510+
hazard : Hazard
511+
The initial (no adaptation) hazard set
512+
513+
Returns
514+
-------
515+
Impact
516+
The computed impact when the measure is in effect.
517+
518+
"""
494519
from climada.engine.impact_calc import (
495520
ImpactCalc, # pylint: disable=import-outside-toplevel
496521
)
@@ -507,4 +532,4 @@ def calc_impact(self, exposures, impfset, hazard):
507532
imp = ImpactCalc(new_exp, new_impfs, new_haz).impact(
508533
save_mat=False, assign_centroids=False
509534
)
510-
return imp.calc_risk_transfer(0, 0)
535+
return imp # .calc_risk_transfer(0, 0)

0 commit comments

Comments
 (0)