Skip to content

CostBenefit measures with new exposure need assigned centroids #1056

@ValentinGebhart

Description

@ValentinGebhart

Describe the bug
In the current Cost Benefit module, when you implement a measure including a new exposure with

measure.exposures_set = new_expsoure

with 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

  1. easy but not efficient: Change one line in CostBenefit._calc_impact_measures to
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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepting pull requestContribute by raising a pull request to resolve this issue!bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions