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
88# np.floating[Any] because precision is not important
9- _FloatArray = TypeVar ("_FloatArray" , bound = np .ndarray [tuple [int , ...], np .dtype [np .floating [Any ]]])
9+ _Floating = TypeVar ("_Floating" , bound = np .floating [Any ])
10+ _Shape = TypeVar ("_Shape" , bound = tuple [int , ...])
1011_FilterType : TypeAlias = str | Callable [[int ], np .ndarray [tuple [int ], np .dtype [np .float64 ]]]
1112
13+ @overload
1214def resample (
13- x : _FloatArray ,
15+ x : np . ndarray [ _Shape , np . dtype [ np . integer ]] ,
1416 sr_orig : float ,
1517 sr_new : float ,
1618 axis : int = - 1 ,
@@ -20,16 +22,44 @@ def resample(
2022 num_zeros : int = 64 ,
2123 precision : int = 9 ,
2224 rolloff : float = 0.945 ,
23- ) -> _FloatArray : ...
25+ ) -> np .ndarray [_Shape , np .dtype [np .float32 ]]: ...
26+ @overload
27+ def resample (
28+ x : np .ndarray [_Shape , np .dtype [_Floating ]],
29+ sr_orig : float ,
30+ sr_new : float ,
31+ axis : int = - 1 ,
32+ filter : _FilterType = "kaiser_best" ,
33+ parallel : bool = False ,
34+ * ,
35+ num_zeros : int = 64 ,
36+ precision : int = 9 ,
37+ rolloff : float = 0.945 ,
38+ ) -> np .ndarray [_Shape , np .dtype [_Floating ]]: ...
39+
40+ @overload
41+ def resample_nu (
42+ x : np .ndarray [_Shape , np .dtype [np .integer ]],
43+ sr_orig : float ,
44+ t_out : np .ndarray [_Shape , np .dtype [np .float32 ]],
45+ axis : int = - 1 ,
46+ filter : _FilterType = "kaiser_best" ,
47+ parallel : bool = False ,
48+ * ,
49+ num_zeros : int = 64 ,
50+ precision : int = 9 ,
51+ rolloff : float = 0.945 ,
52+ ) -> np .ndarray [_Shape , np .dtype [np .float32 ]]: ...
53+ @overload
2454def resample_nu (
25- x : _FloatArray ,
55+ x : np . ndarray [ _Shape , np . dtype [ _Floating ]] ,
2656 sr_orig : float ,
27- t_out : _FloatArray ,
57+ t_out : np . ndarray [ _Shape , np . dtype [ _Floating ]] ,
2858 axis : int = - 1 ,
2959 filter : _FilterType = "kaiser_best" ,
3060 parallel : bool = False ,
3161 * ,
3262 num_zeros : int = 64 ,
3363 precision : int = 9 ,
3464 rolloff : float = 0.945 ,
35- ) -> _FloatArray : ...
65+ ) -> np . ndarray [ _Shape , np . dtype [ _Floating ]] : ...
0 commit comments