If you have a multi-dimensional array, len() might not give you the value you are looking for. For instance:
import numpy as np a = np.arange(10).reshape(2, 5) print len(a) == 2
This code block will return true, telling you the size of the array is 2. However, there are in fact 10 elements in this 2D array. In the case of multi-dimensional arrays, len() gives you the length of the first dimension of the array i.e.
import numpy as np len(a) == np.shape(a)
To get the number of elements in a multi-dimensional array of arbitrary shape:
import numpy as np size = 1 for dim in np.shape(a): size *= dim