I have a numpy.array of numpy arrays of different shapes. When I call np.sum(my_array) I get this error:
Traceback (most recent call last):
return umr_sum(a, axis, dtype, out, keepdims)
ValueError: operands could not be broadcast together with shapes (13,5) (5,3)
All I want is sum of all values across all arrays like sum(my_array) = some float number
Is there some parameter that I missed or another method? I can only think of something like this
np.sum([np.sum(a) for a in my_array])
Is this an optimal way?
Update:
print(type(my_array))
print((my_array).shape)
print([(type(sub_array), sub_array.shape) for sub_array in my_array])
output:
<class 'numpy.ndarray'>
(2,)
[(<class 'numpy.ndarray'>, (13, 5)), (<class 'numpy.ndarray'>, (5, 3))]
my_array? Is it a python list containing numpy arrays?type(my_array)for us.