I have been working on a Numpy script and it has suddenly started acting up.
I wrote the For loop line at the beginning, and have tested the script about 20 or so times with no trouble. Now that I think other issues are resolved, Python is telling me that the “for” syntax is wrong. Does anybody have any ideas?
The exact Python output is:
File "Test.py", line 17
for t in range(10):
^
Script code is:
#!/Library/Frameworks/EPD64.framework/Versions/7.3
import numpy as np
import scipy as sp
tau = 10
c = sp.recfromtxt("test.txt")
binsmax = np.max(c)
f, dummy = np.histogram(c, bins=(np.arange(binsmax+1))
for t in range(tau):
if t==0:
a = c[:len(c)-1]
else:
a = c[:-(t+1)]
d = c[1:]
b = d
c = a + b
newmax = np.max(c)
if binsmax < newmax:
binsmax = newmax
hist, dummy2 = np.histogram(c, bins=[np.arange(binsmax+1)])
if binsmax < newmax:
difference = newmax - binsmax
np.append(f, np.zeros(difference))
else:
difference = binsmax - newmax
np.append(hist, np.zeros(difference))
e = f
f = hist + e # 'f' is the running histogram
sp.savetxt(str(t)+"c.txt", c)
sp.savetxt(str(t)+"f.txt", f)
Thanks!
You’re short a close parens in this line: