import numpy as np
for i in range(len(x)):
if (np.floor(N[i]/2)==N[i]/2):
for j in range(N[i]/2):
pxd[i,j]=x[i]-(delta*j)*np.sin(s[i]*np.pi/180)
pyd[i,j]=y[i]-(delta*j)*np.cos(s[i]*np.pi/180)
else:
for j in range((N[i]-1)/2):
pxd[i,j]=x[i]-(delta*j)*np.sin(s[i]*np.pi/180)
pyd[i,j]=y[i]-(delta*j)*np.cos(s[i]*np.pi/180)
Does anyone has an idea of solving this problem? Running these codes successfully?
有没有人有解决这个问题的想法?成功运行这些代码?
Thanks,
Jeremy
谢谢,杰里米
2 个解决方案
#1
7
N=np.floor(np.divide(l,delta))
...
for j in range(N[i]/2):
N[i]/2
will be a float64
but range()
expects an integer. Just cast the call to
N [i] / 2将是一个float64,但range()需要一个整数。只需将电话转为
for j in range(int(N[i]/2)):
#2
2
I came here with the same Error, though one with a different origin.
我带着相同的错误来到这里,虽然有一个不同的起源。
It is caused by unsupported float index in 1.12.0 and newer versions even if the code should be considered as valid.
它是由1.12.0及更新版本中不支持的浮点索引引起的,即使代码应被视为有效。
An int type is expected, not a np.float64
Solution: Try to install numpy 1.11.0
期望一个int类型,而不是一个np.float64解决方案:尝试安装numpy 1.11.0
sudo pip install -U numpy==1.11.0.
#1
7
N=np.floor(np.divide(l,delta))
...
for j in range(N[i]/2):
N[i]/2
will be a float64
but range()
expects an integer. Just cast the call to
N [i] / 2将是一个float64,但range()需要一个整数。只需将电话转为
for j in range(int(N[i]/2)):
#2
2
I came here with the same Error, though one with a different origin.
我带着相同的错误来到这里,虽然有一个不同的起源。
It is caused by unsupported float index in 1.12.0 and newer versions even if the code should be considered as valid.
它是由1.12.0及更新版本中不支持的浮点索引引起的,即使代码应被视为有效。
An int type is expected, not a np.float64
Solution: Try to install numpy 1.11.0
期望一个int类型,而不是一个np.float64解决方案:尝试安装numpy 1.11.0
sudo pip install -U numpy==1.11.0.