Skip to content

Commit

Permalink
Merge pull request #78 from jorenham/stubtest/scipy.signal
Browse files Browse the repository at this point in the history
fix `scipy.signal` stubtest
  • Loading branch information
jorenham authored Oct 11, 2024
2 parents 233af53 + 829f010 commit e5f1226
Show file tree
Hide file tree
Showing 24 changed files with 633 additions and 176 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ jobs:
"scipy.ndimage",
"scipy.odr",
"scipy.optimize",
# "scipy.signal",
"scipy.signal",
# "scipy.sparse",
"scipy.spatial",
"scipy.special",
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ pip install scipy-stubs
| `ndimage` | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :full_moon: |
| `odr` | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :waxing_crescent_moon: |
| `optimize` | :heavy_check_mark: | :heavy_check_mark: | :x: | :x: | :first_quarter_moon: |
| `signal` | :heavy_check_mark: | :x: | :x: | :x: | :new_moon: |
| `signal` | :heavy_check_mark: | :heavy_check_mark: | :x: | :x: | :waxing_crescent_moon: |
| `sparse` | :heavy_check_mark: | :x: | :x: | :x: | :waxing_crescent_moon: |
| `spatial` | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :waxing_gibbous_moon: |
| `special` | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :first_quarter_moon: |
Expand Down
210 changes: 193 additions & 17 deletions scipy-stubs/signal/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,29 +1,205 @@
from . import (
bsplines as bsplines,
filter_design as filter_design,
fir_filter_design as fir_filter_design,
lti_conversion as lti_conversion,
ltisys as ltisys,
signaltools as signaltools,
spectral as spectral,
spline as spline,
waveforms as waveforms,
wavelets as wavelets,
windows as windows,
bsplines,
filter_design,
fir_filter_design,
lti_conversion,
ltisys,
signaltools,
spectral,
spline,
waveforms,
wavelets,
windows,
)
from ._bsplines import *
from ._czt import *
from ._filter_design import *
from ._fir_filter_design import *
from ._lti_conversion import *
from ._ltisys import *
from ._max_len_seq import max_len_seq as max_len_seq
from ._max_len_seq import max_len_seq
from ._peak_finding import *
from ._savitzky_golay import savgol_coeffs as savgol_coeffs, savgol_filter as savgol_filter
from ._savitzky_golay import savgol_coeffs, savgol_filter
from ._short_time_fft import *
from ._signaltools import *
from ._spectral_py import *
from ._spline import sepfir2d as sepfir2d
from ._spline_filters import *
from ._upfirdn import upfirdn as upfirdn
from ._spline import cspline2d, qspline2d, sepfir2d, symiirorder1, symiirorder2
from ._upfirdn import upfirdn
from ._waveforms import *
from .windows import get_window as get_window
from ._wavelets import *
from .windows import get_window

