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] A case for rank-0 arrays
by Sasha other posts by this author
Feb 23 2006 7:28PM messages near this date
Re: [Numpy-discussion] A case for rank-0 arrays | Re: [Numpy-discussion] A case for rank-0 arrays
On 2/23/06, Francesc Altet <faltet@[...].com>  wrote:
>  It's a bit late, but I want to support your proposal (most of it).

You are not late -- you are the first to reply! When you say "most of
it," is there anything in particular that you don't like?

>  I've also come to the conclusion that scalars and rank-0 arrays should
>  coexist. This is something that appears as a natural fact when you
>  have to deal regularly with general algorithms for treat objects with
>  different shapes. And I think you have put this very well.

Thanks for your kind words.  If we agree to legitimize rank-0 arrays,
maybe we should start by removing conversion to scalars from ufuncs. 
Currently:

> >> type(array(2)*2)
<type 'int32scalar'> 

I believe it should result in a rank-0 array instead.

I've recently wrote ndarray round function and that code illustrates
the problem of implicite scalar conversion:

                ret = PyNumber_Multiply((PyObject *)a, f);
                if (ret==NULL) {Py_DECREF(f); return NULL;}
                if (PyArray_IsScalar(ret, Generic)) {
                        /* array scalars cannot be modified inplace */
                        PyObject *tmp;
                        tmp = PyObject_CallFunction(n_ops.rint, "O", ret);
                        Py_DECREF(ret);
                        ret = PyObject_CallFunction(n_ops.divide, "OO",
                                                    tmp, f);
                        Py_DECREF(tmp);
                } else {
                        PyObject_CallFunction(n_ops.rint, "OO", ret, ret);
                        PyObject_CallFunction(n_ops.divide, "OOO", ret,
                                              f, ret);
                }


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd_______________________________________________
Numpy-discussion mailing list
Numpy-discussion@[...].net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion
Thread:
Sasha
Francesc Altet
Francesc Altet
Colin J. Williams
Travis Oliphant
Sasha
Francesc Altet
Sasha
Travis Oliphant
Sasha
Francesc Altet

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