8000 DOC: clarify documentation for transpose() (gh-15024) · numpy/numpy@95e570c · GitHub
[go: up one dir, main page]

Skip to content

Commit 95e570c

Browse files
danpoveyseberg
authored andcommitted
DOC: clarify documentation for transpose() (gh-15024)
Clarify axes argument and general text of `np.transpose`.
1 parent ab89b1a commit 95e570c

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

numpy/core/fromnumeric.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -604,15 +604,20 @@ def _transpose_dispatcher(a, axes=None):
604604
@array_function_dispatch(_transpose_dispatcher)
605605
def transpose(a, axes=None):
606606
"""
607-
Permute the dimensions of an array.
607+
Reverse or permute the axes of an array; returns the modified array.
608+
609+
For an array a with two axes, transpose(a) gives the matrix transpose.
608610
609611
Parameters
610612
----------
611613
a : array_like
612614
Input array.
613-
axes : list of ints, optional
614-
By default, reverse the dimensions, otherwise permute the axes
615-
according to the values given.
615+
axes : tuple or list of ints, optional
616+
If specified, it must be a tuple or list which contains a permutation of
617+
[0,1,..,N-1] where N is the number of axes of a. The i'th axis of the
618+
returned array will correspond to the axis numbered ``axes[i]`` of the
619+
input. If not specified, defaults to ``range(a.ndim)[::-1]``, which
620+
reverses the order of the axes.
616621
617622
Returns
618623
-------
@@ -797,7 +802,7 @@ def argpartition(a, kth, axis=-1, kind='introselect', order=None):
797802
partition : Describes partition algorithms used.
798803
ndarray.partition : Inplace partition.
799804
argsort : Full indirect sort.
800-
take_along_axis : Apply ``index_array`` from argpartition
805+
take_along_axis : Apply ``index_array`` from argpartition
801806
to an array as if by calling partition.
802807
803808
Notes
@@ -1039,7 +1044,7 @@ def argsort(a, axis=-1, kind=None, order=None):
10391044
lexsort : Indirect stable sort with multiple keys.
10401045
ndarray.sort : Inplace sort.
10411046
argpartition : Indirect partial sort.
1042-
take_along_axis : Apply ``index_array`` from argsort
1047+
take_along_axis : Apply ``index_array`` from argsort
10431048
to an array as if by calling sort.
10441049
10451050
Notes
@@ -1136,7 +1141,7 @@ def argmax(a, axis=None, out=None):
11361141
ndarray.argmax, argmin
11371142
amax : The maximum value along a given axis.
11381143
unravel_index : Convert a flat index into an index tuple.
1139-
take_along_axis : Apply ``np.expand_dims(index_array, axis)``
1144+
take_along_axis : Apply ``np.expand_dims(index_array, axis)``
11401145
from argmax to an array as if by calling max.
11411146
11421147
Notes
@@ -1217,7 +1222,7 @@ def argmin(a, axis=None, out=None):
12171222
ndarray.argmin, argmax
12181223
amin : The minimum value along a given axis.
12191224
unravel_index : Convert a flat index into an index tuple.
1220-
take_along_axis : Apply ``np.expand_dims(index_array, axis)``
1225+
take_along_axis : Apply ``np.expand_dims(index_array, axis)``
12211226
from argmin to an array as if by calling min.
12221227
12231228
Notes

0 commit comments

Comments
 (0)
0