Skip to content

Commit af20096

Browse files
committed
TST: signal/windows: fix tests
1 parent f0d2090 commit af20096

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

scipy/signal/tests/test_windows.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import numpy as np
44
from numpy import array
5-
from numpy.testing import suppress_warnings
5+
from numpy.testing import suppress_warnings
66
import pytest
77
from pytest import raises as assert_raises
88

@@ -187,9 +187,9 @@ def test_correctness(self, xp):
187187
BW_3dB = 2*np.argmax(spec <= -3.0102999566398121) / N_fft * M_win
188188
BW_18dB = 2*np.argmax(spec <= -18.061799739838872) / N_fft * M_win
189189

190-
xp_assert_close(PSLL, -35.1672, atol=1)
191-
xp_assert_close(BW_3dB, 1.1822, atol=0.1)
192-
xp_assert_close(BW_18dB, 2.6112, atol=0.1)
190+
assert math.isclose(PSLL, -35.1672, abs_tol=1)
191+
assert math.isclose(BW_3dB, 1.1822, abs_tol=0.1)
192+
assert math.isclose(BW_18dB, 2.6112, abs_tol=0.1)
193193

194194

195195
class TestBohman:
@@ -763,8 +763,8 @@ def test_basic(self, xp):
763763

764764
def test_array_size(self, xp):
765765
for n in [0, 10, 11]:
766-
xp_assert_equal(windows.lanczos(n, sym=False, xp=xp).shape[0], n)
767-
xp_assert_equal(windows.lanczos(n, sym=True, xp=xp).shape[0], n)
766+
assert windows.lanczos(n, sym=False, xp=xp).shape[0] == n
767+
assert windows.lanczos(n, sym=True, xp=xp).shape[0] == n
768768

769769

770770
class TestGetWindow:
@@ -822,11 +822,11 @@ def test_array_as_window(self, xp):
822822
resample(sig, len(sig) * osfactor, window=win)
823823

824824
def test_general_cosine(self, xp):
825-
xp_assert_close(get_window(('general_cosine', [0.5, 0.3, 0.2]), 4),
826-
[0.4, 0.3, 1, 0.3])
827-
xp_assert_close(get_window(('general_cosine', [0.5, 0.3, 0.2]), 4,
825+
xp_assert_close(get_window(('general_cosine', xp.asarray([0.5, 0.3, 0.2])), 4),
826+
xp.asarray([0.4, 0.3, 1, 0.3], dtype=xp.float64))
827+
xp_assert_close(get_window(('general_cosine', xp.asarray([0.5, 0.3, 0.2])), 4,
828828
fftbins=False),
829-
[0.4, 0.55, 0.55, 0.4])
829+
xp.asarray([0.4, 0.55, 0.55, 0.4], dtype=xp.float64))
830830

831831
with pytest.raises(ValueError):
832832
get_window(('general_cosine', [0.5, 0.3, 0.2]), 4, xp=xp)
@@ -872,10 +872,10 @@ def test_windowfunc_basics(xp):
872872
xp_assert_close(w1[:-1], w2)
873873

874874
# Check that functions run and output lengths are correct
875-
xp_assert_equal(window(6, *params, sym=True, xp=xp).shape[0], 6)
876-
xp_assert_equal(window(6, *params, sym=False, xp=xp).shape[0], 6)
877-
xp_assert_equal(window(7, *params, sym=True, xp=xp).shape[0], 7)
878-
xp_assert_equal(window(7, *params, sym=False, xp=xp).shape[0], 7)
875+
assert window(6, *params, sym=True, xp=xp).shape[0] == 6
876+
assert window(6, *params, sym=False, xp=xp).shape[0] == 6
877+
assert window(7, *params, sym=True, xp=xp).shape[0] == 7
878+
assert window(7, *params, sym=False, xp=xp).shape[0] == 7
879879

880880
# Check invalid lengths
881881
assert_raises(ValueError, window, 5.5, *params, xp=xp)
@@ -953,7 +953,7 @@ def test_not_needs_params(xp, winstr):
953953
if is_jax(xp) and winstr in ['taylor']:
954954
pytest.skip(reason=f'{winstr}: item assignment')
955955
win = get_window(winstr, 7, xp=xp)
956-
xp_assert_equal(win.shape[0], 7)
956+
assert win.shape[0] == 7
957957

958958

959959
def test_symmetric(xp):

0 commit comments

Comments
 (0)