|
1 |
| -from typing import Literal |
| 1 | +from typing import Literal, TypeAlias, overload |
| 2 | +from typing_extensions import TypeVar |
2 | 3 |
|
3 |
| -from scipy._typing import Untyped, UntypedArray |
| 4 | +import numpy as np |
| 5 | +import optype as op |
| 6 | +import optype.numpy as onp |
| 7 | +import optype.numpy.compat as npc |
| 8 | +from .windows._windows import _ToWindow |
4 | 9 |
|
5 | 10 | __all__ = ["firls", "firwin", "firwin2", "kaiser_atten", "kaiser_beta", "kaiserord", "minimum_phase", "remez"]
|
6 | 11 |
|
7 |
| -def kaiser_beta(a: Untyped) -> Untyped: ... |
8 |
| -def kaiser_atten(numtaps: int, width: float | None) -> Untyped: ... |
9 |
| -def kaiserord(ripple: Untyped, width: float | None) -> Untyped: ... |
| 12 | +### |
| 13 | + |
| 14 | +_InexactT_py = TypeVar("_InexactT_py", bound=complex) |
| 15 | +_InexactT_np = TypeVar("_InexactT_np", bound=npc.inexact) |
| 16 | + |
| 17 | +_IIRFilterType: TypeAlias = Literal["bandpass", "lowpass", "highpass", "bandstop"] |
| 18 | +_RemezFilterType: TypeAlias = Literal["bandpass", "differentiator", "hilbert"] |
| 19 | +_LinearPhaseFIRMethod: TypeAlias = Literal["homomorphic", "hilbert"] |
| 20 | + |
| 21 | +### |
| 22 | + |
| 23 | +# |
| 24 | +def kaiser_beta(a: onp.ToFloat) -> float: ... |
| 25 | +def kaiserord(ripple: onp.ToFloat, width: onp.ToFloat) -> tuple[int, float]: ... |
| 26 | + |
| 27 | +# |
| 28 | +@overload |
| 29 | +def kaiser_atten(numtaps: _InexactT_py, width: _InexactT_py) -> _InexactT_py: ... |
| 30 | +@overload |
| 31 | +def kaiser_atten(numtaps: _InexactT_np | float, width: _InexactT_np) -> _InexactT_np: ... |
| 32 | +@overload |
| 33 | +def kaiser_atten(numtaps: npc.integer, width: npc.integer | float) -> np.float64: ... |
| 34 | +@overload |
| 35 | +def kaiser_atten(numtaps: npc.integer | float, width: npc.integer) -> np.float64: ... |
| 36 | + |
| 37 | +# |
| 38 | +@overload |
| 39 | +def firwin( |
| 40 | + numtaps: onp.ToJustInt, |
| 41 | + cutoff: onp.ToFloat64 | onp.ToFloat64_1D, |
| 42 | + *, |
| 43 | + width: onp.ToFloat64 | None = None, |
| 44 | + window: _ToWindow = "hamming", |
| 45 | + pass_zero: _IIRFilterType | bool = True, |
| 46 | + scale: op.CanBool = True, |
| 47 | + fs: onp.ToFloat64 | None = None, |
| 48 | +) -> onp.Array1D[np.float64]: ... |
| 49 | +@overload |
10 | 50 | def firwin(
|
11 |
| - numtaps: int, |
12 |
| - cutoff: Untyped, |
| 51 | + numtaps: onp.ToJustInt, |
| 52 | + cutoff: onp.ToFloat | onp.ToFloat1D, |
13 | 53 | *,
|
14 |
| - width: Untyped | None = None, |
15 |
| - window: str = "hamming", |
16 |
| - pass_zero: Literal["bandpass", "lowpass", "highpass", "bandstop"] | bool = True, |
17 |
| - scale: bool = True, |
18 |
| - fs: float | None = None, |
19 |
| -) -> Untyped: ... |
| 54 | + width: onp.ToFloat | None = None, |
| 55 | + window: _ToWindow = "hamming", |
| 56 | + pass_zero: _IIRFilterType | bool = True, |
| 57 | + scale: op.CanBool = True, |
| 58 | + fs: onp.ToFloat | None = None, |
| 59 | +) -> onp.Array1D[np.float64 | np.longdouble]: ... |
| 60 | + |
| 61 | +# |
20 | 62 | def firwin2(
|
21 |
| - numtaps: int, |
22 |
| - freq: Untyped, |
23 |
| - gain: Untyped, |
| 63 | + numtaps: onp.ToJustInt, |
| 64 | + freq: onp.ToFloat1D, |
| 65 | + gain: onp.ToFloat1D, |
24 | 66 | *,
|
25 |
| - nfreqs: Untyped | None = None, |
26 |
| - window: str = "hamming", |
27 |
| - antisymmetric: bool = False, |
28 |
| - fs: float | None = None, |
29 |
| -) -> Untyped: ... |
30 |
| -def remez( |
31 |
| - numtaps: int, |
32 |
| - bands: Untyped, |
33 |
| - desired: Untyped, |
| 67 | + nfreqs: onp.ToJustInt | None = None, |
| 68 | + window: _ToWindow = "hamming", |
| 69 | + antisymmetric: op.CanBool = False, |
| 70 | + fs: onp.ToFloat | None = None, |
| 71 | +) -> onp.Array1D[np.float64]: ... |
| 72 | + |
| 73 | +# |
| 74 | +@overload |
| 75 | +def firls( |
| 76 | + numtaps: onp.ToJustInt, |
| 77 | + bands: onp.ToFloat1D, |
| 78 | + desired: onp.ToFloat1D, |
34 | 79 | *,
|
35 |
| - weight: Untyped | None = None, |
36 |
| - type: str = "bandpass", |
37 |
| - maxiter: int = 25, |
38 |
| - grid_density: int = 16, |
39 |
| - fs: float | None = None, |
40 |
| -) -> Untyped: ... |
| 80 | + weight: onp.ToFloat1D | None = None, |
| 81 | + fs: onp.ToFloat | None = None, |
| 82 | +) -> onp.Array1D[np.float64]: ... |
| 83 | +@overload |
41 | 84 | def firls(
|
42 |
| - numtaps: int, |
43 |
| - bands: Untyped, |
44 |
| - desired: Untyped, |
| 85 | + numtaps: onp.ToJustInt, |
| 86 | + bands: onp.ToFloat2D, |
| 87 | + desired: onp.ToFloat2D, |
45 | 88 | *,
|
46 |
| - weight: Untyped | None = None, |
47 |
| - fs: float | None = None, |
48 |
| -) -> Untyped: ... |
| 89 | + weight: onp.ToFloat1D | None = None, |
| 90 | + fs: onp.ToFloat | None = None, |
| 91 | +) -> onp.Array1D[np.float64]: ... |
| 92 | + |
| 93 | +# |
| 94 | +def remez( |
| 95 | + numtaps: onp.ToJustInt, |
| 96 | + bands: onp.ToFloat1D, |
| 97 | + desired: onp.ToFloat1D, |
| 98 | + *, |
| 99 | + weight: onp.ToFloat1D | None = None, |
| 100 | + type: _RemezFilterType = "bandpass", |
| 101 | + maxiter: onp.ToJustInt = 25, |
| 102 | + grid_density: onp.ToJustInt = 16, |
| 103 | + fs: onp.ToFloat | None = None, |
| 104 | +) -> onp.Array1D[np.float64]: ... |
| 105 | + |
| 106 | +# |
49 | 107 | def minimum_phase(
|
50 |
| - h: UntypedArray, |
51 |
| - method: Literal["homomorphic", "hilbert"] = "homomorphic", |
52 |
| - n_fft: int | None = None, |
| 108 | + h: onp.ToFloat1D, |
| 109 | + method: _LinearPhaseFIRMethod = "homomorphic", |
| 110 | + n_fft: onp.ToJustInt | None = None, |
53 | 111 | *,
|
54 |
| - half: bool = True, |
55 |
| -) -> UntypedArray: ... |
| 112 | + half: op.CanBool = True, |
| 113 | +) -> onp.Array1D[np.float64]: ... |
0 commit comments