Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions scipy-stubs/signal/_polyutils.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from types import ModuleType
from typing import Any, TypeVar

import numpy as np
import optype.numpy as onp
import optype.numpy.compat as npc

_InexactT = TypeVar("_InexactT", bound=npc.inexact)

###

def _sort_cmplx(arr: onp.ArrayND[_InexactT], xp: ModuleType) -> onp.ArrayND[_InexactT]: ...
def polyroots(coef: onp.ArrayND[_InexactT], *, xp: ModuleType) -> onp.ArrayND[_InexactT]: ...
def _trim_zeros(filt: onp.Array1D[_InexactT], trim: str = "fb") -> onp.Array1D[_InexactT]: ...
def _poly1d(c_or_r: onp.Array1D[_InexactT], *, xp: ModuleType) -> onp.Array1D[_InexactT]: ...
def polyval(p: onp.ArrayND[npc.number], x: onp.ArrayND[_InexactT], *, xp: ModuleType) -> onp.ArrayND[_InexactT]: ...
def poly(seq_of_zeros: onp.ToComplex1D, *, xp: ModuleType) -> onp.ArrayND[np.float64 | Any]: ...
def polymul(a1: onp.ArrayND[_InexactT], a2: onp.ArrayND[_InexactT], *, xp: ModuleType) -> onp.ArrayND[_InexactT]: ...
def npp_polyval(
x: onp.ToComplex | onp.ToComplexND, c: onp.ArrayND[npc.number], *, xp: ModuleType, tensor: bool = True
) -> onp.ArrayND[np.float64 | Any]: ...
def npp_polyvalfromroots(
x: onp.ToComplex | onp.ToComplexND, r: onp.ArrayND[npc.number], *, xp: ModuleType, tensor: bool = True
) -> onp.ArrayND[np.float64 | Any]: ...
52 changes: 52 additions & 0 deletions scipy-stubs/signal/_sigtools.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
from _typeshed import Incomplete
from typing import Literal, TypeAlias, TypeVar

import numpy as np
import optype.numpy as onp
import optype.numpy.compat as npc

_NumberT = TypeVar("_NumberT", bound=npc.number)
_ImageScalarT = TypeVar("_ImageScalarT", bound=np.uint8 | np.float32 | np.float64)
_Mode: TypeAlias = Literal[0, 1, 2]

###

# defined in scipy/signal/_correlate_nd.cc
def _correlateND(
x: onp.ArrayND[_NumberT], y: onp.ArrayND[_NumberT], out: onp.ArrayND[_NumberT], mode: _Mode = 2
) -> onp.ArrayND[_NumberT]: ...

# defined in scipy/signal/_sigtoolsmodule.cc
def _convolve2d(
in1: onp.ArrayND[_NumberT],
in2: onp.ArrayND[_NumberT],
flip: int = 1,
mode: _Mode = 2,
boundary: int = 0,
fillvalue: Incomplete | None = None,
) -> Incomplete: ...

# defined in scipy/signal/_lfilter.cc
def _linear_filter(
b: onp.ArrayND[_NumberT],
a: onp.ArrayND[_NumberT],
X: onp.ArrayND[_NumberT],
axis: int = -1,
Vi: onp.ArrayND[_NumberT] | None = None,
) -> onp.ArrayND[_NumberT]: ...

# defined in scipy/signal/_sigtoolsmodule.cc
def _remez(
numtaps: int,
bands: onp.ArrayND[np.float64],
des: onp.ArrayND[np.float64],
weight: onp.ArrayND[np.float64],
type: Literal[1, 2, 3] = 1,
fs: float = 1.0,
maxiter: int = 25,
grid_density: int = 16,
) -> onp.ArrayND[np.float64]: ...

#
# defined in scipy/signal/_sigtoolsmodule.cc
def _medfilt2d(image: onp.Array2D[_ImageScalarT], size: tuple[int, int]) -> onp.Array2D[_ImageScalarT]: ...
14 changes: 14 additions & 0 deletions scipy-stubs/signal/_sosfilt.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# defined in scipy/signal/_sosfilt.pyx

from typing import TypeVar

import numpy as np
import optype.numpy as onp

# emulate `ctypedef fused DTYPE_t`
_DTypeT = TypeVar("_DTypeT", np.float32, np.float64, np.longdouble, np.complex64, np.complex128, np.clongdouble, np.object_)

###

def _sosfilt_object(sos: onp.Array2D[np.object_], x: onp.Array2D[np.object_], zi: onp.Array3D[np.object_]) -> None: ...
def _sosfilt(sos: onp.Array2D[_DTypeT], x: onp.Array2D[_DTypeT], zi: onp.Array3D[_DTypeT]) -> None: ...
30 changes: 30 additions & 0 deletions scipy-stubs/signal/_upfirdn_apply.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# defined in scipy/signal/_upfirdn_apply.pyx

from typing import Literal, TypeAlias, TypeVar

import numpy as np
import optype.numpy as onp
import optype.numpy.compat as npc

_DTypeT = TypeVar("_DTypeT", np.float32, np.float64, np.complex64, np.complex128)

_Mode: TypeAlias = Literal["constant", "symmetric", "edge", "smooth", "wrap", "reflect", "antisymmetric", "antireflect", "line"]
_ModeCode: TypeAlias = Literal[0, 1, 2, 3, 4, 5, 6, 7, 8]

###

def _output_len(len_h: np.int64 | int, in_len: np.int64 | int, up: np.int64 | int, down: np.int64 | int) -> int: ...
def mode_enum(mode: _Mode) -> _ModeCode: ...
def _pad_test(
data: onp.ArrayND[_DTypeT], npre: np.intp | int = 0, npost: np.intp | int = 0, mode: _ModeCode = 0
) -> onp.Array1D[_DTypeT]: ...
def _apply(
data: onp.ArrayND[npc.number],
h_trans_flip: onp.Array1D[_DTypeT],
out: onp.ArrayND[npc.number],
up: np.intp | int,
down: np.intp | int,
axis: np.intp | int,
mode: np.intp | int,
cval: _DTypeT | complex,
) -> onp.ArrayND[_DTypeT]: ...