Re: [Numpy-discussion] rank-0 arrays
by Scott Gilbert other posts by this author
Sep 13 2002 5:16PM messages near this date
RE: [Numpy-discussion] rank-0 arrays
|
Re: [Numpy-discussion] rank-0 arrays
--- Todd Miller <jmiller@[...].edu> wrote:
> Two other issues come up trying to implement the "rank-0 experiment":
>
> 1. What should be the behavior of subscripting a rank-0 array?
>
> a. Return the scalar value (what numarray does
> now. seems inconsistent)
>
If you think of it as "dereferencing" instead of "indexing", I think this
is most consistent. It takes 3 elements to dereference a rank-3 array, so
it should take 0 elements to dereference a rank-0 array.
>
> 2. What's a decent notation for .asScalar()?
>
> a. a[ <subscript_resulting_in_rank0> ][0] (what numarray
> does now)
> b. a[ <subscript_resulting_in_rank0> ]() (override
> __call__)
> c. a[ <subscript_resulting_in_rank0> ].asScalar()
>
> Any strong opinions?
>
Since subscripting a rank-3 array:
a[1, 2, 3]
is very much like
a[(1, 2, 3)]
The __getitem__ receives the tuple (1, 2, 3) in both cases. (Try it!)
So that would imply subscripting (dereferencing) a rank-0 array could be:
a[] could be represented by a[()]
It's just unfortunate that Python doesn't currently recognize the a[] as a
valid syntax.
Cheers,
-Scott
__________________________________________________
Do you Yahoo!?
Yahoo! News - Today's headlines
http://news.yahoo.com
-------------------------------------------------------
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
|