Skip to content

Commit a1c4ca3

Browse files
authored
[resampy] Add stubs for resampy 0.4.3 (#15341)
1 parent bfb7342 commit a1c4ca3

File tree

6 files changed

+74
-0
lines changed

6 files changed

+74
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Part of internal API which is not needed for public type stubs:
2+
resampy.interpn

stubs/resampy/METADATA.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
version = "0.4.*"
2+
upstream_repository = "https://github.com/bmcfee/resampy"
3+
# Requires a version of numpy with a `py.typed` file
4+
requires = ["numpy>=1.20"]

stubs/resampy/resampy/__init__.pyi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from . import filters as filters
2+
from .core import *

stubs/resampy/resampy/core.pyi

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
from collections.abc import Callable
2+
from typing import Any
3+
from typing_extensions import TypeAlias, TypeVar
4+
5+
import numpy as np
6+
7+
__all__ = ["resample", "resample_nu"]
8+
9+
# np.floating[Any] because precision is not important
10+
_FloatArray = TypeVar("_FloatArray", bound=np.ndarray[tuple[int, ...], np.dtype[np.floating[Any]]])
11+
_FilterType: TypeAlias = str | Callable[[int], np.ndarray[tuple[int], np.dtype[np.float64]]]
12+
13+
def resample(
14+
x: _FloatArray,
15+
sr_orig: float,
16+
sr_new: float,
17+
axis: int = -1,
18+
filter: _FilterType = "kaiser_best",
19+
parallel: bool = False,
20+
*,
21+
num_zeros: int = 64,
22+
precision: int = 9,
23+
rolloff: float = 0.945,
24+
) -> _FloatArray: ...
25+
def resample_nu(
26+
x: _FloatArray,
27+
sr_orig: float,
28+
t_out: _FloatArray,
29+
axis: int = -1,
30+
filter: _FilterType = "kaiser_best",
31+
parallel: bool = False,
32+
*,
33+
num_zeros: int = 64,
34+
precision: int = 9,
35+
rolloff: float = 0.945,
36+
) -> _FloatArray: ...

stubs/resampy/resampy/filters.pyi

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
from collections.abc import Callable
2+
from typing_extensions import TypeAlias
3+
4+
import numpy as np
5+
6+
__all__ = ["get_filter", "clear_cache", "sinc_window"]
7+
8+
# Dictionary to cache loaded filters
9+
FILTER_CACHE: dict[str, tuple[np.ndarray[tuple[int], np.dtype[np.float64]], int, float]]
10+
11+
# List of filter functions available
12+
FILTER_FUNCTIONS: list[str]
13+
14+
_FilterType: TypeAlias = str | Callable[[int], np.ndarray[tuple[int], np.dtype[np.float64]]]
15+
16+
def sinc_window(
17+
num_zeros: int = 64,
18+
precision: int = 9,
19+
window: Callable[[int], np.ndarray[tuple[int], np.dtype[np.float64]]] | None = None,
20+
rolloff: float = 0.945,
21+
) -> tuple[np.ndarray[tuple[int], np.dtype[np.float64]], int, float]: ...
22+
def get_filter(
23+
name_or_function: _FilterType, *, num_zeros: int = 64, precision: int = 9, rolloff: float = 0.945
24+
) -> tuple[np.ndarray[tuple[int], np.dtype[np.float64]], int, float]: ...
25+
def load_filter(filter_name: str) -> tuple[np.ndarray[tuple[int], np.dtype[np.float64]], int, float]: ...
26+
def clear_cache() -> None: ...

stubs/resampy/resampy/version.pyi

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from typing import Final
2+
3+
short_version: Final[str]
4+
version: Final[str]

0 commit comments

Comments
 (0)