__all__ = [
"CZT",
"BadCoefficients",
"ShortTimeFFT",
"StateSpace",
"TransferFunction",
"ZerosPolesGain",
"ZoomFFT",
"abcd_normalize",
"argrelextrema",
"argrelmax",
"argrelmin",
"band_stop_obj",
"bessel",
"besselap",
"bilinear",
"bilinear_zpk",
"bode",
"bsplines",
"buttap",
"butter",
"buttord",
"cascade",
"cheb1ap",
"cheb1ord",
"cheb2ap",
"cheb2ord",
"cheby1",
"cheby2",
"check_COLA",
"check_NOLA",
"chirp",
"choose_conv_method",
"cmplx_sort",
"coherence",
"cont2discrete",
"convolve",
"convolve2d",
"correlate",
"correlate2d",
"correlation_lags",
"csd",
"cspline1d",
"cspline1d_eval",
"cspline2d",
"cwt",
"czt",
"czt_points",
"daub",
"dbode",
"decimate",
"deconvolve",
"detrend",
"dfreqresp",
"dimpulse",
"dlsim",
"dlti",
"dstep",
"ellip",
"ellipap",
"ellipord",
"fftconvolve",
"filter_design",
"filtfilt",
"find_peaks",
"find_peaks_cwt",
"findfreqs",
"fir_filter_design",
"firls",
"firwin",
"firwin2",
"freqresp",
"freqs",
"freqs_zpk",
"freqz",
"freqz_zpk",
"gammatone",
"gauss_spline",
"gausspulse",
"get_window",
"group_delay",
"hilbert",
"hilbert2",
"iircomb",
"iirdesign",
"iirfilter",
"iirnotch",
"iirpeak",
"impulse",
"invres",
"invresz",
"istft",
"kaiser_atten",
"kaiser_beta",
"kaiserord",
"lfilter",
"lfilter_zi",
"lfiltic",
"lombscargle",
"lp2bp",
"lp2bp_zpk",
"lp2bs",
"lp2bs_zpk",
"lp2hp",
"lp2hp_zpk",
"lp2lp",
"lp2lp_zpk",
"lsim",
"lti",
"lti_conversion",
"ltisys",
"max_len_seq",
"medfilt",
"medfilt2d",
"minimum_phase",
"morlet",
"morlet2",
"normalize",
"oaconvolve",
"order_filter",
"peak_prominences",
"peak_widths",
"periodogram",
"place_poles",
"qmf",
"qspline1d",
"qspline1d_eval",
"qspline2d",
"remez",
"resample",
"resample_poly",
"residue",
"residuez",
"ricker",
"savgol_coeffs",
"savgol_filter",
"sawtooth",
"sepfir2d",
"signaltools",
"sos2tf",
"sos2zpk",
"sosfilt",
"sosfilt_zi",
"sosfiltfilt",
"sosfreqz",
"spectral",
"spectrogram",
"spline",
"spline_filter",
"square",
"ss2tf",
"ss2zpk",
"step",
"stft",
"sweep_poly",
"symiirorder1",
"symiirorder2",
"tf2sos",
"tf2ss",
"tf2zpk",
"unique_roots",
"unit_impulse",
"upfirdn",
"vectorstrength",
"waveforms",
"wavelets",
"welch",
"wiener",
"windows",
"zoom_fft",
"zpk2sos",
"zpk2ss",
"zpk2tf",
]
27 changes: 19 additions & 8 deletions scipy-stubs/signal/_arraytools.pyi
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
from scipy._typing import Untyped
from typing import TypeVar

import numpy as np
import numpy.typing as npt
import optype as op
from scipy._typing import AnyInt

_SCT = TypeVar("_SCT", bound=np.generic)

def axis_slice(
a, start: Untyped | None = None, stop: Untyped | None = None, step: Untyped | None = None, axis: int = -1
) -> Untyped: ...
def axis_reverse(a, axis: int = -1) -> Untyped: ...
def odd_ext(x, n, axis: int = -1) -> Untyped: ...
def even_ext(x, n, axis: int = -1) -> Untyped: ...
def const_ext(x, n, axis: int = -1) -> Untyped: ...
def zero_ext(x, n, axis: int = -1) -> Untyped: ...
a: npt.NDArray[_SCT],
start: op.CanIndex | None = None,
stop: op.CanIndex | None = None,
step: op.CanIndex | None = None,
axis: op.CanIndex = -1,
) -> npt.NDArray[_SCT]: ...
def axis_reverse(a: npt.NDArray[_SCT], axis: op.CanIndex = -1) -> npt.NDArray[_SCT]: ...
def odd_ext(x: npt.NDArray[_SCT], n: AnyInt, axis: op.CanIndex = -1) -> npt.NDArray[_SCT]: ...
def even_ext(x: npt.NDArray[_SCT], n: AnyInt, axis: op.CanIndex = -1) -> npt.NDArray[_SCT]: ...
def const_ext(x: npt.NDArray[_SCT], n: AnyInt, axis: op.CanIndex = -1) -> npt.NDArray[_SCT]: ...
def zero_ext(x: npt.NDArray[_SCT], n: AnyInt, axis: op.CanIndex = -1) -> npt.NDArray[_SCT]: ...
35 changes: 35 additions & 0 deletions scipy-stubs/signal/_bsplines.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
from typing import Any, overload
from typing_extensions import TypeVar

import numpy as np
import numpy.typing as npt
from numpy._typing import _ArrayLike, _ArrayLikeComplex_co, _ArrayLikeFloat_co, _ArrayLikeInt_co
from scipy._typing import AnyInt, AnyReal

__all__ = ["cspline1d", "cspline1d_eval", "gauss_spline", "qspline1d", "qspline1d_eval", "spline_filter"]

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

