Fernando Perez wrote: > On 8/30/06, Stefan van der Walt <[EMAIL PROTECTED]> wrote: > > >> The current behaviour makes sense, but is maybe not consistent: >> >> N.array([],dtype=object).size == 1 >> N.array([[],[]],dtype=object).size == 2 >> > > Yes, including one more term in this check: > > In [5]: N.array([],dtype=object).size > Out[5]: 1 > > In [6]: N.array([[]],dtype=object).size > Out[6]: 1 > > In [7]: N.array([[],[]],dtype=object).size > Out[7]: 2 > > Intuitively, I'd have expected the answers to be 0,1,2, instead of 1,1,2. > >
What about N.array(3).size N.array([3]).size N.array([3,3]).size Essentially, the [] is being treated as an object when you explicitly ask for an object array in exactly the same way as 3 is being treated as a number in the default case. It's just that '[' ']' is "also" being used as the dimension delimiter and thus the confusion. It is consistent. It's a corner case, and I have no problem fixing the special-case code running when dtype=object so that array([], dtype=object) returns an empty array, if that is the consensus. -Travis > Cheers, > > f > > ------------------------------------------------------------------------- > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > _______________________________________________ > Numpy-discussion mailing list > Numpy-discussion@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/numpy-discussion > ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion