[PYTHON MATRIX-SIG] Type coercion issues again - possible incompatibility in next release :-(
Konrad Hinsen
hinsen@ibs.ibs.fr
Sun, 9 Mar 1997 19:02:51 +0100
> In fixing this bug, I noticed a laxness in a number of array functions for
> coercion with loss of precision. For example, the following code runs
> without a hitch in NumPy-beta1
>
> >>> from Numeric import *
> >>> a = arange(10, typecode=Float)
> >>> a
> array([ 0., 1., 2., 3., 4., 5., 6., 7., 8., 9.])
> >>> asarray(a, Int)
> array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
>
> While this is clearly not a problem in this case, in general it's a very
> dangerous thing to automatically coerce an array of floats to ints.
What's automatic in this case? There's an explicit 'Int' there, so
I don't see a problem.
I agree, of course, that truly automatic conversion with loss of
precision should not happen, even if that leads to somewhat incompatible
behaviour.
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
_______________