Skip to content

Commit 7502b53

Browse files
committed
guard against invalid axis index in waverecn
The ValueError raised is the same as the one in idwt
1 parent 1904642 commit 7502b53

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

pywt/_multilevel.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,13 @@ def waverec(coeffs, wavelet, mode='symmetric', axis=-1):
143143

144144
for d in ds:
145145
if (a is not None) and (d is not None):
146-
if a.shape[axis] == d.shape[axis] + 1:
147-
a = a[[slice(s) for s in d.shape]]
148-
elif a.shape[axis] != d.shape[axis]:
149-
raise RuntimeError("coefficient shape mismatch")
146+
try:
147+
if a.shape[axis] == d.shape[axis] + 1:
148+
a = a[[slice(s) for s in d.shape]]
149+
elif a.shape[axis] != d.shape[axis]:
150+
raise ValueError("coefficient shape mismatch")
151+
except IndexError:
152+
raise ValueError("Axis greater than coefficient dimensions")
150153
a = idwt(a, d, wavelet, mode, axis)
151154

152155
return a

0 commit comments

Comments
 (0)