Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pywt/_dwt.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ def downcoef(part, data, wavelet, mode='symmetric', level=1):
data = np.asarray(data, dtype=dt, order='C')
if data.ndim > 1:
raise ValueError("downcoef only supports 1d data.")
if part not in 'ad':
if part not in ('a', 'd'):
raise ValueError(f"Argument 1 must be 'a' or 'd', not '{part}'.")
mode = Modes.from_object(mode)
wavelet = _as_wavelet(wavelet)
Expand Down Expand Up @@ -372,7 +372,7 @@ def upcoef(part, coeffs, wavelet, level=1, take=0):
if coeffs.ndim > 1:
raise ValueError("upcoef only supports 1d coeffs.")
wavelet = _as_wavelet(wavelet)
if part not in 'ad':
if part not in ('a', 'd'):
raise ValueError(f"Argument 1 must be 'a' or 'd', not '{part}'.")
return np.asarray(_upcoef(part == 'a', coeffs, wavelet, level, take))

Expand Down
6 changes: 4 additions & 2 deletions pywt/tests/test__pywt.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ def test_downcoef_complex():

def test_downcoef_errs():
# invalid part string (not 'a' or 'd')
assert_raises(ValueError, pywt.downcoef, 'f', np.ones(16), 'haar')
for part in ('f', '', 'ad'):
assert_raises(ValueError, pywt.downcoef, part, np.ones(16), 'haar')


def test_compare_downcoef_coeffs():
Expand Down Expand Up @@ -90,7 +91,8 @@ def test_upcoef_complex():

def test_upcoef_errs():
# invalid part string (not 'a' or 'd')
assert_raises(ValueError, pywt.upcoef, 'f', np.ones(4), 'haar')
for part in ('f', '', 'ad'):
assert_raises(ValueError, pywt.upcoef, part, np.ones(4), 'haar')


def test_upcoef_and_downcoef_1d_only():
Expand Down