Skip to content

Commit 29ced07

Browse files
committed
signal: various _signaltools improvements
1 parent c72b33d commit 29ced07

File tree

1 file changed

+100
-31
lines changed

1 file changed

+100
-31
lines changed

scipy-stubs/signal/_signaltools.pyi

+100-31
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
from typing import Any, Literal, overload
1+
from typing import Any, Literal, TypeAlias, overload
22

33
import numpy as np
44
import optype.numpy as onp
5-
from scipy._typing import Untyped, UntypedArray
5+
from scipy._typing import CorrelateMode, Untyped, UntypedArray
6+
from ._ltisys import dlti
67

78
__all__ = [
89
"choose_conv_method",
@@ -40,72 +41,140 @@ __all__ = [
4041
"wiener",
4142
]
4243

43-
def correlate(in1: Untyped, in2: Untyped, mode: str = "full", method: str = "auto") -> Untyped: ...
44-
def correlation_lags(in1_len: Untyped, in2_len: Untyped, mode: str = "full") -> Untyped: ...
45-
def fftconvolve(in1: Untyped, in2: Untyped, mode: str = "full", axes: Untyped | None = None) -> Untyped: ...
46-
def oaconvolve(in1: Untyped, in2: Untyped, mode: str = "full", axes: Untyped | None = None) -> Untyped: ...
47-
def choose_conv_method(in1: Untyped, in2: Untyped, mode: str = "full", measure: bool = False) -> Untyped: ...
48-
def convolve(in1: Untyped, in2: Untyped, mode: str = "full", method: str = "auto") -> Untyped: ...
44+
_CorrelateMethod: TypeAlias = Literal["auto", "direct", "fft"]
45+
_BoundaryConditions: TypeAlias = Literal["fill", "wrap", "symm"]
46+
_ResidueType: TypeAlias = Literal["avg", "min", "max"]
47+
_RootType: TypeAlias = Literal[_ResidueType, "maximum", "avg", "mean"]
48+
_Domain: TypeAlias = Literal["time", "freq"]
49+
_TrendType: TypeAlias = Literal["linear", "constant"]
50+
_PadType: TypeAlias = Literal["constant", "line", "mean", "median", "maximum", "minimum", "symmetric", "reflect", "edge", "wrap"]
51+
_FiltFiltPadType: TypeAlias = Literal["odd", "even", "constant"]
52+
_ResidualKind: TypeAlias = Literal["lowpass", "all"]
53+
_FilterType: TypeAlias = Literal["iir", "fir"] | dlti
54+
55+
###
56+
57+
# TODO(jorenham): deprecate `longdouble` and `object_` input
58+
def choose_conv_method(in1: Untyped, in2: Untyped, mode: CorrelateMode = "full", measure: bool = False) -> Untyped: ...
59+
def correlate(in1: Untyped, in2: Untyped, mode: CorrelateMode = "full", method: _CorrelateMethod = "auto") -> Untyped: ...
60+
def convolve(in1: Untyped, in2: Untyped, mode: CorrelateMode = "full", method: _CorrelateMethod = "auto") -> Untyped: ...
61+
def lfilter(b: Untyped, a: Untyped, x: Untyped, axis: int = -1, zi: Untyped | None = None) -> Untyped: ...
62+
def sosfilt(sos: Untyped, x: Untyped, axis: int = -1, zi: Untyped | None = None) -> Untyped: ...
63+
64+
#
65+
def correlation_lags(in1_len: Untyped, in2_len: Untyped, mode: CorrelateMode = "full") -> Untyped: ...
66+
def fftconvolve(in1: Untyped, in2: Untyped, mode: CorrelateMode = "full", axes: Untyped | None = None) -> Untyped: ...
67+
def oaconvolve(in1: Untyped, in2: Untyped, mode: CorrelateMode = "full", axes: Untyped | None = None) -> Untyped: ...
68+
69+
#
4970
def order_filter(a: Untyped, domain: Untyped, rank: Untyped) -> Untyped: ...
71+
72+
#
5073
def medfilt(volume: Untyped, kernel_size: Untyped | None = None) -> Untyped: ...
51-
def wiener(im: Untyped, mysize: Untyped | None = None, noise: Untyped | None = None) -> Untyped: ...
52-
def convolve2d(in1: Untyped, in2: Untyped, mode: str = "full", boundary: str = "fill", fillvalue: int = 0) -> Untyped: ...
53-
def correlate2d(in1: Untyped, in2: Untyped, mode: str = "full", boundary: str = "fill", fillvalue: int = 0) -> Untyped: ...
5474
def medfilt2d(input: Untyped, kernel_size: int = 3) -> Untyped: ...
55-
def lfilter(b: Untyped, a: Untyped, x: Untyped, axis: int = -1, zi: Untyped | None = None) -> Untyped: ...
75+
76+
#
77+
def wiener(im: Untyped, mysize: Untyped | None = None, noise: Untyped | None = None) -> Untyped: ...
78+
79+
#
80+
def convolve2d(
81+
in1: Untyped,
82+
in2: Untyped,
83+
mode: CorrelateMode = "full",
84+
boundary: _BoundaryConditions = "fill",
85+
fillvalue: onp.ToComplex = 0,
86+
) -> Untyped: ...
87+
def correlate2d(
88+
in1: Untyped,
89+
in2: Untyped,
90+
mode: CorrelateMode = "full",
91+
boundary: _BoundaryConditions = "fill",
92+
fillvalue: onp.ToComplex = 0,
93+
) -> Untyped: ...
94+
95+
#
5696
def lfiltic(b: Untyped, a: Untyped, y: Untyped, x: Untyped | None = None) -> Untyped: ...
97+
98+
#
5799
def deconvolve(signal: Untyped, divisor: Untyped) -> Untyped: ...
100+
101+
#
58102
def hilbert(x: Untyped, N: Untyped | None = None, axis: int = -1) -> Untyped: ...
59103
def hilbert2(x: Untyped, N: Untyped | None = None) -> Untyped: ...
60-
def unique_roots(p: Untyped, tol: float = 0.001, rtype: str = "min") -> Untyped: ...
61-
def invres(r: Untyped, p: Untyped, k: Untyped, tol: float = 0.001, rtype: str = "avg") -> Untyped: ...
62-
def residue(b: Untyped, a: Untyped, tol: float = 0.001, rtype: str = "avg") -> Untyped: ...
63-
def residuez(b: Untyped, a: Untyped, tol: float = 0.001, rtype: str = "avg") -> Untyped: ...
64-
def invresz(r: Untyped, p: Untyped, k: Untyped, tol: float = 0.001, rtype: str = "avg") -> Untyped: ...
104+
105+
#
106+
def unique_roots(p: Untyped, tol: float = 0.001, rtype: _RootType = "min") -> Untyped: ...
107+
108+
#
109+
def residue(b: Untyped, a: Untyped, tol: float = 0.001, rtype: _ResidueType = "avg") -> Untyped: ...
110+
def residuez(b: Untyped, a: Untyped, tol: float = 0.001, rtype: _ResidueType = "avg") -> Untyped: ...
111+
112+
#
113+
def invres(r: Untyped, p: Untyped, k: Untyped, tol: float = 0.001, rtype: _ResidueType = "avg") -> Untyped: ...
114+
def invresz(r: Untyped, p: Untyped, k: Untyped, tol: float = 0.001, rtype: _ResidueType = "avg") -> Untyped: ...
115+
116+
#
65117
def resample(
66118
x: Untyped,
67119
num: Untyped,
68120
t: Untyped | None = None,
69121
axis: int = 0,
70122
window: Untyped | None = None,
71-
domain: str = "time",
123+
domain: _Domain = "time",
72124
) -> Untyped: ...
73125
def resample_poly(
74126
x: Untyped,
75127
up: Untyped,
76128
down: Untyped,
77129
axis: int = 0,
78130
window: Untyped = ("kaiser", 5.0),
79-
padtype: str = "constant",
131+
padtype: _PadType = "constant",
80132
cval: Untyped | None = None,
81133
) -> Untyped: ...
134+
135+
#
82136
def vectorstrength(events: Untyped, period: Untyped) -> Untyped: ...
137+
138+
#
83139
def detrend(
84140
data: UntypedArray,
85141
axis: int = -1,
86-
type: Literal["linear", "constant"] = "linear",
142+
type: _TrendType = "linear",
87143
bp: onp.ToJustInt | onp.ToJustIntND = 0,
88144
overwrite_data: bool = False,
89145
) -> UntypedArray: ...
146+
147+
#
90148
def lfilter_zi(b: Untyped, a: Untyped) -> Untyped: ...
91149
def sosfilt_zi(sos: Untyped) -> Untyped: ...
150+
151+
#
92152
def filtfilt(
93153
b: Untyped,
94154
a: Untyped,
95155
x: Untyped,
96156
axis: int = -1,
97-
padtype: str = "odd",
98-
padlen: Untyped | None = None,
99-
method: str = "pad",
100-
irlen: Untyped | None = None,
157+
padtype: _FiltFiltPadType = "odd",
158+
padlen: int | None = None,
159+
method: Literal["pad", "gust"] = "pad",
160+
irlen: int | None = None,
101161
) -> Untyped: ...
102-
def sosfilt(sos: Untyped, x: Untyped, axis: int = -1, zi: Untyped | None = None) -> Untyped: ...
103-
def sosfiltfilt(sos: Untyped, x: Untyped, axis: int = -1, padtype: str = "odd", padlen: Untyped | None = None) -> Untyped: ...
162+
163+
#
164+
def sosfiltfilt(
165+
sos: Untyped,
166+
x: Untyped,
167+
axis: int = -1,
168+
padtype: _FiltFiltPadType = "odd",
169+
padlen: int | None = None,
170+
) -> Untyped: ...
171+
172+
#
104173
def decimate(
105174
x: Untyped,
106-
q: Untyped,
107-
n: Untyped | None = None,
108-
ftype: str = "iir",
175+
q: int,
176+
n: int | None = None,
177+
ftype: _FilterType = "iir",
109178
axis: int = -1,
110179
zero_phase: bool = True,
111180
) -> Untyped: ...
@@ -119,7 +188,7 @@ def envelope(
119188
*,
120189
n_out: int | None = None,
121190
squared: bool = False,
122-
residual: Literal["lowpass", "all"] | None = "lowpass",
191+
residual: _ResidualKind | None = "lowpass",
123192
axis: int = -1,
124193
) -> onp.ArrayND[np.floating[Any]]: ...
125194
@overload
@@ -129,6 +198,6 @@ def envelope(
129198
*,
130199
n_out: int | None = None,
131200
squared: bool = False,
132-
residual: Literal["lowpass", "all"] | None = "lowpass",
201+
residual: _ResidualKind | None = "lowpass",
133202
axis: int = -1,
134203
) -> onp.ArrayND[np.inexact[Any]]: ...

0 commit comments

Comments
 (0)