[Numpy-discussion] Re: calculating on matrix indices

Brian Blais bblais at bryant.edu
Fri Feb 17 05:33:15 CST 2006


Robert Kern wrote:
> The traceback tells you exactly what's wrong:
> 
> In [7]: x[idx] = exp(-t[idx]/tau)
> ---------------------------------------------------------------------------
> exceptions.TypeError                                 Traceback (most recent call
> last)
> 

yes, I saw that, but all of the types (i.e. type(x)) came out to be the same, so I 
figured the problem was with the indexing, and that was causing a typecast problem. 
I didn't know about dtype

> In [13]: x = zeros(len(t), float)

well that is confusing!  zeros(5,'f') is single precision, zeros(5,'d') is double, 
and zeros(5,float) is double!  that's where I got whacked, because I remembered that 
"float" was "double" in python...but I guess, not always.


thanks for your help!



				bb
-- 
-----------------

             bblais at bryant.edu
             http://web.bryant.edu/~bblais





More information about the Numpy-discussion mailing list