python-librosa/skip-test-data-missing-tests.patch
Steve Kowalik 1430ccd07c - Update to 0.9.2:
* Fixed librosa.show_versions to match package dependencies.
  * Fixed a bug in librosa.effects.split when applied to multichannel data.
  * Removed test data from main repository and reduced the git attic.
  * Accept pre-constructed audioread objects in librosa.load.
  * Accelerate librosa.magphase.
  * Nearly full support for multi-channel processing.
  * Option to disable unicode characters in display functions.
  * Significantly expanded the library of example audio clips.
  * The default padding mode for most functions (including STFT) is now
    zero-padding.
  * librosa.load and librosa.stream can now operate directly on open
    soundfile objects.
  * librosa.display.specshow now uses centered coordinate grids.
  * librosa.iirt now exposes API control over resampling modes.
  * Maximum frequency is now correctly inferred as Nyquist in onset strength
    calculation.
  * librosa.effects.deemphasis no longer modifies the input signal in-place.
  * librosa.util.frame now correctly works for arbitrary memory layouts and
    numbers of axes.
  * Corrected a normalization error in inverse CQT.
  * ibrosa.cqt now supports arbitrary hop lengths.
  * Added a run-time check for minimally supported matplotlib versions.
  * Enhanced continuous integration testing for oldest and newest environments.
  * librosa.effects.deemphasis, inverse operation of
    librosa.effects.preemphasis.
  * librosa.display.waveshow, adaptively visualize waveforms by amplitude
    envelope when zoomed out, or raw sample values when zoomed in.
- Add patch remove-contextlib2.patch:
  * No longer require contextlib2.

OBS-URL: https://build.opensuse.org/package/show/devel:languages:python:numeric/python-librosa?expand=0&rev=20
2022-09-20 06:04:27 +00:00

411 lines
13 KiB
Diff

