[Matrix-SIG] New Behavior for NumPy scalars?

Konrad Hinsen hinsen@cnrs-orleans.fr
Mon, 6 Sep 1999 15:45:01 +0200


> My personal solution preference is to not use PyArray_Return for the
> ufuncs and let users who really need a scalar do the indexing to get it
> from the rank-0 array.  Using PyArray_Return seems like trying to
> second-guess the user and leads to these kinds of issues.

It does what a naive user would expect, and what works well for the
vast majority of applications. Anyone who thinks that returning
rank-0 arrays is a good idea should volunteer for writing the
chapter in the documentation which explains the difference between
scalars and rank-0 arrays and why it is necessary to have both!

If you want to introduce rank-0 arrays consistently, you also have
to return a rank-0 result from indexing, for example. And then code
like

    a = Numeric.zeros((3,))
    a[0] = 1
    ...
    if a[0] == 1:
       ...

would do something very unexpected.

The best solution would be to integrate the basic array module with
the standard Python distribution and make all Python scalars rank-0
arrays. Perhaps this could be proposed seriously for Python 2.0.

> Anyone else having any fun with the new NumPy 1.12 beta release?

From what you report, it looks as if I could put my time to a better
use...

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