[Numpy-discussion] np.array creation: unexpected behaviour
Stéfan van der Walt
stefan at sun.ac.za
Fri Jan 24 19:34:12 EST 2014
On Fri, 24 Jan 2014 17:30:33 +0100, Emanuele Olivetti wrote:
> I just came across this unexpected behaviour when creating
> a np.array() from two other np.arrays of different shape.
The tuple parsing for the construction of new numpy arrays is pretty
tricky/hairy, and doesn't always do exactly what you'd expect.
The easiest workaround is probably to pre-allocate the array:
In : data = [a, c]
In : x = np.empty(len(data), dtype=object)
In : x[:] = data
In : x.shape
More information about the NumPy-Discussion