OverLordGoldDragon / ssqueezepy

Synchrosqueezing, wavelet transforms, and time-frequency analysis in Python
MIT License
636 stars 96 forks source link

Incorrect raising of ValueError("must set `wavelet` if `scales` isn't array") line 220 cwt_utils,py #67

Open jelsom opened 2 years ago

jelsom commented 2 years ago

Hi,

I've encountered what i believe to be a bug in a call to ssqueezepy.ssqueeze to synchro-squeeze a continous wavelet transform. I'll try to explain the issue as best i can, because i can't send the exact implementation. This is also my first issue, to bear with me if i get anything wrong in the format or conventions :)

I'm running ssqueezepy v0.6.3

The call is of the form:

Tx, fvec = sq.ssqueeze(
            Mx, w=phase, ssq_freqs="log", wavelet=wavelet, scales="log", fs=sampleRate, maprange="maximal",
            transform="cwt"
        )

where,

wavelet = sq.Wavelet("morlet") is set before calling the method. and is of type(wavelet) = ssqueezepy.wavelets.Wavelet

and Mx, phase are the normal matrices of the transform and phase produced by ssqueezepy.cwt()

In 'squeezing.py/squeeze' after the call to _process_args is completed, the following if statement on line 168 calls the method process_scales if transform == 'cwt'. See below

    if transform == 'cwt':
        scales, cwt_scaletype, _, nv = process_scales(scales, N, get_params=True)

However the call to process_scales does NOT pass the wavelet as an input argument (which it expects and sets to None if not passed). This results in the exception ValueError("must set `wavelet` if `scales` isn't array") being raised on line 220 in cwt_utils.pt/_process_args as called from process_scales.

The argument wavelet passed to ssqueeze() was in fact set correctly.

Hopefully that makes sense...

Thanks, J.

OverLordGoldDragon commented 2 years ago

Thanks for the report. The debug details help, but please include a minimal reproducible example.