bizarre Numeric error
Chris Fonnesbeck
spam at fisher.forestry.uga.edu
Fri Jun 20 18:56:39 EDT 2003
Something very wierd is going on with transpose in Numeric: I have an
empty list to which I am iteratively adding 2-element lists. In my
code, I transpose this array for use in other operations. Even though
my array is tranposeable, in my code, I get a TypeError. Here is the
chunk of code:
obs.append([X,y])
print obs
_X,_Y = t(obs)
here, I imported Numeric.transpose as t. Running the code gives:
[[0.5, 0.022628661753748849]]
Traceback (most recent call last):
File "KalmanFilter.py", line 268, in ?
ricker.runTest()
File "KalmanFilter.py", line 258, in runTest
testfilter.filter(xinit,Pinit)
File "KalmanFilter.py", line 210, in filter
_X,_Y = transpose(obs)
File "/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages/Numeric/Numeric.py",
line 248, in transpose
return multiarray.transpose(a, axes)
TypeError: a float is required
The first line of the output is the list that I'm trying to transpose.
There is no reason I can see why this shouldnt work. If I do it by
hand in a python shell, it transposes fine:
>>> from Numeric import *
>>> a = [[0.5,0.022628661753748849]]
>>> transpose(a)
array([[ 0.5 ],
[ 0.022628661753748849]])
I'm totally stumped. Pelase help.
More information about the Python-list
mailing list