@@ -83,7 +83,7 @@ def __init__(self):
8383 >>> fun_1.paa = np.array([0, 1])
8484 >>> fun_1.mdd = np.array([0, 0.5])
8585 >>> imp_fun = ImpactFuncSet()
86- >>> imp_fun.add_func (fun_1)
86+ >>> imp_fun.append (fun_1)
8787 >>> imp_fun.check()
8888
8989 Read impact functions from file and checks consistency data.
@@ -96,10 +96,10 @@ def __init__(self):
9696 def clear (self ):
9797 """Reinitialize attributes."""
9898 self .tag = Tag ()
99- self ._data = dict () # {hazard_id : {id:ImpactFunc}}
99+ self ._data = dict () # {hazard_type : {id:ImpactFunc}}
100100
101- def add_func (self , func ):
102- """Add a ImpactFunc. Overwrite existing if same id.
101+ def append (self , func ):
102+ """Append a ImpactFunc. Overwrite existing if same id and haz_type .
103103
104104 Parameters:
105105 func (ImpactFunc): ImpactFunc instance
@@ -111,17 +111,15 @@ def add_func(self, func):
111111 LOGGER .error ("Input value is not of type ImpactFunc." )
112112 raise ValueError
113113 if not func .haz_type :
114- LOGGER .error ("Input ImpactFunc's hazard type not set." )
115- raise ValueError
114+ LOGGER .warning ("Input ImpactFunc's hazard type not set." )
116115 if not func .id :
117- LOGGER .error ("Input ImpactFunc's id not set." )
118- raise ValueError
116+ LOGGER .warning ("Input ImpactFunc's id not set." )
119117 if func .haz_type not in self ._data :
120118 self ._data [func .haz_type ] = dict ()
121119 self ._data [func .haz_type ][func .id ] = func
122120
123121 def remove_func (self , haz_type = None , fun_id = None ):
124- """Remove vulenerability(ies ) with provided hazard type and/or id.
122+ """Remove impact function(s ) with provided hazard type and/or id.
125123 If no input provided, all impact functions are removed.
126124
127125 Parameters:
@@ -188,7 +186,7 @@ def get_hazard_types(self, fun_id=None):
188186 fun_id (int, optional): id of an impact function
189187
190188 Returns:
191- list
189+ list(str)
192190 """
193191 if fun_id is None :
194192 return list (self ._data .keys ())
@@ -257,12 +255,12 @@ def check(self):
257255 raise ValueError
258256 vul .check ()
259257
260- def append (self , impact_funcs ):
258+ def extend (self , impact_funcs ):
261259 """Append impact functions of input ImpactFuncSet to current
262- ImpactFuncSet. Overwrite ImpactFunc if same id.
260+ ImpactFuncSet. Overwrite ImpactFunc if same id and haz_type .
263261
264262 Parameters:
265- impact_funcs (ImpactFuncSet): ImpactFuncSet instance to append
263+ impact_funcs (ImpactFuncSet): ImpactFuncSet instance to extend
266264
267265 Raises:
268266 ValueError
@@ -277,7 +275,7 @@ def append(self, impact_funcs):
277275 new_func = impact_funcs .get_func ()
278276 for _ , vul_dict in new_func .items ():
279277 for _ , vul in vul_dict .items ():
280- self .add_func (vul )
278+ self .append (vul )
281279
282280 def plot (self , haz_type = None , fun_id = None ):
283281 """Plot impact functions of selected hazard (all if not provided) and
@@ -385,7 +383,7 @@ def _get_hdf5_str(imp, idxs, file_name, var_name):
385383 func .intensity = np .take (imp [var_names ['var_name' ]['inten' ]], imp_rows )
386384 func .mdd = np .take (imp [var_names ['var_name' ]['mdd' ]], imp_rows )
387385 func .paa = np .take (imp [var_names ['var_name' ]['paa' ]], imp_rows )
388- self .add_func (func )
386+ self .append (func )
389387 except KeyError as err :
390388 LOGGER .error ("Not existing variable: %s" , str (err ))
391389 raise err
@@ -467,7 +465,7 @@ def _get_xls_funcs(dfr, var_names):
467465 func .mdd = df_func [var_names ['col_name' ]['mdd' ]].values
468466 func .paa = df_func [var_names ['col_name' ]['paa' ]].values
469467
470- self .add_func (func )
468+ self .append (func )
471469
472470 except KeyError as err :
473471 LOGGER .error ("Not existing variable: %s" , str (err ))
0 commit comments