Re: [Numpy-discussion] rank-0 arrays
by Travis Oliphant other posts by this author
Sep 16 2002 10:49PM messages near this date
RE: [Numpy-discussion] rank-0 arrays
|
Re: [Numpy-discussion] rank-0 arrays
>
> 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
> use one as an index? Personally, this is what has bit me in the past: I
> could use A[3,2] as an index if A was type "Int" but not if it was
> "Int16" for example.
>
> In any case, the type of A[3,2] should NOT depend on the precision of
> the numbers stored in A.
>
> 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
> them strange and confusing... What are they really neccesary for
> (besides holding scalar values of different precision that standard
> Pyton scalars)?
With new coercion rules this becomes a possibility. Arguments against it
are that special rank-0 arrays behave as more consistent numbers with the
rest of Numeric than Python scalars. In other words they have a length
and a shape and one can right N-dimensional code that works the same even
when the result is a scalar.
Another advantage of having a Numeric scalar is that we can control the
behavior of floating point operations better.
e.g.
if only Python scalars were available and sum(a) returned 0, then
1 / sum(a) would behave as Python behaves (always raises error).
while with our own scalars
1 / sum(a) could potentially behave however the user wanted.
-Travis
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Numpy-discussion mailing list
Numpy-discussion@[...].net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion
Thread:
Perry Greenfield
Travis Oliphant
Pearu Peterson
Konrad Hinsen
Perry Greenfield
Todd Miller
Pearu Peterson
Konrad Hinsen
Travis Oliphant
Konrad Hinsen
Perry Greenfield
Travis Oliphant
Tim Hochberg
Chris Barker
Konrad Hinsen
Perry Greenfield
Travis Oliphant
Pearu Peterson
Tim Hochberg
Perry Greenfield
Konrad Hinsen
Perry Greenfield
eric jones
Konrad Hinsen
eric jones
Konrad Hinsen
Tim Hochberg
Tim Hochberg
Paul F Dubois
Scott Gilbert
Konrad Hinsen
|