python-librosa/update-tests-for-numpy-123.patch

67 lines
2.2 KiB
Diff

From 5dd212036667a524cf29480d5351ee5e5eca5693 Mon Sep 17 00:00:00 2001
From: Brian McFee <brian.mcfee@nyu.edu>
Date: Mon, 26 Sep 2022 13:26:26 -0400
Subject: [PATCH] updated tests for numpy 1.23 compatibility
---
tests/test_core.py | 2 ++
tests/test_multichannel.py | 6 +++---
tests/test_util.py | 6 +++---
3 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/tests/test_core.py b/tests/test_core.py
index 57c3458aee..d83f5b6e5a 100644
--- a/tests/test_core.py
+++ b/tests/test_core.py
@@ -2122,6 +2122,8 @@ def test_pcen_stream_multi(axis):
slice2 = [slice(None)] * x.ndim
slice2[axis] = slice(10, None)
+ slice1 = tuple(slice1)
+ slice2 = tuple(slice2)
# Compute pcen piecewise
p1, zf1 = librosa.pcen(x[slice1], return_zf=True, axis=axis)
p2, zf2 = librosa.pcen(x[slice2], zi=zf1, return_zf=True, axis=axis)
diff --git a/tests/test_multichannel.py b/tests/test_multichannel.py
index 19531842fd..8a0490bd82 100644
--- a/tests/test_multichannel.py
+++ b/tests/test_multichannel.py
@@ -65,13 +65,13 @@ def test_sync_multi(aggregate, ndim, axis):
idx = [slice(None)] * ndim
idx[axis] = 0
if aggregate is np.sum:
- assert np.allclose(dsync[idx], 2)
+ assert np.allclose(dsync[tuple(idx)], 2)
else:
- assert np.allclose(dsync[idx], 1)
+ assert np.allclose(dsync[tuple(idx)], 1)
# The second slice will sum to 1 and have mean 1
idx[axis] = 1
- assert np.allclose(dsync[idx], 1)
+ assert np.allclose(dsync[tuple(idx)], 1)
def test_stft_multi(y_multi):
diff --git a/tests/test_util.py b/tests/test_util.py
index 1b90087611..eebbf432c2 100644
--- a/tests/test_util.py
+++ b/tests/test_util.py
@@ -877,13 +877,13 @@ def test_sync(aggregate, ndim, axis):
idx = [slice(None)] * ndim
idx[axis] = 0
if aggregate is np.sum:
- assert np.allclose(dsync[idx], 2)
+ assert np.allclose(dsync[tuple(idx)], 2)
else:
- assert np.allclose(dsync[idx], 1)
+ assert np.allclose(dsync[tuple(idx)], 1)
# The second slice will sum to 1 and have mean 1
idx[axis] = 1
- assert np.allclose(dsync[idx], 1)
+ assert np.allclose(dsync[tuple(idx)], 1)
@pytest.mark.parametrize("aggregate", [np.mean, np.max])