Skip to content

Commit 1f055f1

Browse files
committed
Merge pull request librosa#327 from bmcfee/warning-cleanup
[wip] various cleanup and warning avoidance
2 parents 73b50d3 + a33d069 commit 1f055f1

File tree

6 files changed

+11
-10
lines changed

6 files changed

+11
-10
lines changed

librosa/core/audio.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ def autocorrelate(y, max_size=None, axis=-1):
423423
autocorr = fft.ifft(powspec, axis=axis, overwrite_x=True)
424424

425425
# Slice down to max_size
426-
subslice = [Ellipsis] * autocorr.ndim
426+
subslice = [slice(None)] * autocorr.ndim
427427
subslice[axis] = slice(max_size)
428428

429429
autocorr = autocorr[subslice]

librosa/segment.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ def recurrence_to_lag(rec, pad=True, axis=-1):
272272
else:
273273
lag = rec.copy()
274274

275-
idx_slice = [Ellipsis] * lag.ndim
275+
idx_slice = [slice(None)] * lag.ndim
276276
for i in range(1, t):
277277
idx_slice[axis] = i
278278
lag[idx_slice] = np.roll(lag[idx_slice], -i)
@@ -342,12 +342,12 @@ def lag_to_recurrence(lag, axis=-1):
342342
t = lag.shape[axis]
343343
lag = lag.copy()
344344

345-
idx_slice = [Ellipsis] * lag.ndim
345+
idx_slice = [slice(None)] * lag.ndim
346346
for i in range(1, t):
347347
idx_slice[axis] = i
348348
lag[idx_slice] = np.roll(lag[idx_slice], i)
349349

350-
sub_slice = [Ellipsis] * lag.ndim
350+
sub_slice = [slice(None)] * lag.ndim
351351
sub_slice[1 - axis] = slice(t)
352352
return np.ascontiguousarray(lag[sub_slice].T).T
353353

@@ -510,7 +510,7 @@ def subsegment(data, frames, n_segments=4, axis=-1):
510510
raise ParameterError('n_segments must be a positive integer')
511511

512512
boundaries = []
513-
idx_slices = [Ellipsis] * data.ndim
513+
idx_slices = [slice(None)] * data.ndim
514514

515515
for seg_start, seg_end in zip(frames[:-1], frames[1:]):
516516
idx_slices[axis] = slice(seg_start, seg_end)

tests/test_core.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ def __test_spec(filename, sr, duration, n_fft, hop_length, center):
436436
yield __test_audio, test_file, mono, sr, duration
437437

438438
for n_fft in [256, 512, 1024]:
439-
for hop_length in [n_fft / 8, n_fft / 4, n_fft / 2]:
439+
for hop_length in [n_fft // 8, n_fft // 4, n_fft // 2]:
440440
for center in [False, True]:
441441
yield (__test_spec, test_file, sr,
442442
duration, n_fft, hop_length, center)
@@ -448,7 +448,7 @@ def __test(y, truth, max_size, axis):
448448

449449
ac = librosa.autocorrelate(y, max_size=max_size, axis=axis)
450450

451-
my_slice = [Ellipsis] * truth.ndim
451+
my_slice = [slice(None)] * truth.ndim
452452
if max_size is not None and max_size <= y.shape[axis]:
453453
my_slice[axis] = slice(min(max_size, y.shape[axis]))
454454

@@ -772,7 +772,7 @@ def __test(times, frames, sr, hop_length, click_freq, click_duration, click, len
772772
for hop_length in [512, 1024]:
773773
test_frames = librosa.time_to_frames(test_times, sr=sr, hop_length=hop_length)
774774

775-
for click in [None, np.ones(sr * 0.1)]:
775+
for click in [None, np.ones(sr // 10)]:
776776

777777
for length in [None, 5 * sr, 15 * sr]:
778778
yield __test, test_times, None, sr, hop_length, 1000, 0.1, click, length

tests/test_failures.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def test_istft_bad_window():
122122

123123
n_fft = 2 * (D.shape[0] - 1)
124124

125-
window = np.ones(n_fft / 2)
125+
window = np.ones(n_fft // 2)
126126

127127
librosa.istft(D, window=window)
128128

tests/test_features.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ def __test_peaks(tempo, win_length, window, norm):
546546
eq_(tempogram.shape[1], len(odf))
547547

548548
# Mean over time to wash over the boundary padding effects
549-
idx = np.where(librosa.localmax(tempogram.max(axis=1)))[0]
549+
idx = np.where(librosa.util.localmax(tempogram.max(axis=1)))[0]
550550

551551
# Indices should all be non-zero integer multiples of spacing
552552
assert np.allclose(idx, spacing * np.arange(1, 1 + len(idx)))

tests/test_filters.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ def __test(n, window):
156156
wdec = librosa.filters.__float_window(window)
157157

158158
if n == int(n):
159+
n = int(n)
159160
assert np.allclose(wdec(n), window(n))
160161
else:
161162
wf = wdec(n)

0 commit comments

Comments
 (0)