So far all the “mistakes” I’ve been making have been small things I’m missing, hopefully this is the case here. I’ve decided to use NUMPY array mainly for the array resizing capability. I’ve noticed that it takes awhile to import, but it’s essentially doing what I need so beggars can’t be choosers. Anyway, while trying to “delete” items from the array and replacing them via “insert” with new data, I still have an array that contains all zeroes. So, I’m at a loss. I know the values for [archstartred], [archstartgrn], and [archstartblu] are correct because I print them when they’re generated. Why are the values not populating into the array? Here’s my code:
#Frame Creation
from numpy import *
frames=array([0 for i in range (0,workingframes*archnodes*3)])
frames.resize(archnodes*3, workingframes)
#Frame Population
for f in range (0, workingframes):
if f<=(workingframes/2):
for x in range (0, archnodes):
delete(frames,[x+f])
insert(frames,[x+f],(archstartred[x]))
print archstartred[x]
delete(frames,[x+f+workingframes])
insert(frames,[x+f+workingframes],(archstartgrn[x]))
print archstartgrn[x]
delete(frames,[x+f+workingframes*2])
insert(frames,[x+f+workingframes*2],(archstartblu[x]))
print archstartblu[x]
print frames
raw_input('Press control c') #stop/troubleshoot program
for y in range (0, nodesperframe):
archstartred.pop()
archstartgrn.pop()
archstartblu.pop()
archstartred.insert(0, backred)
archstartgrn.insert(0, backgrn)
archstartblu.insert(0, backblu)
archstartred = [int(value) for value in archstartred]
archstartgrn = [int(value) for value in archstartgrn]
archstartblu = [int(value) for value in archstartblu]
else:
for y in range (0, nodesperframe):
archstartred.pop(0)
archstartgrn.pop(0)
archstartblu.pop(0)
archstartred.append(backred)
archstartgrn.append(backgrn)
archstartblu.append(backblu)
archstartred = [int(value) for value in archstartred]
archstartgrn = [int(value) for value in archstartgrn]
archstartblu = [int(value) for value in archstartblu]
for x in range (0, archnodes):
delete(frames,[x+f])
insert(frames,[x+f],(archstartred[x]))
delete(frames,[x+f+workingframes])
insert(frames,[x+f+workingframes],(archstartgrn[x]))
delete(frames,[x+f+workingframes*2])
insert(frames,[x+f+workingframes*2],(archstartblu[x]))
The numpy functions
insertanddeletereturn a copy rather than occurring in-place. Assign the result back toframesrather than discarding it.