@overload
def gauss_spline(x: _ArrayLikeInt_co, n: AnyInt) -> npt.NDArray[np.float64]: ...
@overload
def gauss_spline(x: _ArrayLike[_SCT_fc], n: AnyInt) -> npt.NDArray[_SCT_fc]: ...
@overload
def gauss_spline(x: _ArrayLikeFloat_co, n: AnyInt) -> npt.NDArray[np.floating[Any]]: ...
@overload
def gauss_spline(x: _ArrayLikeComplex_co, n: AnyInt) -> npt.NDArray[np.inexact[Any]]: ...
def spline_filter(Iin: _ArrayLike[_SCT_fc], lmbda: AnyReal = 5.0) -> npt.NDArray[_SCT_fc]: ...
def cspline1d(signal: npt.NDArray[_SCT_fc], lamb: AnyReal = 0.0) -> npt.NDArray[_SCT_fc]: ...
def qspline1d(signal: npt.NDArray[_SCT_fc], lamb: AnyReal = 0.0) -> npt.NDArray[_SCT_fc]: ...
def cspline1d_eval(
cj: npt.NDArray[_SCT_fc],
newx: _ArrayLikeFloat_co,
dx: AnyReal = 1.0,
x0: AnyInt = 0,
) -> npt.NDArray[_SCT_fc]: ...
def qspline1d_eval(
cj: npt.NDArray[_SCT_fc],
newx: _ArrayLikeFloat_co,
dx: AnyReal = 1.0,
x0: AnyInt = 0,
) -> npt.NDArray[_SCT_fc]: ...
58 changes: 47 additions & 11 deletions scipy-stubs/signal/_czt.pyi
Original file line number Diff line number Diff line change
@@ -1,17 +1,53 @@
from scipy._typing import Untyped
from scipy.fft import fft as fft, ifft as ifft, next_fast_len as next_fast_len
from collections.abc import Sequence

def czt_points(m, w: Untyped | None = None, a: complex = ...) -> Untyped: ...
import numpy as np
import numpy.typing as npt
from numpy._typing import _ArrayLikeComplex_co
from scipy._typing import AnyComplex, AnyReal

__all__ = ["CZT", "ZoomFFT", "czt", "czt_points", "zoom_fft"]

class CZT:
def __init__(self, n, m: Untyped | None = None, w: Untyped | None = None, a: complex = ...): ...
def __call__(self, x, *, axis: int = -1) -> Untyped: ...
def points(self) -> Untyped: ...
def __init__(self, n: int, m: int | None = None, w: AnyComplex | None = None, a: AnyComplex = 1 + 0j) -> None: ...
def __call__(self, x: _ArrayLikeComplex_co, *, axis: int = -1) -> npt.NDArray[np.complex128 | np.complex64]: ...
def points(self) -> npt.NDArray[np.complex128 | np.complex64]: ...

class ZoomFFT(CZT):
w: Untyped
a: Untyped
def __init__(self, n, fn, m: Untyped | None = None, *, fs: int = 2, endpoint: bool = False): ...
w: complex
a: complex

m: int
n: int

f1: AnyReal
f2: AnyReal
fs: AnyReal

def __init__(
self,
n: int,
fn: Sequence[AnyReal] | AnyReal,
m: int | None = None,
*,
fs: AnyReal = 2,
endpoint: bool = False,
) -> None: ...

def czt(x, m: Untyped | None = None, w: Untyped | None = None, a: complex = ..., *, axis: int = -1) -> Untyped: ...
def zoom_fft(x, fn, m: Untyped | None = None, *, fs: int = 2, endpoint: bool = False, axis: int = -1) -> Untyped: ...
def czt_points(m: int, w: AnyComplex | None = None, a: AnyComplex = ...) -> npt.NDArray[np.complex128 | np.complex64]: ...
def czt(
x: _ArrayLikeComplex_co,
m: int | None = None,
w: AnyComplex | None = None,
a: AnyComplex = 1 + 0j,
*,
axis: int = -1,
) -> npt.NDArray[np.complex128 | np.complex64]: ...
def zoom_fft(
x: _ArrayLikeComplex_co,
fn: Sequence[AnyReal] | AnyReal,
m: int | None = None,
*,
fs: int = 2,
endpoint: bool = False,
axis: int = -1,
) -> npt.NDArray[np.float64 | np.float32 | np.complex128 | np.complex64]: ...
Loading

0 comments on commit e5f1226

Please sign in to comment.