-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Add initial implementation of resampy library #15341
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
Open
hunterhogan
wants to merge
26
commits into
python:main
Choose a base branch
from
hunterhogan:resampy
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+76
−0
Open
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
0fb9f63
Add initial stubs for resampy including core functionality and metadata
hunterhogan 547b4c4
Merge branch 'main' of https://github.com/python/typeshed into resampy
hunterhogan c910ff9
METADATA: add requires
hunterhogan 4f8383c
Update stubs/resampy/METADATA.toml
hunterhogan 3b0c8f8
Update stubs/resampy/resampy/version.pyi
hunterhogan 2801ee4
Update stubs/resampy/resampy/__init__.pyi
hunterhogan 541d8e8
Update stubs/resampy/resampy/filters.pyi
hunterhogan 52b6063
Update stubs/resampy/resampy/interpn.pyi
hunterhogan a6ecd3c
Update stubs/resampy/resampy/interpn.pyi
hunterhogan d0405af
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] e1c3fd0
Create stubtest_allowlist.txt
hunterhogan 1f86e17
Update stubs/resampy/resampy/core.pyi
hunterhogan e6c29a6
Update stubs/resampy/resampy/filters.pyi
hunterhogan 930e971
Update stubs/resampy/resampy/interpn.pyi
hunterhogan 7158cef
Update stubs/resampy/resampy/interpn.pyi
hunterhogan 48f3996
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] bbbbbd5
Update stubs/resampy/resampy/interpn.pyi
hunterhogan 5796fde
Better filter typing. Real kwargs types.
hunterhogan 84782b7
Remove internal API: `_resample_loop`.
hunterhogan f308524
Remove internal API.
hunterhogan 33ff8f9
Update stubs/resampy/@tests/stubtest_allowlist.txt
hunterhogan 6f07d59
Delete internal API file.
hunterhogan 75f0d8e
Update stubs/resampy/resampy/core.pyi
hunterhogan 3165fa5
Update stubs/resampy/resampy/core.pyi
hunterhogan b78f101
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] fa83b83
Refactor resample and resample_nu functions to use default parameter …
hunterhogan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| # Part of internal API which is not needed for public type stubs: | ||
| resampy.interpn |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| version = "0.4.*" | ||
| upstream_repository = "https://github.com/bmcfee/resampy" | ||
| # Requires a version of numpy with a `py.typed` file | ||
| requires = ["numpy>=1.20"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| from . import filters as filters | ||
| from .core import * | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| 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]]]) | ||
|
|
||
| # np.floating[Any] because precision is not important | ||
|
|
||
| _FilterType: TypeAlias = str | Callable[[int], np.ndarray[tuple[int], np.dtype[np.float64]]] | ||
|
|
||
| def resample( | ||
| x: _FloatArray, | ||
| sr_orig: float, | ||
| sr_new: float, | ||
| axis: int = -1, | ||
| filter: _FilterType = "kaiser_best", | ||
| parallel: bool = False, | ||
| *, | ||
| num_zeros: int = 64, | ||
| precision: int = 9, | ||
| rolloff: float = 0.945, | ||
| ) -> _FloatArray: ... | ||
| def resample_nu( | ||
| x: _FloatArray, | ||
| sr_orig: float, | ||
| t_out: _FloatArray, | ||
| axis: int = -1, | ||
| filter: _FilterType = "kaiser_best", | ||
| parallel: bool = False, | ||
| *, | ||
| num_zeros: int = 64, | ||
| precision: int = 9, | ||
| rolloff: float = 0.945, | ||
| ) -> _FloatArray: ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| from collections.abc import Callable | ||
| from typing_extensions import TypeAlias | ||
|
|
||
| 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.float64]], int, float]] | ||
|
|
||
| # List of filter functions available | ||
| FILTER_FUNCTIONS: list[str] | ||
|
|
||
| _FilterType: TypeAlias = str | Callable[[int], np.ndarray[tuple[int], np.dtype[np.float64]]] | ||
|
|
||
| def sinc_window( | ||
| num_zeros: int = 64, | ||
| precision: int = 9, | ||
| window: Callable[[int], np.ndarray[tuple[int], np.dtype[np.float64]]] | None = None, | ||
| rolloff: float = 0.945, | ||
| ) -> tuple[np.ndarray[tuple[int], np.dtype[np.float64]], int, float]: ... | ||
| def get_filter( | ||
| name_or_function: _FilterType, *, num_zeros: int = 64, precision: int = 9, rolloff: float = 0.945 | ||
| ) -> tuple[np.ndarray[tuple[int], np.dtype[np.float64]], int, float]: ... | ||
| def load_filter(filter_name: str) -> tuple[np.ndarray[tuple[int], np.dtype[np.float64]], int, float]: ... | ||
| def clear_cache() -> None: ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| from typing import Final | ||
|
|
||
| short_version: Final[str] | ||
| version: Final[str] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.