@@ -41,8 +41,8 @@ class Exposures(object):
4141 value (np.array): a value for each exposure
4242 impact_id (np.array): impact function id corresponding to each
4343 exposure
44- deductible (np.array, default ): deductible value for each exposure
45- cover (np.array, default ): cover value for each exposure
44+ deductible (np.array, optional ): deductible value for each exposure
45+ cover (np.array, optional ): cover value for each exposure
4646 category_id (np.array, optional): category id for each exposure
4747 (when defined)
4848 region_id (np.array, optional): region id for each exposure
@@ -93,10 +93,9 @@ def clear(self):
9393 self .value = np .array ([], float )
9494 self .impact_id = np .array ([], int )
9595 self .id = np .array ([], int )
96- # Optional variables. Default values set in check if not filled.
96+ # Optional variables.
9797 self .deductible = np .array ([], float )
9898 self .cover = np .array ([], float )
99- # Optional variables. No default values set in check if not filled.
10099 self .category_id = np .array ([], int )
101100 self .region_id = np .array ([], int )
102101 self .assigned = dict ()
@@ -126,7 +125,6 @@ def check(self):
126125 raise ValueError
127126 self ._check_obligatories (num_exp )
128127 self ._check_optionals (num_exp )
129- self ._check_defaults (num_exp )
130128
131129 def plot (self , ignore_zero = True , pop_name = True , buffer_deg = 1.0 ,
132130 extend = 'neither' , ** kwargs ):
@@ -219,7 +217,6 @@ def append(self, exposures):
219217 Raises:
220218 ValueError
221219 """
222- self ._check_defaults (len (self .id ))
223220 exposures .check ()
224221 if self .id .size == 0 :
225222 self .__dict__ = exposures .__dict__ .copy ()
@@ -243,8 +240,9 @@ def append(self, exposures):
243240 self .value = np .append (self .value , exposures .value )
244241 self .impact_id = np .append (self .impact_id , exposures .impact_id )
245242 self .id = np .append (self .id , exposures .id )
246- self .deductible = np .append (self .deductible , exposures .deductible )
247- self .cover = np .append (self .cover , exposures .cover )
243+ self .deductible = self ._append_optional (self .deductible ,
244+ exposures .deductible )
245+ self .cover = self ._append_optional (self .cover , exposures .cover )
248246 self .category_id = self ._append_optional (self .category_id , \
249247 exposures .category_id )
250248 self .region_id = self ._append_optional (self .region_id , \
@@ -363,21 +361,15 @@ def _check_obligatories(self, num_exp):
363361 check .size (num_exp , self .impact_id , 'Exposures.impact_id' )
364362 check .shape (num_exp , 2 , self .coord , 'Exposures.coord' )
365363
366- def _check_defaults (self , num_exp ):
367- """Check coherence optional variables. Warn and set default values \
368- if empty."""
369- self .deductible = check .array_default (num_exp , self .deductible , \
370- 'Exposures.deductible' , np .zeros (num_exp ))
371- self .cover = check .array_default (num_exp , self .cover , \
372- 'Exposures.cover' , self .value .copy ())
373-
374364 def _check_optionals (self , num_exp ):
375365 """Check coherence optional variables. Warn if empty."""
376366 check .array_optional (num_exp , self .category_id , \
377367 'Exposures.category_id' )
378368 check .array_optional (num_exp , self .region_id , \
379369 'Exposures.region_id' )
380370 check .empty_optional (self .assigned , "Exposures.assigned" )
371+ check .array_optional (num_exp , self .deductible , 'Exposures.deductible' )
372+ check .array_optional (num_exp , self .cover , 'Exposures.cover' )
381373 for (ass_haz , ass ) in self .assigned .items ():
382374 if ass_haz == 'NA' :
383375 LOGGER .warning ('Exposures.assigned: assigned hazard type ' \
0 commit comments