[PYTHON MATRIX-SIG] zero-dimension array silliness
Konrad Hinsen
hinsen@ibs.ibs.fr
Fri, 25 Oct 96 10:32:25 +0100
> Therefore, I propose the following "common sense" (Republican?) solution:
>
> 1) array types must match - type conversions must be explicit
> 2) Python scalars are automatically converted to the correct type
"Correct" being what? There has been a long discussion about the
coercion problem a few months ago, and in the end we agreed that
to avoid unpleasant surprises we would never allow "downgrading"
of precision silently. That means that when combining a Python
float (i.e. a double) with a short float array, the array will be
converted to double. And if that's not what you want, you need a
short float scalar, which doesn't exist - hence the need for
rank-0 arrays.
This seems an acceptable solution to me, since most people, and
especially beginners, would not use short floats anyway. And as long
as you keep your arrays limited to the types that Python has always
had, everything would work like before without tricks and nasty
surprises.
> you don't need strange idioms (a * array(3.14, a.typecode())) for scalar
> multiplication (3.14 * a).
Such idioms are needed only in general library routines that should
work for all precisions.
Konrad.
--
-------------------------------------------------------------------------------
Konrad Hinsen | E-Mail: hinsen@ibs.ibs.fr
Laboratoire de Dynamique Moleculaire | Tel.: +33-76.88.99.28
Institut de Biologie Structurale | Fax: +33-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
=================