I can not understand why it gives an error:

if t[i] >= 0 or t[i] < 1/2: IndexError: invalid index to scalar variable.

snippet code:

 import numpy as np def mother_wavelet(t): for i in range (0, np.size(t)): if t[i] >= 0 or t[i] < 1/2: mat_psi = 1 elif t[i] >= 1/2 or t[i] <= 1: mat_psi = -1 else: mat_psi = 0 return mat_psi 
  • * can you tell me more about t that mother_wavelet () takes? Let's say type (t) and what value t comes to mother_wavelet () * range (0, np.size (t) can be reduced to range (np.size (t)) - Ekkertan
  • In the error, the answer is said - scalar variable You are trying to work with it as with a list. You have a string or a number in the mother_wavelet function. Use >>> import pdb >>> pdb.set_trace () You can see what data is in the variables in the right place. - trec
  • t - task area (t = [0, 1]) is supplied to mother_wavelet () - Romashka
  • Python disagrees with you. The code for calling mother_wavelet and initializing its parameter to the studio. - Vitalts

0