ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> numpy-discussion
numpy-discussion
Re: [Numpy-discussion] rank-0 arrays
by Travis Oliphant other posts by this author
Sep 13 2002 7:54PM messages near this date
Re: [Numpy-discussion] rank-0 arrays | Re: [Numpy-discussion] rank-0 arrays
>  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)
+0.25

>  b.  Raise an exception
+1

>  c.  Return a copy  of the rank-0 array
-1

> 
>  2.  What's a decent notation for .asScalar()?
> 
>  a.  a[ <subscript_resulting_in_rank0> ][0]                (what numarray
>  does now)
-1

Numeric does this now for backward compatibility.  I don't think this
issue was discussed at length.


>  b.  a[ <subscript_resulting_in_rank0> ]()                  (override
>  __call__)
-1

>  c.  a[ <subscript_resulting_in_rank0> ].asScalar()
+1  just keep the current .toscalar()  notation.

Also int(a) and float(a) and complex(a) would work as well.

If we just implemented Python scalars for the other precisions then much
of this rank 0 array business would be solved as we could always return
the Python scalar rather than an array for rank 0 arrays.

I believe Konrad made this suggestion many moons ago and I would agree
with him.

-Travis Oliphant




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

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved