I'm trying to iterate an array of values generated with numpy.linspace:
slX = numpy.linspace(obsvX, flightX, numSPts)
slY = np.linspace(obsvY, flightY, numSPts)
for index,point in slX:
yPoint = slY[index]
arcpy.AddMessage(yPoint)
This code worked fine on my office computer, but I sat down this morning to work from home on a different machine and this error came up:
File "C:\temp\gssm_arcpy.1.0.3.py", line 147, in AnalyzeSightLine
for index,point in slX:
TypeError: 'numpy.float64' object is not iterable
slX is just an array of floats, and the script has no problem printing the contents -- just, apparently iterating through them. Any suggestions for what is causing it to break, and possible fixes?
for index, point in slX:. This will not work in any version of Python with any version of numpy. Instead, did you actually runfor index, point in enumerate(slX):on your office computer? That would seem to be what you are intending to accomplish.enumerate(slX)makes a lot more sense)for i,j in numpy.linspace(0,1): ... print jcreates the same error. The variantfor j in numpy.linspace(0,1): ... print jworks fine, indicating what the problem is.