Skip to content
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

Fix sample rate type annotations #1789

Merged
merged 4 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/glossary.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ Glossary
corresponds to amplitude of the waveform at sample `t`.

sampling rate
The (positive integer) number of samples per second of a time series.
This is denoted by an integer variable `sr`.
The number of samples per second of a time series.
This is denoted by a positive number `sr`.

frame
A short slice of a :term:`time series` used for analysis purposes. This
Expand Down
2 changes: 1 addition & 1 deletion librosa/core/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def load(
duration: Optional[float] = None,
dtype: DTypeLike = np.float32,
res_type: str = "soxr_hq",
) -> Tuple[np.ndarray, float]:
) -> Tuple[np.ndarray, Union[int, float]]:
"""Load an audio file as a floating point time series.

Audio will be automatically resampled to the given rate
Expand Down
8 changes: 4 additions & 4 deletions librosa/core/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -600,14 +600,14 @@ def blocks_to_samples(

@overload
def blocks_to_time(
blocks: _IntLike_co, *, block_length: int, hop_length: int, sr: int
blocks: _IntLike_co, *, block_length: int, hop_length: int, sr: float
) -> np.floating[Any]:
...


@overload
def blocks_to_time(
blocks: _SequenceLike[_IntLike_co], *, block_length: int, hop_length: int, sr: int
blocks: _SequenceLike[_IntLike_co], *, block_length: int, hop_length: int, sr: float
) -> np.ndarray:
...

Expand All @@ -618,7 +618,7 @@ def blocks_to_time(
*,
block_length: int,
hop_length: int,
sr: int,
sr: float,
) -> Union[np.floating[Any], np.ndarray]:
...

Expand All @@ -628,7 +628,7 @@ def blocks_to_time(
*,
block_length: int,
hop_length: int,
sr: int,
sr: float,
) -> Union[np.floating[Any], np.ndarray]:
"""Convert block indices to time (in seconds)

Expand Down