FW: [Numpy-discussion] Bug: extremely misleading array behavior

Konrad Hinsen hinsen at cnrs-orleans.fr
Fri Jun 7 09:01:47 CDT 2002


> For binary operations between a Python scalar and array, there is
> no coercion performed on the array type if the scalar is of the
> same kind as the array (but not same size or precision). For example
> (assuming ints happen to be 32 bit in this case)

That solves one problem and creates another... Two, in fact. One is
the inconsistency problem: Python type coercion always promotes
"smaller" to "bigger" types, it would be good to make no exceptions
from this rule.

Besides, there are still situations in which types, ranks, and
indexing operations depend on each other in a strange way. With

  a = array([1., 2.], Float)
  b = array([3., 4.], Float32)

the result of

  a*b

is of type Float, whereas

  a[0]*b

is of type Float32 - if and only if a has rank 1.

> (Yes, it would be easiest to deal with if Python had all these types,
> but I think that will never happen, nor should it happen.)

Python doesn't need to have them as standard types, an add-on package
can provide them as well. NumPy seems like the obvious one.

Konrad.
-- 
-------------------------------------------------------------------------------
Konrad Hinsen                            | E-Mail: hinsen at cnrs-orleans.fr
Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.56.24
Rue Charles Sadron                       | Fax:  +33-2.38.63.15.17
45071 Orleans Cedex 2                    | Deutsch/Esperanto/English/
France                                   | Nederlands/Francais
-------------------------------------------------------------------------------




More information about the Numpy-discussion mailing list