66"""
77from __future__ import annotations
88
9- from typing import Optional
9+ from typing import Generic , Optional , TypeVar , overload
1010
1111import numpy as np
12- from typing_extensions import Final
12+ from typing_extensions import Final , Literal
1313
1414from ..._utils import _cartesian_product , _to_grid_points
1515from ...misc .lstsq import LstsqMethod , solve_regularized_weighted_lstsq
1919from ...representation .basis import Basis
2020from ._linear import _LinearSmoother
2121
22+ T = TypeVar ("T" , Literal [True ], Literal [False ])
2223
23- class BasisSmoother (_LinearSmoother ):
24+
25+ class BasisSmoother (Generic [T ], _LinearSmoother ):
2426 r"""
2527 Transform raw data to a smooth functional form.
2628
@@ -203,6 +205,33 @@ class BasisSmoother(_LinearSmoother):
203205
204206 _required_parameters = ["basis" ]
205207
208+ @overload
209+ def __init__ (
210+ self : BasisSmoother [Literal [False ]],
211+ basis : Basis ,
212+ * ,
213+ smoothing_parameter : float = 1.0 ,
214+ weights : Optional [NDArrayFloat ] = None ,
215+ regularization : Optional [TikhonovRegularization [FDataGrid ]] = None ,
216+ output_points : Optional [GridPointsLike ] = None ,
217+ method : LstsqMethod = 'svd' ,
218+ ) -> None :
219+ pass
220+
221+ @overload
222+ def __init__ (
223+ self : BasisSmoother [T ],
224+ basis : Basis ,
225+ * ,
226+ smoothing_parameter : float = 1.0 ,
227+ weights : Optional [NDArrayFloat ] = None ,
228+ regularization : Optional [TikhonovRegularization [FDataGrid ]] = None ,
229+ output_points : Optional [GridPointsLike ] = None ,
230+ method : LstsqMethod = 'svd' ,
231+ return_basis : T ,
232+ ) -> None :
233+ pass
234+
206235 def __init__ (
207236 self ,
208237 basis : Basis ,
@@ -271,7 +300,7 @@ def fit(
271300 self ,
272301 X : FDataGrid ,
273302 y : None = None ,
274- ) -> BasisSmoother :
303+ ) -> BasisSmoother [ T ] :
275304 """Compute the hat matrix for the desired output points.
276305
277306 Args:
@@ -294,6 +323,22 @@ def fit(
294323
295324 return self
296325
326+ @overload
327+ def transform (
328+ self : BasisSmoother [Literal [False ]],
329+ X : FDataGrid ,
330+ y : None = None ,
331+ ) -> FDataGrid :
332+ pass
333+
334+ @overload
335+ def transform (
336+ self : BasisSmoother [Literal [True ]],
337+ X : FDataGrid ,
338+ y : None = None ,
339+ ) -> FDataBasis :
340+ pass
341+
297342 def transform (
298343 self ,
299344 X : FDataGrid ,
0 commit comments