I made a small change to the array creation function so that if you 
explicitly specify dtype=object, then the logic for determining the 
shape of the array is changed.

The new logic for constructing dtype=object arrays from Python sequences 
is that the shape is determined by nested lists (and only lists).  The 
nesting must be consistent or else the elements of the last conforming 
lists are assumed to be objects.

Here are some examples:

array([[1,2],3,4],dtype=object)  returns a 1-d array of shape (3,)

array([[1,2],[3,4]],dtype=object)  returns a 2-d array of shape (2,2)

array([(1,2),(3,4)],dtype=object) returns a 1-d array of shape (2,)

array([],dtype=object) returns a 0-d array of shape ()

array([[],[],[]],dtype=object) returns a 1-d array of shape (3,)

array([[3,4],[5,6],None],dtype=object) returns a 1-d array of shape (3,)


You have to actually specify dtype=object to get this, otherwise the old 
code-path will be taken.


-Travis


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion

Reply via email to