Open ignatenkobrain opened 5 years ago
Thanks for reporting this. Was this vs. the 1.0.1 release? I don't expect current master will be different, but maybe worth trying.
It looks like all of these failures are in the test cases that compare the output of cwt
to precomputed values. It looks like the rms
values reported are MUCH larger than the tolerances, so it does not seem like a simple case of just needing to back off slightly on the tolerance in the tests.
Yes, this was with 1.0.1.
The other thing that stands out from those failures is that they appear to occur only for the complex-valued continuous wavelets. None of the real-valued ones show up in that log.
Have you verified that NumPy itself is passing its tests? The cwt
implementation is mostly just calling NumPy functions, specifically numpy.convolve
.
There is one test failing on ppc64le for Numpy 1.17, but is related to numpy.einsum so I don't think this is related to these tests.
With 1.1.1 we seem to be down to the following test failures on ppc64le:
=================================== FAILURES ===================================
_____________________ test_cwt_complex[float64-1e-13-conv] _____________________
dtype = <class 'numpy.float64'>, tol = 1e-13, method = 'conv'
@pytest.mark.parametrize('dtype, tol, method',
[(np.float32, 1e-5, 'conv'),
(np.float32, 1e-5, 'fft'),
(np.float64, 1e-13, 'conv'),
(np.float64, 1e-13, 'fft')])
def test_cwt_complex(dtype, tol, method):
time, sst = pywt.data.nino()
sst = np.asarray(sst, dtype=dtype)
dt = time[1] - time[0]
wavelet = 'cmor1.5-1.0'
scales = np.arange(1, 32)
# real-valued tranfsorm as a reference
[cfs, f] = pywt.cwt(sst, scales, wavelet, dt, method=method)
# verify same precision
assert_equal(cfs.real.dtype, sst.dtype)
# complex-valued transform equals sum of the transforms of the real
# and imaginary components
sst_complex = sst + 1j*sst
[cfs_complex, f] = pywt.cwt(sst_complex, scales, wavelet, dt,
method=method)
> assert_allclose(cfs + 1j*cfs, cfs_complex, atol=tol, rtol=tol)
E AssertionError:
E Not equal to tolerance rtol=1e-13, atol=1e-13
E
E Mismatched elements: 8184 / 8184 (100%)
E Max absolute difference: 1.6260850453446392
E Max relative difference: 12.401794291785068
E x: array([[-0.022052+0.030137j, -0.018349+0.007132j, -0.078264+0.069763j, ...,
E 0.074812-0.099818j, -0.017838-0.003138j, -0.059956+0.043232j],
E [-0.216809+0.179627j, 0.224426-0.229889j, -0.154184+0.204049j, ...,...
E y: array([[-0.022052+0.026094j, -0.018349+0.01274j , -0.078264+0.074014j, ...,
E 0.074812-0.093232j, -0.017838+0.007649j, -0.059956+0.038912j],
E [-0.216809+0.198218j, 0.224426-0.227157j, -0.154184+0.179117j, ...,...
pywt/tests/test_cwt_wavelets.py:371: AssertionError
_____________________________ test_cwt_method_fft ______________________________
def test_cwt_method_fft():
rstate = np.random.RandomState(1)
data = rstate.randn(50)
data[15] = 1.
scales = np.arange(1, 64)
wavelet = 'cmor1.5-1.0'
# build a reference cwt with the legacy np.conv() method
cfs_conv, _ = pywt.cwt(data, scales, wavelet, method='conv')
# compare with the fft based convolution
cfs_fft, _ = pywt.cwt(data, scales, wavelet, method='fft')
> assert_allclose(cfs_conv, cfs_fft, rtol=0, atol=1e-13)
E AssertionError:
E Not equal to tolerance rtol=0, atol=1e-13
E
E Mismatched elements: 3000 / 3150 (95.2%)
E Max absolute difference: 0.8902320255282511
E Max relative difference: 3.8545247710132533
E x: array([[-0.018290-0.0411j , -0.013562+0.109078j, 0.014260+0.081553j, ...,
E -0.020773-0.101545j, -0.014319+0.060749j, 0.007514+0.049972j],
E [ 0.035162-0.408651j, -0.016188+0.489424j, 0.021840-0.541804j, ...,...
E y: array([[-0.018290-0.0411j , -0.013562+0.109078j, 0.014260+0.081553j, ...,
E -0.020773-0.101545j, -0.014319+0.060749j, 0.007514+0.049972j],
E [ 0.035162-0.408651j, -0.016188+0.489424j, 0.021840-0.541804j, ...,...
pywt/tests/test_cwt_wavelets.py:433: AssertionError
=========================== short test summary info ============================
FAILED pywt/tests/test_cwt_wavelets.py::test_cwt_complex[float64-1e-13-conv]
FAILED pywt/tests/test_cwt_wavelets.py::test_cwt_method_fft - AssertionError:
============= 2 failed, 227 passed, 2 skipped in 131.24s (0:02:11) =============
Other architectures appear to be fine.
Building pywt 1.3.0 on Fedora rawhide fails on ppc64le with the following test:
________________________ test_accuracy_precomputed_cwt _________________________
@uses_precomputed # skip this case if pymatbridge + Matlab are being used
@pytest.mark.slow
def test_accuracy_precomputed_cwt():
# Keep this specific random seed to match the precomputed Matlab result.
rstate = np.random.RandomState(1234)
# has to be improved
epsilon = 2e-15
epsilon32 = 1e-5
epsilon_psi = 1e-15
for wavelet in wavelets:
with warnings.catch_warnings():
warnings.simplefilter('ignore', FutureWarning)
w = pywt.ContinuousWavelet(wavelet)
w32 = pywt.ContinuousWavelet(wavelet,dtype=np.float32)
psi = _load_matlab_result_psi(wavelet)
_check_accuracy_psi(w, psi, wavelet, epsilon_psi)
for N in _get_data_sizes(w):
data = rstate.randn(N)
data32 = data.astype(np.float32)
scales_count = 0
for scales in _get_scales(w):
scales_count += 1
coefs = _load_matlab_result(data, wavelet, scales_count)
> _check_accuracy(data, w, scales, coefs, wavelet, epsilon)
pywt/tests/test_matlab_compatibility_cwt.py:100:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
data = array([ -1.39349312e+00, 8.43433358e-01, -7.48389740e-01,
6.96962461e-01, -2.31877711e-02, 3.14787623e-....61324483e+00, -2.62751782e-03,
2.24986089e+00, -1.20909849e+00, 5.33308212e-02,
2.85267990e+00])
w = pywt._extensions._pywt.ContinuousWavelet(name='cgau1'), scales = 1
coefs = array([[ 5.88904952e-01 -4.22675773e-01j,
-1.02734763e+00 +2.40005860e-02j,
5.28246856e-01 +1.4842....74440177e+00 +1.48754656e-01j,
-7.16701910e-01 -1.17576867e+00j,
-1.58277318e+00 +7.72076610e-01j]])
wavelet = 'cgau1', epsilon = 2e-15
def _check_accuracy(data, w, scales, coefs, wavelet, epsilon):
# PyWavelets result
coefs_pywt, freq = pywt.cwt(data, scales, w)
# coefs from Matlab are from R2012a which is missing the complex conjugate
# as shown in Eq. 2 of Torrence and Compo. We take the complex conjugate of
# the precomputed Matlab result to account for this.
coefs = np.conj(coefs)
# calculate error measures
err = coefs_pywt - coefs
rms = np.real(np.sqrt(np.mean(np.conj(err) * err)))
msg = ('[RMS > EPSILON] for Scale: %s, Wavelet: %s, '
'Length: %d, rms=%.3g' % (scales, wavelet, len(data), rms))
> assert_(rms < epsilon, msg=msg)
E AssertionError: [RMS > EPSILON] for Scale: 1, Wavelet: cgau1, Length: 1000, rms=0.398
pywt/tests/test_matlab_compatibility_cwt.py:161: AssertionError
These tests also still fail on ppc64le:
_____________________ test_cwt_complex[float64-1e-13-conv] _____________________
dtype = <class 'numpy.float64'>, tol = 1e-13, method = 'conv'
@pytest.mark.parametrize('dtype, tol, method',
[(np.float32, 1e-5, 'conv'),
(np.float32, 1e-5, 'fft'),
(np.float64, 1e-13, 'conv'),
(np.float64, 1e-13, 'fft')])
def test_cwt_complex(dtype, tol, method):
time, sst = pywt.data.nino()
sst = np.asarray(sst, dtype=dtype)
dt = time[1] - time[0]
wavelet = 'cmor1.5-1.0'
scales = np.arange(1, 32)
# real-valued tranfsorm as a reference
[cfs, f] = pywt.cwt(sst, scales, wavelet, dt, method=method)
# verify same precision
assert_equal(cfs.real.dtype, sst.dtype)
# complex-valued transform equals sum of the transforms of the real
# and imaginary components
sst_complex = sst + 1j*sst
[cfs_complex, f] = pywt.cwt(sst_complex, scales, wavelet, dt,
method=method)
> assert_allclose(cfs + 1j*cfs, cfs_complex, atol=tol, rtol=tol)
E AssertionError:
E Not equal to tolerance rtol=1e-13, atol=1e-13
E
E Mismatched elements: 8184 / 8184 (100%)
E Max absolute difference: 1.6051954624814788
E Max relative difference: 54.176482670006024
E x: array([[ 0.004042+0.004042j, -0.005609-0.005609j, -0.004250-0.00425j , ...,
E 0.045709-0.070715j, -0.063121+0.042146j, -0.035555+0.018831j],
E [-0.018591-0.018591j, -0.002732-0.002732j, 0.024933+0.024933j, ...,...
E y: array([[-0.022052+0.004042j, -0.018349-0.005609j, -0.078264-0.00425j , ...,
E 0.074812-0.070715j, -0.017838+0.042146j, -0.059956+0.018831j],
E [-0.216809-0.018591j, 0.224426-0.002732j, -0.154184+0.024933j, ...,...
pywt/tests/test_cwt_wavelets.py:387: AssertionError
_____________________________ test_cwt_method_fft ______________________________
def test_cwt_method_fft():
rstate = np.random.RandomState(1)
data = rstate.randn(50)
data[15] = 1.
scales = np.arange(1, 64)
wavelet = 'cmor1.5-1.0'
# build a reference cwt with the legacy np.conv() method
cfs_conv, _ = pywt.cwt(data, scales, wavelet, method='conv')
# compare with the fft based convolution
cfs_fft, _ = pywt.cwt(data, scales, wavelet, method='fft')
> assert_allclose(cfs_conv, cfs_fft, rtol=0, atol=1e-13)
E AssertionError:
E Not equal to tolerance rtol=0, atol=1e-13
E
E Mismatched elements: 150 / 3150 (4.76%)
E Max absolute difference: 1.146537746216395
E Max relative difference: 1.497151833596519
E x: array([[-0.018290 -2.276161e-17j, -0.013562 -2.868661e-17j,
E 0.014260 -3.302193e-13j, ..., -0.020773 -7.407469e-02j,
E -0.014319 +1.350186e-01j, 0.007514 -1.496994e-02j],...
E y: array([[-0.018290-0.0411j , -0.013562+0.109078j, 0.014260+0.081553j, ...,
E -0.020773-0.101545j, -0.014319+0.060749j, 0.007514+0.049972j],
E [ 0.035162-0.408651j, -0.016188+0.489424j, 0.021840-0.541804j, ...,...
pywt/tests/test_cwt_wavelets.py:449: AssertionError
Hello,
I noticed that quite some tests failed on ppc64le architecture. They are below. I guess it is because only this architecture enables FMA (more precise floating point).