11from collections .abc import Callable
2- from typing import Any , TypeAlias , TypeVar
2+ from typing import Any , TypeAlias , TypeVar , overload
33
44import numpy as np
55
66__all__ = ["resample" , "resample_nu" ]
77
8- # np.floating[Any] because precision is not important
9- _FloatArray = TypeVar ("_FloatArray " , bound = np . ndarray [ tuple [int , ...], np . dtype [ np . floating [ Any ]] ])
8+ _Floating = TypeVar ( "_Floating" , bound = np .floating [Any ])
9+ _Shape = TypeVar ("_Shape " , bound = tuple [int , ...])
1010_FilterType : TypeAlias = str | Callable [[int ], np .ndarray [tuple [int ], np .dtype [np .float64 ]]]
1111
12+ @overload
1213def resample (
13- x : _FloatArray ,
14+ x : np . ndarray [ _Shape , np . dtype [ np . integer [ Any ]]] ,
1415 sr_orig : float ,
1516 sr_new : float ,
1617 axis : int = - 1 ,
@@ -20,16 +21,70 @@ def resample(
2021 num_zeros : int = 64 ,
2122 precision : int = 9 ,
2223 rolloff : float = 0.945 ,
23- ) -> _FloatArray : ...
24+ ) -> np .ndarray [_Shape , np .dtype [np .float32 ]]: ...
25+ @overload
26+ def resample (
27+ x : np .ndarray [_Shape , np .dtype [_Floating ]],
28+ sr_orig : float ,
29+ sr_new : float ,
30+ axis : int = - 1 ,
31+ filter : _FilterType = "kaiser_best" ,
32+ parallel : bool = False ,
33+ * ,
34+ num_zeros : int = 64 ,
35+ precision : int = 9 ,
36+ rolloff : float = 0.945 ,
37+ ) -> np .ndarray [_Shape , np .dtype [_Floating ]]: ...
38+ @overload
39+ def resample (
40+ x : np .ndarray [_Shape , np .dtype [np .integer [Any ]]] | np .ndarray [_Shape , np .dtype [_Floating ]],
41+ sr_orig : float ,
42+ sr_new : float ,
43+ axis : int = - 1 ,
44+ filter : _FilterType = "kaiser_best" ,
45+ parallel : bool = False ,
46+ * ,
47+ num_zeros : int = 64 ,
48+ precision : int = 9 ,
49+ rolloff : float = 0.945 ,
50+ ) -> np .ndarray [_Shape , np .dtype [np .float32 ]] | np .ndarray [_Shape , np .dtype [_Floating ]]: ...
51+
52+ @overload
53+ def resample_nu (
54+ x : np .ndarray [_Shape , np .dtype [np .integer [Any ]]],
55+ sr_orig : float ,
56+ t_out : np .ndarray [_Shape , np .dtype [np .float32 ]],
57+ axis : int = - 1 ,
58+ filter : _FilterType = "kaiser_best" ,
59+ parallel : bool = False ,
60+ * ,
61+ num_zeros : int = 64 ,
62+ precision : int = 9 ,
63+ rolloff : float = 0.945 ,
64+ ) -> np .ndarray [_Shape , np .dtype [np .float32 ]]: ...
65+ @overload
66+ def resample_nu (
67+ x : np .ndarray [_Shape , np .dtype [_Floating ]],
68+ sr_orig : float ,
69+ t_out : np .ndarray [_Shape , np .dtype [_Floating ]],
70+ axis : int = - 1 ,
71+ filter : _FilterType = "kaiser_best" ,
72+ parallel : bool = False ,
73+ * ,
74+ num_zeros : int = 64 ,
75+ precision : int = 9 ,
76+ rolloff : float = 0.945 ,
77+ ) -> np .ndarray [_Shape , np .dtype [_Floating ]]: ...
78+ @overload
2479def resample_nu (
25- x : _FloatArray ,
80+ x : np . ndarray [ _Shape , np . dtype [ np . integer [ Any ]]] | np . ndarray [ _Shape , np . dtype [ _Floating ]] ,
2681 sr_orig : float ,
27- t_out : _FloatArray ,
82+ t_out : np . ndarray [ _Shape , np . dtype [ np . float32 ]] | np . ndarray [ _Shape , np . dtype [ _Floating ]] ,
2883 axis : int = - 1 ,
2984 filter : _FilterType = "kaiser_best" ,
3085 parallel : bool = False ,
3186 * ,
3287 num_zeros : int = 64 ,
3388 precision : int = 9 ,
3489 rolloff : float = 0.945 ,
35- ) -> _FloatArray : ...
90+ ) -> np . ndarray [ _Shape , np . dtype [ np . float32 ]] | np . ndarray [ _Shape , np . dtype [ _Floating ]] : ...
0 commit comments