treefmt / nix fmt (pull_request) Successful in 3s
build_systems / build-rhapsody-in-green (pull_request) Failing after 1h42m42s
build_systems / build-portal-1 (pull_request) Failing after 1h56m54s
build_systems / build-brain (pull_request) Failing after 2h2m2s
test ebook search / test-ebook-search (pull_request) Successful in 2h6m28s
pytest / pytest (pull_request) Successful in 3h32m2s
build_systems / build-jeeves (pull_request) Successful in 5h36m55s
build_systems / build-bob (pull_request) Successful in 7h36m46s
Keep STFT tests enabled with precision-appropriate tolerances for x86-64-v3 builds. Add the override under overlays/patches/scipy and remove the commented-out test exclusions.
52 lines
2.0 KiB
Diff
52 lines
2.0 KiB
Diff
Subject: [PATCH] signal: allow floating-point rounding in STFT tests
|
|
|
|
Keep the STFT tests enabled for x86-64-v3 builds. Allow two float32
|
|
epsilons of relative error when comparing inverse-STFT implementations;
|
|
float64 and the existing i686 override remain unchanged. Allow one
|
|
float64 epsilon of absolute error in all three scaling round trips,
|
|
which otherwise require exact zeros (observed residual: 4e-17 for a
|
|
signal with amplitude 2).
|
|
|
|
Upstream issue: https://github.com/scipy/scipy/issues/25488
|
|
|
|
--- a/scipy/signal/tests/_scipy_spectral_test_shim.py
|
|
+++ b/scipy/signal/tests/_scipy_spectral_test_shim.py
|
|
@@ -294,7 +294,7 @@
|
|
|
|
# Adapted tolerances to account for resolution loss:
|
|
atol = np.finfo(x.dtype).resolution*2 # instead of default atol = 0
|
|
- rtol = 1e-7 # default for np.allclose()
|
|
+ rtol = max(1e-7, 2 * np.finfo(x.dtype).eps)
|
|
|
|
# Relax atol on 32-Bit platforms a bit to pass CI tests.
|
|
# - Not clear why there are discrepancies (in the FFT maybe?)
|
|
--- a/scipy/signal/tests/test_spectral.py
|
|
+++ b/scipy/signal/tests/test_spectral.py
|
|
@@ -2044,7 +2044,7 @@
|
|
|
|
# Test round trip:
|
|
x1 = istft(Zs, boundary=True, scaling='spectrum')[1]
|
|
- assert_allclose(x1, x)
|
|
+ assert_allclose(x1, x, atol=np.finfo(x.dtype).eps)
|
|
|
|
# For a Hann-windowed 256 sample length FFT, we expect a peak at
|
|
# frequency 64 (since it is 1/4 the length of X) with a height of 1
|
|
@@ -2074,7 +2074,7 @@
|
|
|
|
# Test round trip:
|
|
x1 = istft(Zp, input_onesided=False, boundary=True, scaling='psd')[1]
|
|
- assert_allclose(x1, x)
|
|
+ assert_allclose(x1, x, atol=np.finfo(x.dtype).eps)
|
|
|
|
# The power of the one-sided psd-scaled STFT can be determined
|
|
# analogously (note that the two sides are not of equal shape):
|
|
@@ -2094,7 +2094,7 @@
|
|
|
|
# Test round trip:
|
|
x1 = istft(Zp0, input_onesided=True, boundary=True, scaling='psd')[1]
|
|
- assert_allclose(x1, x)
|
|
+ assert_allclose(x1, x, atol=np.finfo(x.dtype).eps)
|
|
|
|
|
|
class TestSampledSpectralRepresentations:
|