Index: librosa-0.9.2/tests/test_core.py
===================================================================
--- librosa-0.9.2.orig/tests/test_core.py
+++ librosa-0.9.2/tests/test_core.py
@@ -21,7 +21,7 @@ import numpy as np
import scipy.io
import pytest
import warnings
-from unittest import mock
+from unittest import mock, SkipTest
# -- utilities --#
@@ -39,6 +39,11 @@ def srand(seed=628318530):
def load(infile):
return scipy.io.loadmat(infile, chars_as_strings=True)
+def _safe_load(fname, **kwargs):
+ if not os.path.exists(fname):
+ raise SkipTest()
+ return librosa.load(fname, **kwargs)
+
@pytest.mark.parametrize(
"infile", files(os.path.join("tests", "data", "core-load-*.mat"))
@@ -58,6 +63,8 @@ def test_load(infile):
def test_load_soundfile():
fname = os.path.join("tests", "data", "test1_44100.wav")
+ if not os.path.exists(fname):
+ raise SkipTest()
# Load from filename
y, sr = librosa.load(fname, sr=None, mono=False)
@@ -72,7 +79,9 @@ def test_load_soundfile():
def test_load_audioread():
fname = os.path.join("tests", "data", "test1_44100.wav")
-
+ if not os.path.exists(fname):
+ raise SkipTest()
+
# Load using an existing audioread object
reader = audioread.rawread.RawAudioFile(fname)
y, sr = librosa.load(reader, sr=None)
@@ -104,7 +113,7 @@ def test_segment_load():
sample_len = 2003
fs = 44100
test_file = os.path.join("tests", "data", "test1_44100.wav")
- y, sr = librosa.load(
+ y, sr = _safe_load(
test_file, sr=None, mono=False, offset=0.0, duration=sample_len / float(fs)
)
@@ -129,9 +138,10 @@ def test_segment_load():
)
def resample_audio(request):
infile = request.param
- y, sr_in = librosa.load(
- os.path.join("tests", "data", infile), sr=None, duration=5, mono=False
- )
+ file_ = os.path.join("tests", "data", infile)
+ if not os.path.exists(file_):
+ raise SkipTest()
+ y, sr_in = librosa.load(file_, sr=None, duration=5, mono=False)
return (y, sr_in)
@@ -599,7 +609,7 @@ def test_reassigned_spectrogram_paramete
def test_salience_basecase():
- (y, sr) = librosa.load(os.path.join("tests", "data", "test1_22050.wav"))
+ (y, sr) = _safe_load(os.path.join("tests", "data", "test1_22050.wav"))
S = np.abs(librosa.stft(y))
freqs = librosa.core.fft_frequencies(sr=sr)
harms = [1]
@@ -611,7 +621,8 @@ def test_salience_basecase():
def test_salience_basecase2():
- (y, sr) = librosa.load(os.path.join("tests", "data", "test1_22050.wav"))
+ filename = os.path.join("tests", "data", "test1_22050.wav")
+ (y, sr) = _safe_load(filename)
S = np.abs(librosa.stft(y))
freqs = librosa.core.fft_frequencies(sr=sr)
harms = [1, 0.5, 2.0]
@@ -684,13 +695,13 @@ def test_salience_aggregate():
@pytest.fixture(scope="module")
def y_22050():
- y, sr = librosa.load(os.path.join("tests", "data", "test1_22050.wav"))
+ y, sr = _safe_load(os.path.join("tests", "data", "test1_22050.wav"))
return y
@pytest.fixture(scope="module")
def y_44100():
- y, sr = librosa.load(os.path.join("tests", "data", "test1_44100.wav"), sr=None)
+ y, sr = _safe_load(os.path.join("tests", "data", "test1_44100.wav"), sr=None)
return y
@@ -777,7 +788,7 @@ def test_istft_reconstruction(y_chirp_is
"filename", files(os.path.join("tests", "data", "test1_22050.*"))
)
def test_load_options(filename, offset, duration, mono, dtype):
- y, sr = librosa.load(
+ y, sr = _safe_load(
filename, mono=mono, offset=offset, duration=duration, dtype=dtype
)
@@ -827,6 +838,8 @@ def test_get_duration_specgram(sr, dur,
def test_get_duration_filename():
filename = os.path.join("tests", "data", "test2_8000.wav")
+ if not os.path.exists(filename):
+ raise SkipTest
true_duration = 30.197625
duration_fn = librosa.get_duration(filename=filename)
@@ -839,6 +852,8 @@ def test_get_duration_filename():
def test_get_duration_mp3():
filename = os.path.join("tests", "data", "test1_22050.mp3")
+ if not os.path.exists(filename):
+ raise SkipTest()
true_duration = 4.587528344671202
duration_fn = librosa.get_duration(filename=filename)
@@ -999,13 +1014,11 @@ def pip_hop(request, pip_nfft):
def pip_spec(y_22050, pip_nfft, pip_hop):
return np.abs(librosa.stft(y_22050, n_fft=pip_nfft, hop_length=pip_hop))
-
@pytest.mark.parametrize("fmin", [0, 100])
@pytest.mark.parametrize("fmax", [4000, 8000, 11025])
@pytest.mark.parametrize("threshold", [0.1, 0.2, 0.5])
@pytest.mark.parametrize("ref", [None, 1.0, np.max])
def test_piptrack_properties(pip_spec, pip_nfft, pip_hop, fmin, fmax, threshold, ref):
-
n_fft = pip_nfft
hop_length = pip_hop
S = pip_spec
@@ -1061,7 +1074,10 @@ def test_yin_tone(freq):
def test_yin_chirp():
y = librosa.chirp(fmin=220, fmax=640, duration=1.0)
f0 = librosa.yin(y, fmin=110, fmax=880, center=False)
- target_f0 = np.load(os.path.join("tests", "data", "pitch-yin.npy"))
+ filename = os.path.join("tests", "data", "pitch-yin.npy")
+ if not os.path.exists(filename):
+ raise SkipTest()
+ target_f0 = np.load(filename)
assert np.allclose(np.log2(f0), np.log2(target_f0), rtol=0, atol=1e-2)
@@ -1138,7 +1154,10 @@ def test_pyin_chirp():
y = librosa.chirp(fmin=220, fmax=640, duration=1.0)
y = np.pad(y, (22050,))
f0, voiced_flag, _ = librosa.pyin(y, fmin=110, fmax=880, center=False)
- target_f0 = np.load(os.path.join("tests", "data", "pitch-pyin.npy"))
+ filename = os.path.join("tests", "data", "pitch-pyin.npy")
+ if not os.path.exists(filename):
+ raise SkipTest
+ target_f0 = np.load(filename)
# test if correct frames are voiced
assert np.array_equal(voiced_flag, target_f0 > 0)
# test voiced frames are within one cent of the target
@@ -1718,7 +1737,7 @@ def test_iirt():
)["f_cqt"]
# There shouldn't be a load here, but test1_44100 was resampled for this fixture :\
- y, sr = librosa.load(os.path.join("tests", "data", "test1_44100.wav"))
+ y, sr = _safe_load(os.path.join("tests", "data", "test1_44100.wav"))
mut1 = librosa.iirt(y, sr=sr, hop_length=2205, win_length=4410, flayout="ba")
@@ -2137,6 +2156,8 @@ def test_griffinlim_momentum_warn():
def test_get_samplerate(ext):
path = os.path.join("tests", "data", os.path.extsep.join(["test1_22050", ext]))
+ if not os.path.exists(path):
+ raise SkipTest()
sr = librosa.get_samplerate(path)
assert sr == 22050
@@ -2145,6 +2166,8 @@ def test_get_samplerate(ext):
def test_get_samplerate_soundfile():
path = os.path.join("tests", "data", os.path.extsep.join(["test1_22050", "wav"]))
+ if not os.path.exists(path):
+ raise SkipTest()
sfo = soundfile.SoundFile(path)
@@ -2162,9 +2185,13 @@ def path(request):
if request.param == "as_string":
yield path
elif request.param == "as_file":
+ if not os.path.exists(path):
+ raise SkipTest()
with open(path, "rb") as f:
yield f
elif request.param == "as_sfo":
+ if not os.path.exists(path):
+ raise SkipTest()
with soundfile.SoundFile(path) as f:
yield f
@@ -2204,7 +2231,8 @@ def test_stream(
fill_value,
dtype,
):
-
+ if not os.path.exists(path):
+ raise SkipTest()
stream = librosa.stream(
path,
block_length=block_length,
Index: librosa-0.9.2/tests/test_beat.py
===================================================================
--- librosa-0.9.2.orig/tests/test_beat.py
+++ librosa-0.9.2/tests/test_beat.py
@@ -11,6 +11,7 @@ except:
pass
import pytest
+import unittest
from contextlib import nullcontext as dnr
import numpy as np
@@ -24,6 +25,8 @@ __EXAMPLE_FILE = os.path.join("tests", "
@pytest.fixture(scope="module", params=[22050, 44100])
def ysr(request):
+ if not os.path.exists(__EXAMPLE_FILE):
+ raise unittest.SkipTest()
return librosa.load(__EXAMPLE_FILE, sr=request.param)
Index: librosa-0.9.2/tests/test_segment.py
===================================================================
--- librosa-0.9.2.orig/tests/test_segment.py
+++ librosa-0.9.2/tests/test_segment.py
@@ -15,6 +15,7 @@ import numpy as np
import scipy
from scipy.spatial.distance import cdist, pdist, squareform
import pytest
+import unittest
from test_core import srand
@@ -404,6 +405,8 @@ def test_timelag_filter_pos1():
@pytest.fixture(scope="module")
def ysr():
+ if not os.path.exists(__EXAMPLE_FILE):
+ raise unittest.SkipTest()
return librosa.load(__EXAMPLE_FILE)
Index: librosa-0.9.2/tests/test_onset.py
===================================================================
--- librosa-0.9.2.orig/tests/test_onset.py
+++ librosa-0.9.2/tests/test_onset.py
@@ -3,6 +3,7 @@
# unit tests for librosa.onset
import pytest
+from unittest import SkipTest
from contextlib import nullcontext as dnr
# Disable cache
@@ -26,6 +27,8 @@ __EXAMPLE_FILE = os.path.join("tests", "
@pytest.fixture(scope="module")
def ysr():
+ if not os.path.exists(__EXAMPLE_FILE):
+ raise SkipTest()
return librosa.load(__EXAMPLE_FILE)
Index: librosa-0.9.2/tests/test_effects.py
===================================================================
--- librosa-0.9.2.orig/tests/test_effects.py
+++ librosa-0.9.2/tests/test_effects.py
@@ -3,6 +3,7 @@
"""Unit tests for the effects module"""
import warnings
+from unittest import SkipTest
# Disable cache
import os
@@ -22,11 +23,15 @@ __EXAMPLE_FILE = os.path.join("tests", "
@pytest.fixture(scope="module", params=["test1_44100.wav"])
def y_multi(request):
infile = request.param
+ if not os.path.exists(__EXAMPLE_FILE):
+ raise SkipTest()
return librosa.load(os.path.join("tests", "data", infile), sr=None, mono=False)
@pytest.fixture(scope="module", params=[22050, 44100])
def ysr(request):
+ if not os.path.exists(__EXAMPLE_FILE):
+ raise SkipTest()
return librosa.load(__EXAMPLE_FILE, sr=request.param)
Index: librosa-0.9.2/tests/test_decompose.py
===================================================================
--- librosa-0.9.2.orig/tests/test_decompose.py
+++ librosa-0.9.2/tests/test_decompose.py
@@ -4,6 +4,7 @@
# Disable cache
import os
+from unittest import SkipTest
try:
os.environ.pop("LIBROSA_CACHE_DIR")
@@ -100,7 +101,10 @@ def test_sorted_decompose():
@pytest.fixture
def y22050():
- y, _ = librosa.load(os.path.join("tests", "data", "test1_22050.wav"))
+ filename = os.path.join("tests", "data", "test1_22050.wav")
+ if not os.path.exists(filename):
+ raise SkipTest()
+ y, _ = librosa.load(filename)
return y
@@ -199,8 +203,10 @@ def test_nn_filter_mean_rec_sparse():
@pytest.fixture(scope="module")
def s_multi():
- y, sr = librosa.load(os.path.join("tests", "data", "test1_44100.wav"),
- sr=None, mono=False)
+ filename = os.path.join("tests", "data", "test1_44100.wav")
+ if not os.path.exists(filename):
+ raise SkipTest()
+ y, sr = librosa.load(filename, sr=None, mono=False)
return np.abs(librosa.stft(y))
@pytest.mark.parametrize('useR,sparse', [(False, False), (True, False), (True, True)])
Index: librosa-0.9.2/tests/test_multichannel.py
===================================================================
--- librosa-0.9.2.orig/tests/test_multichannel.py
+++ librosa-0.9.2/tests/test_multichannel.py
@@ -17,7 +17,7 @@ import numpy as np
import scipy.io
import pytest
import warnings
-from unittest import mock
+from unittest import mock, SkipTest
from contextlib import nullcontext as dnr
from test_core import srand
@@ -26,7 +26,10 @@ from test_core import srand
@pytest.fixture(scope="module", params=["test1_44100.wav"])
def y_multi(request):
infile = request.param
- return librosa.load(os.path.join("tests", "data", infile), sr=None, mono=False)
+ filename = os.path.join("tests", "data", infile)
+ if not os.path.exists(filename):
+ raise SkipTest()
+ return librosa.load(filename, sr=None, mono=False)
@pytest.fixture(scope="module")
Index: librosa-0.9.2/tests/test_features.py
===================================================================
--- librosa-0.9.2.orig/tests/test_features.py
+++ librosa-0.9.2/tests/test_features.py
@@ -4,6 +4,7 @@
from __future__ import print_function
import warnings
import numpy as np
+from unittest import SkipTest
import pytest
@@ -256,7 +257,10 @@ def test_spectral_rolloff_errors(S, pct)
@pytest.fixture(scope="module")
def y_ex():
- return librosa.load(os.path.join("tests", "data", "test1_22050.wav"))
+ filename = os.path.join("tests", "data", "test1_22050.wav")
+ if not os.path.exists(filename):
+ raise SkipTest()
+ return librosa.load(filename)
def test_spectral_contrast_log(y_ex):
@@ -487,9 +491,10 @@ def test_tonnetz_cqt(y_ex):
def test_tonnetz_msaf():
# Use pre-computed chroma
- tonnetz_chroma = np.load(
- os.path.join("tests", "data", "feature-tonnetz-chroma.npy")
- )
+ filename = os.path.join("tests", "data", "feature-tonnetz-chroma.npy")
+ if not os.path.exists(filename):
+ raise SkipTest()
+ tonnetz_chroma = np.load(filename)
tonnetz_msaf = np.load(os.path.join("tests", "data", "feature-tonnetz-msaf.npy"))
tonnetz = librosa.feature.tonnetz(chroma=tonnetz_chroma)