Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🔧 .mypyignore cleanup #392

Merged
merged 4 commits into from
Jan 1, 2025
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
28 changes: 15 additions & 13 deletions .mypyignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,30 @@ scipy\.stats\._rcont\.rcont
# why is this even included in the wheels?
scipy\.special\._precompute\..*

# omitted methods that always return `NotImplemented` or always raise
# scipy\.sparse\._(\w+)\._(\w+)\.__(len|i(add|mul|sub)|(i|r)(true)?div)__

# workarounds for mypy bugs
scipy\.signal\._short_time_fft\.(FFT_MODE_TYPE|PAD_TYPE) # `Literal[...] != def (*, **)`
scipy\.(_lib|integrate|stats)\.((_|\w)+\.)+__replace__ # `NamedTuple` on `python >= 3.13`

# stubtest doesn't understand `if sys.version_info >= _: ...` blocks
scipy\.sparse\.(\w+)\.warn
scipy\.(_lib|integrate|stats)\.((_|\w)+\.)+__replace__ # `NamedTuple` on `python>=3.13`
scipy\.sparse\.(\w+)\.warn # all `if sys.version_info` branches are checked...?

# annoying and useless __new__
scipy\.stats\.(_new_distributions\.)?Normal\.__new__

# mypy fails recognize type-check-only ufunc subtypes as ufuncs
# https://github.com/KotlinIsland/basedmypy/issues/815
# https://github.com/KotlinIsland/basedmypy/issues/816
scipy\.special\._basic\.digamma
scipy\.special\._support_alternative_backends\..*
scipy\.stats\._qmvnt\.phi(nv)?

# https://github.com/KotlinIsland/basedmypy/issues/815
scipy\.special\._ufuncs\._(hypergeom|nbinom|nc(f|t))_(mean|variance|skewness|kurtosis_excess)
scipy\.special\._basic\.digamma
scipy\.special\._support_alternative_backends\.betaincc?
scipy\.special\._support_alternative_backends\.gamma(incc?|ln)
scipy\.special\._support_alternative_backends\.(rel_)?entr
scipy\.special\._support_alternative_backends\.erfc?
scipy\.special\._support_alternative_backends\.(exp|log)it
scipy\.special\._support_alternative_backends\.i(0|1)e?
scipy\.special\._support_alternative_backends\.xlogy
scipy\.special\._support_alternative_backends\.chdtrc?
scipy\.special\._support_alternative_backends\.(log_)?ndtri?
scipy\.special\._support_alternative_backends\.stdtr
scipy\.special\._ufuncs\._(hypergeom|n?binom)_(pm|cd|pp|i?s)f
scipy\.special\._ufuncs\._(hypergeom|nbinom|nc(f|t))_(mean|variance|skewness|kurtosis_excess)
scipy\.special\._ufuncs\._(beta|cauchy|invgauss|landau|nc(f|t|x2)|skewnorm)_(pd|cd|pp|i?s)f
scipy\.special\._ufuncs\._cosine_(inv)?cdf
scipy\.special\._ufuncs\._(cos|sin)pi
Expand Down
212 changes: 116 additions & 96 deletions scipy-stubs/signal/_short_time_fft.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@ from .windows._windows import _ToWindow

__all__ = ["ShortTimeFFT"]

###

_InexactND: TypeAlias = onp.ArrayND[np.inexact[Any]]

