0

I need to convert a list of numpy arrays into an array of arrays in order to save it using numpy.save (calling save direclty on the list would sort of call numpy.array anyway). When the shapes of the arrays in the list are dissimilar, everything goes fine. For example:

data = np.array([np.zeros((18, 10)), np.zeros((19, 11))])

works, and data has shape (2,), which is what I expect. However, when the shapes of the arrays are the same, for example

data = np.array([np.zeros((18, 10)), np.zeros((18, 10))])

data get the shape (2, 18, 10). How to prevent this behavior?

Even worse, if I only have the same shape in axis 0:

data = np.array([np.zeros((18, 10)), np.zeros((18, 11))])

I get an error:

ValueError: could not broadcast input array from shape (18,10) into shape (18)

Any idea? Thank you for your help!

0 Answers0