Numpy arrays are set up so 0D arrays are scalars, 1D arrays are vectors, 2D arrays are matrices (and the linear map associated with them), and higher dimensional arrays are unimportant for this post.
This can be seen from the length of
(), a zero length tuple,
is a length one tuple, and you get the idea from there.
The transpose of a 1D array of shape
(n,) is still a 1D array of the
same shape, rather than a 2D array of shape
(1,n). In other words,
transposing 1D arrays doesn’t do anything.
This will only really make sense if you understand the transpose and its relationship to dual spaces.
Numpy uses the transpose only to express the transpose of a linear map,
not as a handy way to get a linear functional (vector in the dual
space) from your vector1. To do that, you have to explicitly make
your vector into a linear map (of shape
In this way, Numpy draws a sharp line between vectors and the linear maps acting on them. All isomorphisms that allow you to conflate the two don’t fly in Numpy, so you’ll have to do the conversions explicitly2.