I have a problem to which I can not find a solution for more laps I give it. I have a program in which I generate a series of data and store them in a list. Later I have to remove some of the elements from the list so that its size is smaller. I always delete the first or last item in the list for which I use the "del" or "pop" functions.
To generate the list I want to work on, I call a function created by me that returns a list. Something like this:
y = generadatos(a1,a2,a3) del y
When it reaches the line with the "del" the program hangs. I tried to do it from the console by typing from and  and it gives me the following error:
ValueError: can not delete array elements
However, if I open a new sheet and I think this simple code works without problems:
a=[1,2,3,4] del a print a
If instead of using "from" use "pop" the same thing happens. I thought that maybe the list that returns the function that generates the data does something that I do not understand and that's why it does not let me delete elements.
Thank you very much.
The "generadatos" function is this:
def generadatos(nst,p0st,ast,lbst,timesstrst,pvst,incremst): xbigst = 0 xsmallst = 0 I0bigst =  I0smallst =  for ist in range(0,nst+1): pst = p0st + ast*ist pbigst = np.abs((pst*pvst)/(pst-pvst)) psmallst = np.abs((pst*pvst)/(pst+pvst)) limitpbigst = pbigst/lbst limitpbigst = np.int(limitpbigst) halflimitpbigst = np.int(limitpbigst/2) limitpsmallst = psmallst/lbst limitpsmallst = np.int(limitpsmallst) halflimitpsmallst = np.int(limitpsmallst/2) for jst in range(0,timesstrst): for kst in range(0,halflimitpbigst): I0bigst.append(1) xbigst = xbigst + 1 for lst in range(halflimitpbigst,limitpbigst): I0bigst.append(0) xbigst = xbigst + 1 for mst in range(0,halflimitpsmallst): I0smallst.append(1) xsmallst = xsmallst + 1 for ost in range(halflimitpsmallst,limitpsmallst): I0smallst.append(0) xsmallst = xsmallst + 1 limitpbig2st = np.int((pbigst/2)/lbst) for qst in range (0,limitpbig2st): del I0bigst[-1] limitpsmall2st = np.int((psmallst/2)/lbst) for rst in range (0,limitpsmall2st): del I0smallst[-1] if incremst > 0: aux1st = I0bigst[::] I0bigst = aux1st[::-1] else: aux1st = I0smallst[::] I0smallst = aux1st[::-1] I0st = np.append(I0smallst,I0bigst) return I0st'
At first I create empty lists in the
I0 =  style.
Then I add data using 'I0.append (value)
And finally I use the NumPy function
I0st = np.append (I0smallst, I0bigst)