-
Notifications
You must be signed in to change notification settings - Fork 149
Description
Describe the bug
In the current Cost Benefit module, when you implement a measure including a new exposure with
measure.exposures_set = new_expsourewith a new exposure object new_expsoure that does not have assigned hazard centroids, the cost benefit calculation (that includes the above measure in the entity object) like
cb = CostBenefit()
cb.calc(hazard, entity)results in a quite cryptic error saying ValueError: 'assign_centroids' is set to 'False' but no centroids are assigned for the given hazard type (AD). The calc method even has a assign_centroid which however does not change the above error and is thus confusing. Also entity.exposures having assigned centroids does not help avoiding the error,
Suggestions
- easy but not efficient: Change one line in
CostBenefit._calc_impact_measuresto
imp_tmp, risk_transf = measure.calc_impact(
exposures, imp_fun_set, hazard, assign_centroids=True
)instead of
imp_tmp, risk_transf = measure.calc_impact(
exposures, imp_fun_set, hazard, assign_centroids=False
)which redoes the assignment but of of course is suboptimal if already assigned.
2. Check if the new exposure object has assigned centroids and assign if not
3. Do nothing because soon there will be the new Cost Benefit module that solves this problem as well.