The number of dimensions of an array is obtained with the function ndim or using the array attribute ndim:
ndim(A) # 2 A.ndim # 2
Note that the number of dimensions, given by the function ndim, of a tensor T (a vector, matrix, or higher-order tensor) is always equal to the length of its shape:
T = zeros((2,2,3)) # tensor of shape (2,2,3); three dimensions ndim(T) # 3 len(shape(T)) # 3