Charles R Harris wrote:

>
>     So is this intentional?
>
>     In [24]: a = array([[],[],[]], dtype=object)
>
>     In [25]: a.shape
>     Out[25]: (3, 0)
>
>     In [26]: a = array([], dtype=object)
>
>     In [27]: a.shape
>     Out[27]: (0,)
>      
>     One could argue that the first array should have shape (3,)
>
Yes, it's intentional because it's the old behavior of Numeric.  And it 
follows the rule that object arrays don't do anything special unless the 
old technique of using [] as 'dimension delimiters' breaks down.

>
> And this doesn't look quite right:
>
> In [38]: a = array([[1],[2],[3]], dtype=object)
>
> In [39]: a.shape
> Out[39]: (3, 1)
>
> In [40]: a = array([[1],[2,3],[4,5]], dtype=object)
>
> In [41]: a.shape
> Out[41]: (3,)
>  

Again, same reason as before.  The first example works fine to construct 
a rectangular array of object arrays of dimension 2.  The second only 
does if we limit the number of dimensions to 1.

The rule is that array needs nested lists with the same number of 
dimensions unless you have object arrays.  Then, the dimensionality will 
be determined by finding the largest number of dimensions possible for 
consistency of shape.

-Travis



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

Reply via email to