Skip to content

Commit fa83b83

Browse files
committed
Refactor resample and resample_nu functions to use default parameter values for num_zeros, precision, and rolloff
1 parent b78f101 commit fa83b83

2 files changed

Lines changed: 14 additions & 15 deletions

File tree

stubs/resampy/resampy/core.pyi

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
from collections.abc import Callable
2-
from typing_extensions import TypeAlias, TypeVar, Unpack
2+
from typing import Any
3+
from typing_extensions import TypeAlias, TypeVar
34

45
import numpy as np
56

67
__all__ = ["resample", "resample_nu"]
78

8-
_FloatArray = TypeVar("_FloatArray", bound=np.ndarray[tuple[int, ...], np.dtype[np.floating]])
9+
_FloatArray = TypeVar("_FloatArray", bound=np.ndarray[tuple[int, ...], np.dtype[np.floating[Any]]])
10+
11+
# np.floating[Any] because precision is not important
912

1013
_FilterType: TypeAlias = str | Callable[[int], np.ndarray[tuple[int], np.dtype[np.float64]]]
1114

@@ -17,9 +20,9 @@ def resample(
1720
filter: _FilterType = "kaiser_best",
1821
parallel: bool = False,
1922
*,
20-
num_zeros: int = ...,
21-
precision: int = ...,
22-
rolloff: float = ...,
23+
num_zeros: int = 64,
24+
precision: int = 9,
25+
rolloff: float = 0.945,
2326
) -> _FloatArray: ...
2427
def resample_nu(
2528
x: _FloatArray,
@@ -28,5 +31,8 @@ def resample_nu(
2831
axis: int = -1,
2932
filter: _FilterType = "kaiser_best",
3033
parallel: bool = False,
31-
**kwargs: Unpack[_FilterKwArgs],
34+
*,
35+
num_zeros: int = 64,
36+
precision: int = 9,
37+
rolloff: float = 0.945,
3238
) -> _FloatArray: ...

stubs/resampy/resampy/filters.pyi

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from collections.abc import Callable
2-
from typing import TypedDict, type_check_only
3-
from typing_extensions import TypeAlias, Unpack
2+
from typing_extensions import TypeAlias
43

54
import numpy as np
65

@@ -14,20 +13,14 @@ FILTER_FUNCTIONS: list[str]
1413

1514
_FilterType: TypeAlias = str | Callable[[int], np.ndarray[tuple[int], np.dtype[np.float64]]]
1615

17-
@type_check_only
18-
class _FilterKwArgs(TypedDict, total=False):
19-
num_zeros: int
20-
precision: int
21-
rolloff: float
22-
2316
def sinc_window(
2417
num_zeros: int = 64,
2518
precision: int = 9,
2619
window: Callable[[int], np.ndarray[tuple[int], np.dtype[np.float64]]] | None = None,
2720
rolloff: float = 0.945,
2821
) -> tuple[np.ndarray[tuple[int], np.dtype[np.float64]], int, float]: ...
2922
def get_filter(
30-
name_or_function: _FilterType, **kwargs: Unpack[_FilterKwArgs]
23+
name_or_function: _FilterType, *, num_zeros: int = 64, precision: int = 9, rolloff: float = 0.945
3124
) -> tuple[np.ndarray[tuple[int], np.dtype[np.float64]], int, float]: ...
3225
def load_filter(filter_name: str) -> tuple[np.ndarray[tuple[int], np.dtype[np.float64]], int, float]: ...
3326
def clear_cache() -> None: ...

0 commit comments

Comments
 (0)