[PYTHON MATRIX-SIG] Bug

Konrad Hinsen hinsen@ibs.ibs.fr
Fri, 25 Oct 96 10:21:56 +0100


> > and disallowing any
> > array-specific operations (especially indexing) on them, to make
> > them act just like scalar types?
> 
> This sounds like a good idea in general.  The one problem here is that I do
> want to provide some way to get the python value out of a scalar.  This is
> currently done by scalar[0].  This could also be done by scalar.tolist() I
> suppose.  I'd hate to add a special method just for this one highly unusual
> operation.

But scalar[0] is inconsistent - you can't index without having an axis.
The proper way to pick something from a rank-0 array (assuming we
want them to exist and behave like arrays) would be scalar[NewAxis][0]
or scalar.flat[0].

However, I see no reason for such trickery. If we decide to make rank-0
arrays act just like scalars, then the obvious way to extract a
"real" scalar would be int(scalar), float(scalar) etc.

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