私はNumpyスクリプトに取り組んでいますが、突然動作し始めました。最初にForループ行を作成し、スクリプトを約20回問題なくテストしました。他の問題が解決されたと思うので、Pythonは「for」構文が間違っていると言っています。誰かアイデアはありますか?正確なPython出力は次のとおりです。
File "Test.py", line 17
for t in range(10):
^
スクリプトコードは次のとおりです。
#!/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)
ありがとう!