Skip to content

Commit

Permalink
DOC: Recommend adding dimension to switch between row and column vect…
Browse files Browse the repository at this point in the history
…ors (numpy#12973)

* DOC: Recommend using reshape instead of matrix for vector transpose

* Rephrase doc advice for 1-D vector transpose

Recommend adding a dimension instead of using `reshape`.
Per @eric-wieser, makes explanation more technical.

* Fix grammar
  • Loading branch information
iansan5653 authored and seberg committed Feb 22, 2019
1 parent 67e20d0 commit 04b4220
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions numpy/core/_add_newdocs.py
Original file line number Diff line number Diff line change
Expand Up @@ -4145,9 +4145,11 @@
Returns a view of the array with axes transposed.
For a 1-D array, this has no effect. (To change between column and
row vectors, first cast the 1-D array into a matrix object.)
For a 2-D array, this is the usual matrix transpose.
For a 1-D array this has no effect, as a transposed vector is simply the
same vector. To convert a 1-D array into a 2D column vector, an additional
dimension must be added. `np.atleast2d(a).T` achieves this, as does
`a[:, np.newaxis]`.
For a 2-D array, this is a standard matrix transpose.
For an n-D array, if axes are given, their order indicates how the
axes are permuted (see Examples). If axes are not provided and
``a.shape = (i[0], i[1], ... i[n-2], i[n-1])``, then
Expand All @@ -4173,6 +4175,7 @@
See Also
--------
ndarray.T : Array property returning the array transposed.
ndarray.reshape : Give a new shape to an array without changing its data.
Examples
--------
Expand Down

0 comments on commit 04b4220

Please sign in to comment.