2525from typing import Callable
2626
2727import numpy as np
28+ from scipy import sparse
2829
2930LOGGER = logging .getLogger (__name__ )
3031
@@ -120,13 +121,33 @@ class InterpolationStrategyBase(ABC):
120121 hazard_interp : Callable
121122 vulnerability_interp : Callable
122123
123- def interp_exposure_dim (
124+ def interp_over_exposure_dim (
124125 self , imp_E0 , imp_E1 , interpolation_range : int , ** kwargs
125- ) -> list :
126- """Interpolates along the exposure change between two impact matrices.
126+ ) -> list [sparse .csr_matrix ]:
127+ """Returns a list of `interpolation_range` matrices interpolated between
128+ `mat_start` and `mat_end` using the interpolation strategy defined for exposure.
129+
130+ Parameters
131+ ----------
132+ imp_E0 : scipy.csr_matrix
133+ A sparse matrix of the impacts at the start of the range.
134+ imp_E1 : scipy.csr_matrix
135+ A sparse matrix of the impacts at the end of the range.
136+ interpolation_range : int
137+ The number of time points to interpolate in between the two matrices
138+ kwargs : dict
139+ Keyword arguments to pass to the interpolation function (e.g. rate for exponential interpolation)
140+
141+ Returns
142+ -------
143+ list
144+ A list of interpolated impact matrices between `imp_E0` and `imp_E1`.
145+
146+ Raises
147+ ------
148+ ValueError
149+ A ValueError is raised if the shape of the impact matrices are different.
127150
128- Returns a list of `interpolation_range` matrices linearly interpolated between
129- `mat_start` and `mat_end`.
130151 """
131152 try :
132153 res = self .exposure_interp (imp_E0 , imp_E1 , interpolation_range , ** kwargs )
@@ -140,17 +161,60 @@ def interp_exposure_dim(
140161
141162 return res
142163
143- def interp_hazard_dim (self , metric_0 , metric_1 , ** kwargs ) -> np .ndarray :
164+ def interp_over_hazard_dim (
165+ self , metric_0 : np .ndarray , metric_1 : np .ndarray , ** kwargs
166+ ) -> np .ndarray :
167+ """Interpolates from two arrays of metrics, following the defined interpolation strategy for the hazard dimension.
168+
169+ Parameters
170+ ----------
171+ metric_0 : np.ndarray
172+ The first array of metrics
173+ metric_1 : np.ndarray
174+ The second array of metrics
175+ kwargs : dict
176+ Keyword arguments to pass to the interpolation function (e.g. rate for exponential interpolation)
177+
178+ Returns
179+ -------
180+ np.ndarray
181+ The resulting interpolated array.
182+
183+ """
144184 return self .hazard_interp (metric_0 , metric_1 , ** kwargs )
145185
146- def interp_vulnerability_dim (self , metric_0 , metric_1 , ** kwargs ) -> np .ndarray :
186+ def interp_over_vulnerability_dim (
187+ self , metric_0 : np .ndarray , metric_1 : np .ndarray , ** kwargs
188+ ) -> np .ndarray :
189+ """Interpolates from two arrays of metrics, following the defined interpolation strategy for the vulnerability dimension.
190+
191+ Parameters
192+ ----------
193+ metric_0 : np.ndarray
194+ The first array of metrics
195+ metric_1 : np.ndarray
196+ The second array of metrics
197+ kwargs : dict
198+ Keyword arguments to pass to the interpolation function (e.g. rate for exponential interpolation)
199+
200+ Returns
201+ -------
202+ np.ndarray
203+ The resulting interpolated array.
204+
205+ """
147206 return self .vulnerability_interp (metric_0 , metric_1 , ** kwargs )
148207
149208
150209class InterpolationStrategy (InterpolationStrategyBase ):
151210 """Interface for interpolation strategies."""
152211
153- def __init__ (self , exposure_interp , hazard_interp , vulnerability_interp ) -> None :
212+ def __init__ (
213+ self ,
214+ exposure_interp : Callable ,
215+ hazard_interp : Callable ,
216+ vulnerability_interp : Callable ,
217+ ) -> None :
154218 super ().__init__ ()
155219 self .exposure_interp = exposure_interp
156220 self .hazard_interp = hazard_interp
0 commit comments