Skip to content

Commit 6cf6f34

Browse files
authored
🏷️ signal: stub the remaining private modules (#723)
2 parents 9e6da0b + 0ce1435 commit 6cf6f34

File tree

4 files changed

+120
-0
lines changed

4 files changed

+120
-0
lines changed

scipy-stubs/signal/_polyutils.pyi

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
from types import ModuleType
2+
from typing import Any, TypeVar
3+
4+
import numpy as np
5+
import optype.numpy as onp
6+
import optype.numpy.compat as npc
7+
8+
_InexactT = TypeVar("_InexactT", bound=npc.inexact)
9+
10+
###
11+
12+
def _sort_cmplx(arr: onp.ArrayND[_InexactT], xp: ModuleType) -> onp.ArrayND[_InexactT]: ...
13+
def polyroots(coef: onp.ArrayND[_InexactT], *, xp: ModuleType) -> onp.ArrayND[_InexactT]: ...
14+
def _trim_zeros(filt: onp.Array1D[_InexactT], trim: str = "fb") -> onp.Array1D[_InexactT]: ...
15+
def _poly1d(c_or_r: onp.Array1D[_InexactT], *, xp: ModuleType) -> onp.Array1D[_InexactT]: ...
16+
def polyval(p: onp.ArrayND[npc.number], x: onp.ArrayND[_InexactT], *, xp: ModuleType) -> onp.ArrayND[_InexactT]: ...
17+
def poly(seq_of_zeros: onp.ToComplex1D, *, xp: ModuleType) -> onp.ArrayND[np.float64 | Any]: ...
18+
def polymul(a1: onp.ArrayND[_InexactT], a2: onp.ArrayND[_InexactT], *, xp: ModuleType) -> onp.ArrayND[_InexactT]: ...
19+
def npp_polyval(
20+
x: onp.ToComplex | onp.ToComplexND, c: onp.ArrayND[npc.number], *, xp: ModuleType, tensor: bool = True
21+
) -> onp.ArrayND[np.float64 | Any]: ...
22+
def npp_polyvalfromroots(
23+
x: onp.ToComplex | onp.ToComplexND, r: onp.ArrayND[npc.number], *, xp: ModuleType, tensor: bool = True
24+
) -> onp.ArrayND[np.float64 | Any]: ...

scipy-stubs/signal/_sigtools.pyi

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
from _typeshed import Incomplete
2+
from typing import Literal, TypeAlias, TypeVar
3+
4+
import numpy as np
5+
import optype.numpy as onp
6+
import optype.numpy.compat as npc
7+
8+
_NumberT = TypeVar("_NumberT", bound=npc.number)
9+
_ImageScalarT = TypeVar("_ImageScalarT", bound=np.uint8 | np.float32 | np.float64)
10+
_Mode: TypeAlias = Literal[0, 1, 2]
11+
12+
###
13+
14+
# defined in scipy/signal/_correlate_nd.cc
15+
def _correlateND(
16+
x: onp.ArrayND[_NumberT], y: onp.ArrayND[_NumberT], out: onp.ArrayND[_NumberT], mode: _Mode = 2
17+
) -> onp.ArrayND[_NumberT]: ...
18+
19+
# defined in scipy/signal/_sigtoolsmodule.cc
20+
def _convolve2d(
21+
in1: onp.ArrayND[_NumberT],
22+
in2: onp.ArrayND[_NumberT],
23+
flip: int = 1,
24+
mode: _Mode = 2,
25+
boundary: int = 0,
26+
fillvalue: Incomplete | None = None,
27+
) -> Incomplete: ...
28+
29+
# defined in scipy/signal/_lfilter.cc
30+
def _linear_filter(
31+
b: onp.ArrayND[_NumberT],
32+
a: onp.ArrayND[_NumberT],
33+
X: onp.ArrayND[_NumberT],
34+
axis: int = -1,
35+
Vi: onp.ArrayND[_NumberT] | None = None,
36+
) -> onp.ArrayND[_NumberT]: ...
37+
38+
# defined in scipy/signal/_sigtoolsmodule.cc
39+
def _remez(
40+
numtaps: int,
41+
bands: onp.ArrayND[np.float64],
42+
des: onp.ArrayND[np.float64],
43+
weight: onp.ArrayND[np.float64],
44+
type: Literal[1, 2, 3] = 1,
45+
fs: float = 1.0,
46+
maxiter: int = 25,
47+
grid_density: int = 16,
48+
) -> onp.ArrayND[np.float64]: ...
49+
50+
#
51+
# defined in scipy/signal/_sigtoolsmodule.cc
52+
def _medfilt2d(image: onp.Array2D[_ImageScalarT], size: tuple[int, int]) -> onp.Array2D[_ImageScalarT]: ...

scipy-stubs/signal/_sosfilt.pyi

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# defined in scipy/signal/_sosfilt.pyx
2+
3+
from typing import TypeVar
4+
5+
import numpy as np
6+
import optype.numpy as onp
7+
8+
# emulate `ctypedef fused DTYPE_t`
9+
_DTypeT = TypeVar("_DTypeT", np.float32, np.float64, np.longdouble, np.complex64, np.complex128, np.clongdouble, np.object_)
10+
11+
###
12+
13+
def _sosfilt_object(sos: onp.Array2D[np.object_], x: onp.Array2D[np.object_], zi: onp.Array3D[np.object_]) -> None: ...
14+
def _sosfilt(sos: onp.Array2D[_DTypeT], x: onp.Array2D[_DTypeT], zi: onp.Array3D[_DTypeT]) -> None: ...

scipy-stubs/signal/_upfirdn_apply.pyi

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# defined in scipy/signal/_upfirdn_apply.pyx
2+
3+
from typing import Literal, TypeAlias, TypeVar
4+
5+
import numpy as np
6+
import optype.numpy as onp
7+
import optype.numpy.compat as npc
8+
9+
_DTypeT = TypeVar("_DTypeT", np.float32, np.float64, np.complex64, np.complex128)
10+
11+
_Mode: TypeAlias = Literal["constant", "symmetric", "edge", "smooth", "wrap", "reflect", "antisymmetric", "antireflect", "line"]
12+
_ModeCode: TypeAlias = Literal[0, 1, 2, 3, 4, 5, 6, 7, 8]
13+
14+
###
15+
16+
def _output_len(len_h: np.int64 | int, in_len: np.int64 | int, up: np.int64 | int, down: np.int64 | int) -> int: ...
17+
def mode_enum(mode: _Mode) -> _ModeCode: ...
18+
def _pad_test(
19+
data: onp.ArrayND[_DTypeT], npre: np.intp | int = 0, npost: np.intp | int = 0, mode: _ModeCode = 0
20+
) -> onp.Array1D[_DTypeT]: ...
21+
def _apply(
22+
data: onp.ArrayND[npc.number],
23+
h_trans_flip: onp.Array1D[_DTypeT],
24+
out: onp.ArrayND[npc.number],
25+
up: np.intp | int,
26+
down: np.intp | int,
27+
axis: np.intp | int,
28+
mode: np.intp | int,
29+
cval: _DTypeT | complex,
30+
) -> onp.ArrayND[_DTypeT]: ...

0 commit comments

Comments
 (0)