First, we will cover some tooling prerequisites.
NumPy
The fundamental library for scientific computing with python, centered around a powerful N-dimensional array object.
In NumPy each dimension is called an axis. The number of axes is called the rank, which is exactly what the rank of a matrix refers to. The list of lengths of an array is called the shape of that array. The rank is equal to the shape’s length while the size of the array is the total number of elements, which is all the axis lengths multiplied together.
Consider this matrix below, it’s got two axes, one is of length 3 and the other is of length 4. We can say that its shape is (3, 4) while the rank is 2 (length of shape). Size here would be the 3 x 4 which is 12.
import numpy as np
a = np.zeros((3, 4))
#array([[0., 0., 0., 0.],
# [0., 0., 0., 0.],
# [0., 0., 0., 0.]])
a.shape # gives the shape, (3, 4)
a.ndim # len(a.shape) = 2
a.size # 12