[PYTHON MATRIX-SIG] Re: NumPy in Python 1.4

Konrad Hinsen hinsen@ibs.ibs.fr
Tue, 22 Oct 96 11:27:08 +0100


> The reasoning (as I recall it) was that in all other methods, the array
> type created corresponds to the smallest type which can represent all of
> the elements.  Since 0 and 1 can be represented accurately as integers,
> that's what zeros() and ones() returns.

Exactly. Note also that ints will be coerced to floats if necessary, whereas
the opposite has to be done explicitly. The only reason to call zeros()
with a specific type is to create an array with "arbitrary" values that
are to be overwritten by element assignment.

> I don't have an argument as to why this was chosen over the old version,
> but note that you can do:
> 
> 	zmin = min(ravel(zz))

Still I would recommend minimum.reduce(ravel(zz)). min() will work in
this special case, but can cause lots of unpleasant surprises in other
circumstances. For example, min(a,b), with a and b arrays, will return
a or b depending on which has the lower address in memory!

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
=================