@@ -233,11 +233,11 @@ def _return_impact(self, imp_mat_gen, save_mat):
233233 imp_mat , self .hazard .frequency
234234 )
235235 if isinstance (self .hazard , HazardForecast ):
236- eai_exp = np .nan * np .ones ( eai_exp . shape , dtype = eai_exp .dtype )
237- aai_agg = np .nan * np .ones ( aai_agg . shape , dtype = aai_agg .dtype )
236+ eai_exp = np .full_like ( eai_exp , np .nan , dtype = eai_exp .dtype )
237+ aai_agg = np .full_like ( aai_agg , np .nan , dtype = aai_agg .dtype )
238238 LOGGER .warning (
239239 "eai_exp and aai_agg are undefined with forecasts. "
240- "Setting them to empty arrays."
240+ "Setting them to NaN arrays."
241241 )
242242
243243 else :
@@ -256,8 +256,7 @@ def _return_impact(self, imp_mat_gen, save_mat):
256256 return ImpactForecast .from_impact (
257257 impact , self .hazard .lead_time , self .hazard .member
258258 )
259- else :
260- return impact
259+ return impact
261260
262261 def _return_empty (self , save_mat ):
263262 """
@@ -273,33 +272,34 @@ def _return_empty(self, save_mat):
273272 Impact or ImpactForecast
274273 Empty impact object with correct array sizes.
275274 """
275+ at_event = np .zeros (self .n_events )
276276 if isinstance (self .hazard , HazardForecast ):
277- eai_exp = np .nan * np . ones (self .n_exp_pnt )
277+ eai_exp = np .full (self .n_exp_pnt , np . nan )
278278 aai_agg = np .nan
279279 else :
280280 eai_exp = np .zeros (self .n_exp_pnt )
281281 aai_agg = 0.0
282- at_event = np . zeros ( self . n_events )
282+
283283 if save_mat :
284284 imp_mat = sparse .csr_matrix (
285285 (self .n_events , self .n_exp_pnt ), dtype = np .float64
286286 )
287287 else :
288288 if isinstance (self .hazard , HazardForecast ):
289289 raise ValueError (
290- "Saving impact matrix is required when using HazardForecast."
290+ "Saving impact matrix is required when using HazardForecast. "
291291 "Please set save_mat=True."
292292 )
293293 imp_mat = None
294+
294295 impact = Impact .from_eih (
295296 self .exposures , self .hazard , at_event , eai_exp , aai_agg , imp_mat
296297 )
297298 if isinstance (self .hazard , HazardForecast ):
298299 return ImpactForecast .from_impact (
299300 impact , self .hazard .lead_time , self .hazard .member
300301 )
301- else :
302- return impact
302+ return impact
303303
304304 def minimal_exp_gdf (
305305 self , impf_col , assign_centroids , ignore_cover , ignore_deductible
0 commit comments