Skip to content

Commit

Permalink
Fix compatibility with scipy >= 1.13
Browse files Browse the repository at this point in the history
  • Loading branch information
avalentino committed Sep 13, 2024
1 parent a9d95eb commit 6cfe8e2
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion docs/example.rst
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ resampy allows you to control the design of the filters used in resampling opera
x, sr_orig = librosa.load(librosa.ex('trumpet'), sr=None, mono=False)
# Resample to 22050Hz using a Hann-windowed sinc-filter
y = resampy.resample(x, sr_orig, sr_new, filter='sinc_window', window=scipy.signal.hann)
y = resampy.resample(x, sr_orig, sr_new, filter='sinc_window', window=scipy.signal.windows.hann)
# Or a shorter sinc-filter than the default (num_zeros=64)
y = resampy.resample(x, sr_orig, sr_new, filter='sinc_window', num_zeros=32)
Expand Down
2 changes: 1 addition & 1 deletion resampy/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def resample(
>>> # Resample using a Hann-windowed sinc filter
>>> import scipy.signal
>>> resampy.resample(x, sr_orig, 22050, filter='sinc_window',
... window=scipy.signal.hann)
... window=scipy.signal.windows.hann)
array([ 0.011, 0.123, 0.25 , ..., -0.366, -0.25 , -0.123])
>>> # Generate stereo data
Expand Down
4 changes: 2 additions & 2 deletions resampy/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def sinc_window(num_zeros=64, precision=9, window=None, rolloff=0.945):
>>> # A filter with 10 zero-crossings, 32 samples per crossing, and a
>>> # Hann window for tapering.
>>> halfwin, prec, rolloff = resampy.filters.sinc_window(num_zeros=10, precision=5,
... window=scipy.signal.hann)
... window=scipy.signal.windows.hann)
>>> halfwin
array([ 9.450e-01, 9.436e-01, ..., -7.455e-07, -0.000e+00])
>>> prec
Expand All @@ -111,7 +111,7 @@ def sinc_window(num_zeros=64, precision=9, window=None, rolloff=0.945):
>>> # Or using sinc-window filter construction directly in resample
>>> y = resampy.resample(x, sr_orig, sr_new, filter='sinc_window',
... num_zeros=10, precision=5,
... window=scipy.signal.hann) # doctest: +SKIP
... window=scipy.signal.windows.hann) # doctest: +SKIP
'''

if window is None:
Expand Down
4 changes: 2 additions & 2 deletions scripts/create_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def parse_arguments(args):

def get_window(beta=None, rolloff=None, num_zeros=None):
"""Build the full window from a specification"""
win = functools.partial(scipy.signal.kaiser, beta=beta)
win = functools.partial(scipy.signal.windows.kaiser, beta=beta)
fil = resampy.filters.sinc_window(
num_zeros=num_zeros, precision=1, window=win, rolloff=rolloff
)[0]
Expand Down Expand Up @@ -157,7 +157,7 @@ def objective(trial, num_zeros, min_beta, max_beta, min_rolloff, attenuation):
print("-" * 40)
print(f"Objective value: {study.best_value:g}")

window = functools.partial(scipy.signal.kaiser, beta=study.best_params["beta"])
window = functools.partial(scipy.signal.windows.kaiser, beta=study.best_params["beta"])
half_win, precision, roll = resampy.filters.sinc_window(
num_zeros=params.num_zeros,
precision=params.precision,
Expand Down

0 comments on commit 6cfe8e2

Please sign in to comment.