On 8/31/06, Tom Denniston <tom.denniston@alum.dartmouth.org> wrote:
For this simple example yes, but if one of the nice things about the array constructors is that they know that lists, tuple and arrays are just sequences and any combination of them is valid numpy input.  So for instance a list of tuples yields a 2d array.  A list of tuples of 1d arrays yields a 3d array.  A list of 1d arrays yields 2d array.  This was the case consistently across all dtypes.  Now it is the case across all of them except for the dtype=object which has this unusual behavior.  I agree that vstack is a better choice when you know you have a list of arrays but it is less useful when you don't know and you can't force a type in the vstack function so there is no longer an equivalent to the dtype=object behavior:

In [7]: numpy.array([numpy.array([1,2,3]), numpy.array([4,5,6])], dtype=object)
Out[7]:
array([[1, 2, 3],
       [4, 5, 6]], dtype=object)

What are you trying to do? If you want integers:

In [32]: a = array([array([1,2,3]), array([4,5,6])], dtype=int)

In [33]: a.shape
Out[33]: (2, 3)


If you want objects, you have them:

In [30]: a = array([array([1,2,3]), array([4,5,6])], dtype=object)

In [31]: a.shape
Out[31]: (2,)

i.e, a is an array containing two array objects.

Chuck