Skip to content
Open
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
3 changes: 3 additions & 0 deletions stubs/resampy/METADATA.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
version = "0.4.*"
upstream_repository = "https://github.com/bmcfee/resampy"
requires = ["numba", "numpy"]
2 changes: 2 additions & 0 deletions stubs/resampy/resampy/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import filters as filters
from .core import *
29 changes: 29 additions & 0 deletions stubs/resampy/resampy/core.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from collections.abc import Callable
from typing import Any
from typing_extensions import TypeAlias, TypeVar

import numpy as np

__all__ = ["resample", "resample_nu"]

_FloatArray = TypeVar("_FloatArray", bound=np.ndarray[tuple[int, ...], np.dtype[np.floating[Any]]])
_FilterType: TypeAlias = str | Callable[..., tuple[np.ndarray[tuple[int, ...], np.dtype[np.floating[Any]]], int, float]]

def resample(
x: _FloatArray,
sr_orig: float,
sr_new: float,
axis: int = -1,
filter: _FilterType = "kaiser_best",
parallel: bool = False,
**kwargs: Any,
) -> _FloatArray: ...
def resample_nu(
x: _FloatArray,
sr_orig: float,
t_out: _FloatArray,
axis: int = -1,
filter: _FilterType = "kaiser_best",
parallel: bool = False,
**kwargs: Any,
) -> _FloatArray: ...
25 changes: 25 additions & 0 deletions stubs/resampy/resampy/filters.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from collections.abc import Callable
from typing import Any

import numpy as np

__all__ = ["get_filter", "clear_cache", "sinc_window"]

# Dictionary to cache loaded filters
FILTER_CACHE: dict[str, tuple[np.ndarray[tuple[int, ...], np.dtype[np.floating[Any]]], int, float]] = {}

# List of filter functions available
FILTER_FUNCTIONS: list[str] = ["sinc_window"]

def sinc_window(
num_zeros: int = 64,
precision: int = 9,
window: Callable[..., np.ndarray[tuple[int, ...], np.dtype[np.floating[Any]]]] | None = None,
rolloff: float = 0.945,
) -> tuple[np.ndarray[tuple[int, ...], np.dtype[np.floating[Any]]], int, float]: ...
def get_filter(
name_or_function: str | Callable[..., tuple[np.ndarray[tuple[int, ...], np.dtype[np.floating[Any]]], int, float]],
**kwargs: Any,
) -> tuple[np.ndarray[tuple[int, ...], np.dtype[np.floating[Any]]], int, float]: ...
def load_filter(filter_name: str) -> tuple[np.ndarray[tuple[int, ...], np.dtype[np.floating[Any]]], int, float]: ...
def clear_cache() -> None: ...
66 changes: 66 additions & 0 deletions stubs/resampy/resampy/interpn.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
from typing import Any

import numba

Check failure on line 3 in stubs/resampy/resampy/interpn.pyi

View workflow job for this annotation

GitHub Actions / pyright: Run test cases (Linux, 3.13)

Stub file not found for "numba" (reportMissingTypeStubs)
import numpy as np
from numba import guvectorize

Check failure on line 5 in stubs/resampy/resampy/interpn.pyi

View workflow job for this annotation

GitHub Actions / pyright: Run test cases (Linux, 3.13)

Stub file not found for "numba" (reportMissingTypeStubs)

def _resample_loop(
x: np.ndarray[tuple[int, ...], np.dtype[np.floating[Any]]],
t_out: np.ndarray[tuple[int, ...], np.dtype[np.floating[Any]]],
interp_win: np.ndarray[tuple[int, ...], np.dtype[np.floating[Any]]],
interp_delta: np.ndarray[tuple[int, ...], np.dtype[np.floating[Any]]],
num_table: int,
scale: float,
y: np.ndarray[tuple[int, ...], np.dtype[np.floating[Any]]],
) -> None: ...

# JIT-compiled parallel version of _resample_loop
_resample_loop_p = ...

# JIT-compiled sequential version of _resample_loop
_resample_loop_s = ...

@guvectorize(
(
numba.float32[:, :, :],
numba.float32[:, :],
numba.float32[:],
numba.float32[:],
numba.int32,
numba.float32,
numba.float32[:, :],
),
"(n),(m),(p),(p),(),()->(m)",
nopython=True,
)
def resample_f_p(
x: np.ndarray[tuple[int, ...], np.dtype[np.floating[Any]]],
t_out: np.ndarray[tuple[int, ...], np.dtype[np.floating[Any]]],
interp_win: np.ndarray[tuple[int, ...], np.dtype[np.floating[Any]]],
interp_delta: np.ndarray[tuple[int, ...], np.dtype[np.floating[Any]]],
num_table: int,
scale: float,
y: np.ndarray[tuple[int, ...], np.dtype[np.floating[Any]]],
) -> None: ...
@guvectorize(
(
numba.float32[:, :, :],
numba.float32[:, :],
numba.float32[:],
numba.float32[:],
numba.int32,
numba.float32,
numba.float32[:, :],
),
"(n),(m),(p),(p),(),()->(m)",
nopython=True,
)
def resample_f_s(
x: np.ndarray[tuple[int, ...], np.dtype[np.floating[Any]]],
t_out: np.ndarray[tuple[int, ...], np.dtype[np.floating[Any]]],
interp_win: np.ndarray[tuple[int, ...], np.dtype[np.floating[Any]]],
interp_delta: np.ndarray[tuple[int, ...], np.dtype[np.floating[Any]]],
num_table: int,
scale: float,
y: np.ndarray[tuple[int, ...], np.dtype[np.floating[Any]]],
) -> None: ...
2 changes: 2 additions & 0 deletions stubs/resampy/resampy/version.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
short_version: str
version: str
Loading