[Numpy-discussion] rank-0 arrays

Konrad Hinsen hinsen at cnrs-orleans.fr
Mon Sep 16 12:18:14 CDT 2002

"Chris Barker" <Chris.Barker at noaa.gov> writes:

> Travis Oliphant wrote:
> > This is the gist of it.  Basically you extend the Python scalars to
> > include the single precision types (all the types Numeric supports).
> Would they be recognised as scalars by Python? In particular, could you

There is no "scalar" category in Python. New scalar datatypes would be
types with the same behaviour as the existing Python scalar types, but
different from the. That means that explicitly type-checking code would
not accept them, but everything else would.

> use one as an index? Personally, this is what has bit me in the past: I

At least up to Python 1.5, no, indices have to be of integer type. I
don't know if that condition was extended in later versions.

> could use A[3,2] as an index if A was type "Int" but not if it was
> "Int16" for example.

Ehmmm... Are you sure that is the right example? The restriction is on
the type of the index, not on the type of the array.

> Frankly, I have no idea what the implimentation details would be, but
> could we get rid of rank-0 arrays altogether? I have always simply found

If we introduce additional scalars, yes. Whether or not we would want
to get rid of them is of course another question.

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

More information about the Numpy-discussion mailing list