wavelets
wavelets copied to clipboard
A program error that can cause "IndexError: only integers, ...... are valid indices"
my program is as follows:
x, _ = librosa.core.load(dataset_path + "test.wav", sr=16000, mono=True)
x = x[26000:40000]
wa = WaveletAnalysis(sig, dt=0.1)
print(wa.reconstruction().shape)
An error occurred during runtime:
File "\wavelets\transform.py", line 85, in cwt
return cwt_time(data, wavelet, widths, dt, axis)
File "\wavelets\transform.py", line 105, in cwt_time
wavelet_data[slices],
IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices
Because there is an error in your source code, as shown below,
def cwt_time(data, wavelet, widths, dt, axis):
# wavelets can be complex so output is complex
......
wavelet_data = norm * wavelet(t, width)
output[ind, :] = scipy.signal.fftconvolve(data,
wavelet_data[slices],
mode='same')
return output
it should be corrected in this way. Obviously, the sequence value operation is missing:
def cwt_time(data, wavelet, widths, dt, axis):
# wavelets can be complex so output is complex
......
wavelet_data = norm * wavelet(t, width)
output[ind, :] = scipy.signal.fftconvolve(data,
wavelet_data[slices[axis]],
mode='same')
return output
This repo is abandoned, see my fork and let me know if it has the same problem
This repo is abandoned, see my fork and let me know if it has the same problem
I just took a look, your program in new repo is correct which added an extra line "slices = tuple(slices)" than the original program, so corrected the error, thanks!