The shape of a matrix is the tuple of its dimensions. The shape of an matrix is the tuple (n, m). It can be obtained by the function shape:
M = identity(3) shape(M) # (3, 3)
or, simply by its attribute
M.shape # (3, 3)
However, the advantage of using shape as a function and not as an attribute is that the function may be used on scalars and lists as well. This may come in handy when code is supposed to work with both scalars and arrays:
shape(1.) # () shape([1,2]) # (2,) shape([[1,2]]) # (1,2)
For a vector, the shape is a singleton containing the length of that vector:
v = array([1., 2., 1., 4.]) shape(v) # (4,) <- singleton (1-tuple)