[Numpy-discussion] Cast problems .... doo dah, doo dah

Mathew Yeates mathew at comma.jpl.nasa.gov
Wed Sep 25 17:24:04 CDT 2002


The following code produces an error
---------------------------------------
a=array(([1,2,3,4,5],[10,9,8,7,6])).astype(Float32)
cond=array(([0,0,0,0,0],[1,1,1,1,1])
b=array(([0,0,0,0,0],[0,0,0,0,0]))

choose(cond,(a,b))
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: Array can not be safely cast to required type
------------------------------

I suppose I might need to cast b to Float32. But, I have a function 
which is passed a and b
as args. Ideally, I would like a function which casts a and b to the 
highest compatible type since
"choose" doesnt do it. How can I do this simply?

Mathew

-- 
M47h3w `/34735






More information about the Numpy-discussion mailing list