Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/init entity def #560

Merged
merged 7 commits into from
Oct 27, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions climada/engine/unsequa/input_var.py
Original file line number Diff line number Diff line change
Expand Up @@ -795,13 +795,13 @@ def _meas_set_unc_dict(bounds_cost):

def _ent_unc_func(EN, ET, EL, IFi, IL, MDD, PAA, CO, DR, bounds_noise,
impf_set_list, haz_id_dict, disc_rate, exp_list, meas_set):
ent = Entity()
ent.exposures = _exp_uncfunc(EN, ET, EL, exp_list, bounds_noise)
ent.impact_funcs = _impfset_uncfunc(IFi, MDD, PAA, IL, impf_set_list=impf_set_list,

exposures = _exp_uncfunc(EN, ET, EL, exp_list, bounds_noise)
impact_func_set = _impfset_uncfunc(IFi, MDD, PAA, IL, impf_set_list=impf_set_list,
haz_id_dict=haz_id_dict)
ent.measures = _meas_set_uncfunc(CO, meas_set=meas_set)
ent.disc_rates = _disc_uncfunc(DR, disc_rate)
return ent
measure_set = _meas_set_uncfunc(CO, meas_set=meas_set)
disc_rates = _disc_uncfunc(DR, disc_rate)
return Entity(exposures, disc_rates, impact_func_set, measure_set)

def _ent_unc_dict(bounds_totval, bounds_noise, bounds_impfi, bounds_mdd,
bounds_paa, n_impf_set, bounds_disc, bounds_cost, n_exp):
Expand All @@ -813,13 +813,12 @@ def _ent_unc_dict(bounds_totval, bounds_noise, bounds_impfi, bounds_mdd,

def _entfut_unc_func(EN, EG, EL, IFi, IL, MDD, PAA, CO, bounds_noise,
impf_set_list, haz_id_dict, exp_list, meas_set):
ent = Entity()
ent.exposures = _exp_uncfunc(EN=EN, ET=EG, EL=EL, exp_list=exp_list, bounds_noise=bounds_noise)
ent.impact_funcs = _impfset_uncfunc(IFi, MDD, PAA, IL, impf_set_list=impf_set_list,
exposures = _exp_uncfunc(EN=EN, ET=EG, EL=EL, exp_list=exp_list, bounds_noise=bounds_noise)
impact_funcs = _impfset_uncfunc(IFi, MDD, PAA, IL, impf_set_list=impf_set_list,
haz_id_dict=haz_id_dict)
ent.measures = _meas_set_uncfunc(CO, meas_set=meas_set)
ent.disc_rates = DiscRates() #Disc rate of future entity ignored in cost_benefit.calc()
return ent
measures = _meas_set_uncfunc(CO, meas_set=meas_set)
disc_rates = DiscRates() #Disc rate of future entity ignored in cost_benefit.calc()
return Entity(exposures, disc_rates, impact_funcs, measures)

def _entfut_unc_dict(bounds_impfi, bounds_mdd,
bounds_paa, n_impf_set, bounds_eg, bounds_noise,
Expand Down
16 changes: 11 additions & 5 deletions climada/entity/entity_def.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import logging
import pandas as pd
from typing import Optional
emanuel-schmid marked this conversation as resolved.
Show resolved Hide resolved

from climada.entity.tag import Tag
from climada.entity.impact_funcs.impact_func_set import ImpactFuncSet
Expand All @@ -32,16 +33,16 @@

LOGGER = logging.getLogger(__name__)

class Entity(object):
class Entity:
"""Collects exposures, impact functions, measures and discount rates.
Default values set when empty constructor.

Attributes
----------
exposures : Exposures
exposures
impact_funcs : ImpactFucs
impact functions
impact_funcs : ImpactFuncSet
impact functions set
measures : MeasureSet
measures
disc_rates : DiscRates
Expand All @@ -50,8 +51,13 @@ class Entity(object):
Default file from configuration file
"""

def __init__(self, exposures=None, disc_rates=None,
impact_func_set=None, measure_set=None):
def __init__(
self,
exposures: Optional[Exposures] = None,
disc_rates: Optional[DiscRates] = None,
impact_func_set: Optional[ImpactFuncSet] = None,
measure_set: Optional[MeasureSet] = None
):
"""
Initialize entity

Expand Down
124 changes: 70 additions & 54 deletions doc/tutorial/1_main_climada.ipynb

Large diffs are not rendered by default.