I want to have a numpy array of two another arrays (each of them has different shape). As I know, for this reason one must use: dtype = object in the definition of the main array.
For example, let us define (in Python 2.7) our arrays as
a0 = np.arange(2*2).reshape(2,2)
a1 = np.arange(3*3*2).reshape(3,3,2)
b = np.array([a0,a1], dtype = object)
This works perfect: b[1] is the same as a1. But if I change the dimension in a0 from (2,2) to (3,3) something strange happens:
a0 = np.arange(3*3).reshape(3,3)
a1 = np.arange(3*3*2).reshape(3,3,2)
b = np.array([a0,a1], dtype = object)
This time b[1] and a1 are not equal, they even have different shapes. What is the reason of this strange behavior?
Perhaps there is a completely different solution for me. But I don't want to use lists or tuples because I want to allow addition such as b + b. It is clear that I can write my own class for this purpose but is there any simpler way?