BUG: raise a clear error when cwt() is given a discrete wavelet (gh-776)#849
Merged
Merged
Conversation
…veletsgh-776) Passing a discrete wavelet, e.g. cwt(data, scales, 'coif1'), crashed with a confusing `AttributeError: 'Wavelet' object has no attribute 'complex_cwt'`, because `complex_cwt` exists only on ContinuousWavelet. Validate that the resolved wavelet is continuous and otherwise raise a ValueError that names the offending wavelet and points to pywt.wavelist(kind='continuous').
rgommers
approved these changes
Jun 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #776.
cwt(data, scales, 'coif1')(or any other discrete wavelet) crashed with:The name is resolved with
DiscreteContinuousWavelet, which happily returnsa discrete
Waveletfor a name like'coif1'.cwtthen unconditionallyreads
wavelet.complex_cwt, an attribute that only exists onContinuousWavelet, so the call dies with the confusing error above insteadof telling the user they passed the wrong kind of wavelet.
As @rgommers noted on the issue, passing the wrong wavelet name should give a
clear message rather than a confusing one. This validates that the resolved
wavelet is continuous and otherwise raises a
ValueErrorthat names theoffending wavelet and points to
pywt.wavelist(kind='continuous'):A regression test covering a name, a discrete
Waveletinstance, and astill-working continuous wavelet is included.