_PadType: TypeAlias = Literal["zeros", "edge", "even", "odd"]
_FFTModeType: TypeAlias = Literal["twosided", "centered", "onesided", "onesided2X"]
_ScaleTo: TypeAlias = Literal["magnitude", "psd"]
_Detr: TypeAlias = (
Literal["linear", "constant"]
Expand All @@ -19,77 +23,100 @@ _Detr: TypeAlias = (

###

# awkward naming, but this matches the "attempts at type-aliases" in the implementation
PAD_TYPE: TypeAlias = Literal["zeros", "edge", "even", "odd"]
FFT_MODE_TYPE: TypeAlias = Literal["twosided", "centered", "onesided", "onesided2X"]

class ShortTimeFFT:
def __init__(
self,
/,
win: _InexactND,
hop: int,
fs: float,
*,
fft_mode: FFT_MODE_TYPE = "onesided",
mfft: int | None = None,
dual_win: _InexactND | None = None,
scale_to: _ScaleTo | None = None,
phase_shift: int | None = 0,
) -> None: ...
@classmethod
def from_dual(
cls,
dual_win: _InexactND,
hop: int,
fs: float,
*,
fft_mode: FFT_MODE_TYPE = "onesided",
mfft: int | None = None,
scale_to: _ScaleTo | None = None,
phase_shift: int | None = 0,
) -> Self: ...
@classmethod
def from_window(
cls,
win_param: _ToWindow,
fs: float,
nperseg: int,
noverlap: int,
*,
symmetric_win: bool = False,
fft_mode: FFT_MODE_TYPE = "onesided",
mfft: int | None = None,
scale_to: _ScaleTo | None = None,
phase_shift: int | None = 0,
) -> Self: ...
@property
def win(self, /) -> _InexactND: ...
@property
def dual_win(self, /) -> _InexactND: ...
@property
def hop(self, /) -> int: ...
@property
def invertible(self, /) -> bool: ...
@property
def fac_magnitude(self, /) -> float: ...
@property
def fac_psd(self, /) -> float: ...
@property
def m_num(self, /) -> int: ...
@property
def m_num_mid(self, /) -> int: ...
@property
def k_min(self, /) -> int: ...
@property
def p_min(self, /) -> int: ...
@property
def lower_border_end(self, /) -> tuple[int, int]: ...
@property
def delta_t(self, /) -> float: ...
@property
def delta_f(self, /) -> float: ...
@property
def f_pts(self, /) -> int: ...
@property
def f(self, /) -> _InexactND: ...
@property
def onesided_fft(self, /) -> bool: ...

#
@property
def T(self, /) -> float: ...
@T.setter
def T(self, /, v: float) -> None: ...

#
@property
def fs(self, /) -> float: ...
@fs.setter
def fs(self, /, v: float) -> None: ...

#
@property
def fft_mode(self, /) -> FFT_MODE_TYPE: ...
def fft_mode(self, /) -> _FFTModeType: ...
@fft_mode.setter
def fft_mode(self, /, t: FFT_MODE_TYPE) -> None: ...
def fft_mode(self, /, t: _FFTModeType) -> None: ...

#
@property
def mfft(self, /) -> int: ...
@mfft.setter
def mfft(self, /, n_: int) -> None: ...
@property
def scaling(self, /) -> _ScaleTo | None: ...
def scale_to(self, /, scaling: _ScaleTo) -> None: ...

#
@property
def phase_shift(self, /) -> int | None: ...
@phase_shift.setter
def phase_shift(self, /, v: int | None) -> None: ...

#
@property
def scaling(self, /) -> _ScaleTo | None: ...

#
def __init__(
self,
/,
win: _InexactND,
hop: int,
fs: float,
*,
fft_mode: _FFTModeType = "onesided",
mfft: int | None = None,
dual_win: _InexactND | None = None,
scale_to: _ScaleTo | None = None,
phase_shift: int | None = 0,
) -> None: ...

#
def k_max(self, /, n: int) -> int: ...
def p_max(self, /, n: int) -> int: ...
def p_num(self, /, n: int) -> int: ...
def nearest_k_p(self, /, k: int, left: bool = True) -> int: ...
def upper_border_begin(self, /, n: int) -> tuple[int, int]: ...
def p_range(self, /, n: int, p0: int | None = None, p1: int | None = None) -> tuple[int, int]: ...
def t(self, /, n: int, p0: int | None = None, p1: int | None = None, k_offset: int = 0) -> _InexactND: ...
def scale_to(self, /, scaling: _ScaleTo) -> None: ...

#
def stft(
self,
/,
Expand All @@ -98,9 +125,19 @@ class ShortTimeFFT:
p1: int | None = None,
*,
k_offset: int = 0,
padding: PAD_TYPE = "zeros",
padding: _PadType = "zeros",
axis: int = -1,
) -> _InexactND: ...
def istft(
self,
/,
S: _InexactND,
k0: int = 0,
k1: int | None = None,
*,
f_axis: int = -2,
t_axis: int = -1,
) -> _InexactND: ...
def stft_detrend(
self,
/,
Expand All @@ -110,7 +147,7 @@ class ShortTimeFFT:
p1: int | None = None,
*,
k_offset: int = 0,
padding: PAD_TYPE = "zeros",
padding: _PadType = "zeros",
axis: int = -1,
) -> _InexactND: ...
def spectrogram(
Expand All @@ -123,58 +160,41 @@ class ShortTimeFFT:
p0: int | None = None,
p1: int | None = None,
k_offset: int = 0,
padding: PAD_TYPE = "zeros",
padding: _PadType = "zeros",
axis: int = -1,
) -> _InexactND: ...
@property
def dual_win(self, /) -> _InexactND: ...
@property
def invertible(self, /) -> bool: ...
def istft(
self,
/,
S: _InexactND,
k0: int = 0,
k1: int | None = None,
*,
f_axis: int = -2,
t_axis: int = -1,
) -> _InexactND: ...
@property
def fac_magnitude(self, /) -> float: ...
@property
def fac_psd(self, /) -> float: ...
@property
def m_num(self, /) -> int: ...
@property
def m_num_mid(self, /) -> int: ...
@property
def k_min(self, /) -> int: ...
@property
def p_min(self, /) -> int: ...
def k_max(self, /, n: int) -> int: ...
def p_max(self, /, n: int) -> int: ...
def p_num(self, /, n: int) -> int: ...
@property
def lower_border_end(self, /) -> tuple[int, int]: ...
def upper_border_begin(self, /, n: int) -> tuple[int, int]: ...
@property
def delta_t(self, /) -> float: ...
def p_range(self, /, n: int, p0: int | None = None, p1: int | None = None) -> tuple[int, int]: ...
def t(self, /, n: int, p0: int | None = None, p1: int | None = None, k_offset: int = 0) -> _InexactND: ...
def nearest_k_p(self, /, k: int, left: bool = True) -> int: ...
@property
def delta_f(self, /) -> float: ...
@property
def f_pts(self, /) -> int: ...
@property
def onesided_fft(self, /) -> bool: ...
@property
def f(self, /) -> _InexactND: ...
def extent(
self,
/,
n: int,
axes_seq: Literal["tf", "ft"] = "tf",
center_bins: bool = False,
) -> tuple[float, float, float, float]: ...

#
@classmethod
def from_dual(
cls,
dual_win: _InexactND,
hop: int,
fs: float,
*,
fft_mode: _FFTModeType = "onesided",
mfft: int | None = None,
scale_to: _ScaleTo | None = None,
phase_shift: int | None = 0,
) -> Self: ...
@classmethod
def from_window(
cls,
win_param: _ToWindow,
fs: float,
nperseg: int,
noverlap: int,
*,
symmetric_win: bool = False,
fft_mode: _FFTModeType = "onesided",
mfft: int | None = None,
scale_to: _ScaleTo | None = None,
phase_shift: int | None = 0,
) -> Self: ...
22 changes: 12 additions & 10 deletions scipy-stubs/sparse/base.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# ruff: noqa: ANN401
# This module is not meant for public use and will be removed in SciPy v2.0.0.
from typing import Final

from typing import Any, Final
from typing_extensions import deprecated

from . import _base, _matrix
Expand All @@ -21,7 +23,7 @@ __all__ = [
"validateaxis",
]

MAXPRINT: Final[int]
MAXPRINT: Final[int] = ...

@deprecated("will be removed in SciPy v2.0.0")
class SparseWarning(_base.SparseWarning): ...
Expand All @@ -36,22 +38,22 @@ class SparseEfficiencyWarning(_base.SparseEfficiencyWarning): ...
class spmatrix(_matrix.spmatrix): ...

@deprecated("will be removed in SciPy v2.0.0")
def issparse(x: object) -> object: ...
def issparse(x: object) -> bool: ...
@deprecated("will be removed in SciPy v2.0.0")
def isspmatrix(x: object) -> object: ...
def isspmatrix(x: object) -> bool: ...

# sputils
@deprecated("will be removed in SciPy v2.0.0")
def check_shape(args: object, current_shape: object = ..., *, allow_nd: object = ...) -> object: ...
def check_shape(args: object, current_shape: object = ..., *, allow_nd: object = ...) -> Any: ...
@deprecated("will be removed in SciPy v2.0.0")
def check_reshape_kwargs(kwargs: object) -> object: ...
def check_reshape_kwargs(kwargs: object) -> Any: ...
@deprecated("will be removed in SciPy v2.0.0")
def validateaxis(axis: object) -> None: ...
@deprecated("will be removed in SciPy v2.0.0")
def isdense(x: object) -> object: ...
def isdense(x: object) -> Any: ...
@deprecated("will be removed in SciPy v2.0.0")
def isscalarlike(x: object) -> object: ...
def isscalarlike(x: object) -> Any: ...
@deprecated("will be removed in SciPy v2.0.0")
def get_sum_dtype(dtype: object) -> object: ...
def get_sum_dtype(dtype: object) -> Any: ...
@deprecated("will be removed in SciPy v2.0.0")
def asmatrix(data: object, dtype: object = ...) -> object: ...
def asmatrix(data: object, dtype: object = ...) -> Any: ...
Loading
Loading