10000 Merge pull request #25664 from wingkitlee0/doc-partition · mattip/numpy@0a4b2b8 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0a4b2b8

Browse files
authored
Merge pull request numpy#25664 from wingkitlee0/doc-partition
DOC: minor improvement to the partition() docstrings
2 parents 877ca75 + c459b6d commit 0a4b2b8

File tree

2 files changed

+24
-23
lines changed

2 files changed

+24
-23
lines changed

numpy/_core/_add_newdocs.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2883,7 +2883,7 @@
28832883
add_newdoc('numpy._core.multiarray', 'ndarray', ('mT',
28842884
"""
28852885
View of the matrix transposed array.
2886-
2886+
28872887
The matrix transpose is the transpose of the last two dimensions, even
28882888
if the array is of higher dimension.
28892889
@@ -2893,7 +2893,7 @@
28932893
------
28942894
ValueError
28952895
If the array is of dimension less than 2.
2896-
2896+
28972897
Examples
28982898
--------
28992899
>>> a = np.array([[1, 2], [3, 4]])
@@ -2903,7 +2903,7 @@
29032903
>>> a.mT
29042904
array([[1, 3],
29052905
[2, 4]])
2906-
2906+
29072907
>>> a = np.arange(8).reshape((2, 2, 2))
29082908
>>> a
29092909
array([[[0, 1],
@@ -2917,7 +2917,7 @@
29172917
<BLANKLINE>
29182918
[[4, 6],
29192919
[5, 7]]])
2920-
2920+
29212921
"""))
29222922
##############################################################################
29232923
#
@@ -4112,11 +4112,12 @@
41124112
"""
41134113
a.partition(kth, axis=-1, kind='introselect', order=None)
41144114
4115-
Rearranges the elements in the array in such a way that the value of the
4116-
element in kth position is in the position it would be in a sorted array.
4117-
All elements smaller than the kth element are moved before this element and
4118-
all equal or greater are moved behind it. The ordering of the elements in
4119-
the two partitions is undefined.
4115+
Partially sorts the elements in the array in such a way that the value of
4116+
the element in k-th position is in the position it would be in a sorted
4117+
array. In the output array, all elements smaller than the k-th element
4118+
are located to the left of this element and all equal or greater are
4119+
located to its right. The ordering of the elements in the two partitions
4120+
on the either side of the k-th element in the output array is undefined.
41204121
41214122
.. versionadded:: 1.8.0
41224123
@@ -4929,7 +4930,7 @@
49294930
"""
49304931
The identity value.
49314932
4932-
Data attribute containing the identity element for the ufunc,
4933+
Data attribute containing the identity element for the ufunc,
49334934
if it has one. If it does not, the attribute value is None.
49344935
49354936
Examples
@@ -4953,7 +4954,7 @@
49534954
49544955
Notes
49554956
-----
4956-
Typically this value will be one more than what you might expect
4957+
Typically this value will be one more than what you might expect
49574958
because all ufuncs take the optional "out" argument.
49584959
49594960
Examples
@@ -5919,7 +5920,7 @@
59195920
If present, the optional title can be any object (if it is a string
59205921
or unicode then it will also be a key in the fields dictionary,
59215922
otherwise it's meta-data). Notice also that the first two elements
5922-
of the tuple can be passed directly as arguments to the
5923+
of the tuple can be passed directly as arguments to the
59235924
``ndarray.getfield`` and ``ndarray.setfield`` methods.
59245925
59255926
See Also

numpy/_core/fromnumeric.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -697,13 +697,13 @@ def partition(a, kth, axis=-1, kind='introselect', order=None):
697697
"""
698698
Return a partitioned copy of an array.
699699
700-
Creates a copy of the array with its elements rearranged in such a
701-
way that the value of the element in k-th position is in the position
702-
the value would be in a sorted array. In the partitioned array, all
703-
elements before the k-th element are less than or equal to that
704-
element, and all the elements after the k-th element are greater than
705-
or equal to that element. The ordering of the elements in the two
706-
partitions is undefined.
700+
Creates a copy of the array and partially sorts it in such a way that
701+
the value of the element in k-th position is in the position it would be
702+
in a sorted array. In the output array, all elements smaller than the k-th
703+
element are located to the left of this element and all equal or greater
704+
are located to its right. The ordering of the elements in the two
705+
partitions on the either side of the k-th element in the output array is
706+
undefined.
707707
708708
.. versionadded:: 1.8.0
709709
@@ -884,7 +884,7 @@ def argpartition(a, kth, axis=-1, kind='introselect', order=None):
884884
>>> x = np.array([[3, 4, 2], [1, 3, 1]])
885885
>>> index_array = np.argpartition(x, kth=1, axis=-1)
886886
>>> # below is the same as np.partition(x, kth=1)
887-
>>> np.take_along_axis(x, index_array, axis=-1)
887+
>>> np.take_along_axis(x, index_array, axis=-1)
888888
array([[2, 3, 4],
889889
[1, 1, 3]])
890890
@@ -1364,7 +1364,7 @@ def argmin(a, axis=None, out=None, *, keepdims=np._NoValue):
13641364
array([[2],
13651365
[0]])
13661366
>>> # Same as np.amax(x, axis=-1)
1367-
>>> np.take_along_axis(x, np.expand_dims(index_array, axis=-1),
1367+
>>> np.take_along_axis(x, np.expand_dims(index_array, axis=-1),
13681368
... axis=-1).squeeze(axis=-1)
13691369
array([2, 0])
13701370
@@ -1437,7 +1437,7 @@ def searchsorted(a, v, side='left', sorter=None):
14371437
As of NumPy 1.4.0 `searchsorted` works with real/complex arrays containing
14381438
`nan` values. The enhanced sort order is documented in `sort`.
14391439
1440-
This function uses the same algorithm as the builtin python
1440+
This function uses the same algorithm as the builtin python
14411441
`bisect.bisect_left` (``side='left'``) and `bisect.bisect_right`
14421442
(``side='right'``) functions, which is also vectorized
14431443
in the `v` argument.
@@ -2371,7 +2371,7 @@ def sum(a, axis=None, dtype=None, out=None, keepdims=np._NoValue,
23712371
return res
23722372

23732373
return _wrapreduction(
2374-
a, np.add, 'sum', axis, dtype, out,
2374+
a, np.add, 'sum', axis, dtype, out,
23752375
keepdims=keepdims, initial=initial, where=where
23762376
)
23772377

0 commit comments

Comments
 (0)
0