PyWavelets / pywt

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

DWT hangs with 'reflect' and 'antirefelct' mode on input size 1 #597

Closed mandulaj closed 3 years ago

mandulaj commented 3 years ago

In reflect and antireflect mode, the edges are extended by reflecting the signal as per documentation:

... x3 x2 | x1 x2 ... xn | xn-1 xn-2 ...

Problem is when the input is of length 1. There is no x2/xn-1 and effectively the code computing the extending elements enters an infinite loop.

Steps to reproduce:

import pywt
cA, cD = pywt.dwt([1], 'db1', 'reflect')  #<= Will hang in infinite loop

Expected result

Raise a ValueError or IndexError to report unsupported length

Actual result

Code enters infinite loop