[MATRIX-SIG] newbie question: convert array of floats to integer
Konrad Hinsen
hinsen@ibs.ibs.fr
Mon, 30 Jun 1997 11:29:13 +0200
> try somethink like:
>
> new_array = Numeric.array(old_array, Numeric.Integer)
That will likely produce an error message. Use old_array.astype(Integer):
>>> from Numeric import *
from Numeric import *
>>> a = array([1.,2.])
a = array([1.,2.])
>>> b = array(a, Int)
b = array(a, Int)
Traceback (innermost last):
File "<stdin>", line 1, in ?
TypeError: Array can not be safely cast to required type
>>> b = a.astype(Int)
b = a.astype(Int)
Konrad.
--
-------------------------------------------------------------------------------
Konrad Hinsen | E-Mail: hinsen@ibs.ibs.fr
Laboratoire de Dynamique Moleculaire | Tel.: +33-4.76.88.99.28
Institut de Biologie Structurale | Fax: +33-4.76.88.54.94
41, av. des Martyrs | Deutsch/Esperanto/English/
38027 Grenoble Cedex 1, France | Nederlands/Francais
-------------------------------------------------------------------------------
_______________
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
_______________