From de9b247b426fe361403f8337b252a85706e13a7e Mon Sep 17 00:00:00 2001 From: Pavadol Yamsiri Date: Sun, 3 Nov 2024 22:05:56 +1100 Subject: [PATCH] `signal.windows`: Allow ndarrays for `a` param in `general_cosine`. In `_windows.pyi`. This is because `ndarray` is not a `Sequence`. --- scipy-stubs/signal/windows/_windows.pyi | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/scipy-stubs/signal/windows/_windows.pyi b/scipy-stubs/signal/windows/_windows.pyi index 49825281..1e49dfc7 100644 --- a/scipy-stubs/signal/windows/_windows.pyi +++ b/scipy-stubs/signal/windows/_windows.pyi @@ -1,9 +1,10 @@ from collections.abc import Sequence -from typing import Literal, TypeAlias, overload +from typing import Any, Literal, TypeAlias, overload from typing_extensions import Unpack import numpy as np import optype as op +import optype.numpy as onpt from scipy._typing import AnyInt, AnyReal __all__ = [ @@ -37,6 +38,12 @@ __all__ = [ _Array_f8_1d: TypeAlias = np.ndarray[tuple[int], np.dtype[np.float64]] _Array_f8_2d: TypeAlias = np.ndarray[tuple[int, int], np.dtype[np.float64]] +_Weights: TypeAlias = ( + Sequence[AnyReal] + | np.ndarray[tuple[int], np.dtype[np.floating[Any]]] + | np.ndarray[tuple[int], np.dtype[np.integer[Any]]] + | np.ndarray[tuple[int], np.dtype[np.bool_]] +) _Norm: TypeAlias = Literal[2, "approximate", "subsample"] _WindowLength: TypeAlias = int | np.int16 | np.int32 | np.int64 @@ -111,7 +118,7 @@ _WindowNeedsParams: TypeAlias = Literal[ "kbd", ] -def general_cosine(M: _WindowLength, a: Sequence[AnyReal], sym: op.CanBool = True) -> _Array_f8_1d: ... +def general_cosine(M: _WindowLength, a: _Weights, sym: op.CanBool = True) -> _Array_f8_1d: ... def boxcar(M: _WindowLength, sym: op.CanBool = True) -> _Array_f8_1d: ... def triang(M: _WindowLength, sym: op.CanBool = True) -> _Array_f8_1d: ... def parzen(M: _WindowLength, sym: op.CanBool = True) -> _Array_f8_1d: ...