PyWavelets / pywt

PyWavelets - Wavelet Transforms in Python
http://pywavelets.readthedocs.org
MIT License
1.97k stars 460 forks source link

test_accuracy_precomputed_cwt fails on aarch64 #640

Closed opoplawski closed 1 year ago

opoplawski commented 2 years ago

Building pywt 1.3.0 on Fedora rawhide fails on aarch64 with the following test:

____________________________ test_cwt_batch[0-fft] _____________________________
axis = 0, method = 'fft'
    @pytest.mark.parametrize('axis, method', product([0, 1], ['conv', 'fft']))
    def test_cwt_batch(axis, method):
        dtype = np.float64
        time, sst = pywt.data.nino()
        n_batch = 8
        batch_axis = 1 - axis
        sst1 = np.asarray(sst, dtype=dtype)
        sst = np.stack((sst1, ) * n_batch, axis=batch_axis)
        dt = time[1] - time[0]
        wavelet = 'cmor1.5-1.0'
        scales = np.arange(1, 32)

        # non-batch transform as reference
        [cfs1, f] = pywt.cwt(sst1, scales, wavelet, dt, method=method, axis=axis)

        shape_in = sst.shape
        [cfs, f] = pywt.cwt(sst, scales, wavelet, dt, method=method, axis=axis)

        # shape of input is not modified
        assert_equal(shape_in, sst.shape)

        # verify same precision
        assert_equal(cfs.real.dtype, sst.dtype)

        # verify expected shape
        assert_equal(cfs.shape[0], len(scales))
        assert_equal(cfs.shape[1 + batch_axis], n_batch)
        assert_equal(cfs.shape[1 + axis], sst.shape[axis])

        # batch result on stacked input is the same as stacked 1d result
>       assert_equal(cfs, np.stack((cfs1,) * n_batch, axis=batch_axis + 1))
E       AssertionError: 
E       Arrays are not equal
E       
E       Mismatched elements: 61080 / 65472 (93.3%)
E       Max absolute difference: 2.3052588782060247e-15
E       Max relative difference: 4.507026999251287e-14
E        x: array([[[ 0.004042+0.026095j,  0.004042+0.026095j,  0.004042+0.026095j,
E                ...,  0.004042+0.026095j,  0.004042+0.026095j,  0.004042+0.026095j],
E               [-0.005609+0.012741j, -0.005609+0.012741j, -0.005609+0.012741j,...
E        y: array([[[ 0.004042+0.026095j,  0.004042+0.026095j,  0.004042+0.026095j,
E                ...,  0.004042+0.026095j,  0.004042+0.026095j,  0.004042+0.026095j],
E               [-0.005609+0.012741j, -0.005609+0.012741j, -0.005609+0.012741j,...
pywt/tests/test_cwt_wavelets.py:422: AssertionError
____________________________ test_cwt_batch[1-fft] _____________________________
axis = 1, method = 'fft'
    @pytest.mark.parametrize('axis, method', product([0, 1], ['conv', 'fft']))
    def test_cwt_batch(axis, method):
        dtype = np.float64
        time, sst = pywt.data.nino()
        n_batch = 8
        batch_axis = 1 - axis
        sst1 = np.asarray(sst, dtype=dtype)
        sst = np.stack((sst1, ) * n_batch, axis=batch_axis)
        dt = time[1] - time[0]
        wavelet = 'cmor1.5-1.0'
        scales = np.arange(1, 32)

        # non-batch transform as reference
        [cfs1, f] = pywt.cwt(sst1, scales, wavelet, dt, method=method, axis=axis)

        shape_in = sst.shape
        [cfs, f] = pywt.cwt(sst, scales, wavelet, dt, method=method, axis=axis)

        # shape of input is not modified
        assert_equal(shape_in, sst.shape)

        # verify same precision
        assert_equal(cfs.real.dtype, sst.dtype)

        # verify expected shape
        assert_equal(cfs.shape[0], len(scales))
        assert_equal(cfs.shape[1 + batch_axis], n_batch)
        assert_equal(cfs.shape[1 + axis], sst.shape[axis])

        # batch result on stacked input is the same as stacked 1d result
>       assert_equal(cfs, np.stack((cfs1,) * n_batch, axis=batch_axis + 1))
E       AssertionError: 
E       Arrays are not equal
E       
E       Mismatched elements: 61080 / 65472 (93.3%)
E       Max absolute difference: 2.3052588782060247e-15
E       Max relative difference: 4.507026999251287e-14
E        x: array([[[ 0.004042+0.026095j, -0.005609+0.012741j, -0.004250+0.074014j,
E                ..., -0.012503-0.087315j, -0.010488+0.00735j , -0.008362+0.051594j],
E               [ 0.004042+0.026095j, -0.005609+0.012741j, -0.004250+0.074014j,...
E        y: array([[[ 0.004042+0.026095j, -0.005609+0.012741j, -0.004250+0.074014j,
E                ..., -0.012503-0.087315j, -0.010488+0.00735j , -0.008362+0.051594j],
E               [ 0.004042+0.026095j, -0.005609+0.012741j, -0.004250+0.074014j,...
pywt/tests/test_cwt_wavelets.py:422: AssertionError