Skip to content

Commit 557e66d

Browse files
committed
Complete docstring of dpnp.pto
1 parent 36bcffa commit 557e66d

File tree

1 file changed

+35
-6
lines changed

1 file changed

+35
-6
lines changed

dpnp/dpnp_iface_statistics.py

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1181,20 +1181,39 @@ def ptp(
11811181
11821182
For full documentation refer to :obj:`numpy.ptp`.
11831183
1184+
Parameters
1185+
----------
1186+
a : {dpnp.ndarray, usm_ndarray}
1187+
Input array.
1188+
axis : {None, int, tuple of ints}, optional
1189+
Axis along which to find the peaks. By default, flatten the array.
1190+
`axis` may be negative, in which case it counts from the last to the
1191+
first axis. If this is a tuple of ints, a reduction is performed on
1192+
multiple axes, instead of a single axis or all the axes as before.
1193+
1194+
Default: ``None``.
1195+
out : {None, dpnp.ndarray, usm_ndarray}, optional
1196+
Alternative output array in which to place the result. It must have the
1197+
same shape and buffer length as the expected output, but the type of
1198+
the output values will be cast if necessary.
1199+
1200+
Default: ``None``.
1201+
keepdims : {None, bool}, optional
1202+
If this is set to ``True``, the axes which are reduced are left in the
1203+
result as dimensions with size one. With this option, the result will
1204+
broadcast correctly against the input array.
1205+
1206+
Default: ``None``.
1207+
11841208
Returns
11851209
-------
11861210
ptp : dpnp.ndarray
11871211
The range of a given array.
11881212
1189-
Limitations
1190-
-----------
1191-
Input array is supported as :class:`dpnp.dpnp.ndarray` or
1192-
:class:`dpctl.tensor.usm_ndarray`.
1193-
11941213
Examples
11951214
--------
11961215
>>> import dpnp as np
1197-
>>> x = np.array([[4, 9, 2, 10],[6, 9, 7, 12]])
1216+
>>> x = np.array([[4, 9, 2, 10], [6, 9, 7, 12]])
11981217
>>> np.ptp(x, axis=1)
11991218
array([8, 6])
12001219
@@ -1204,6 +1223,16 @@ def ptp(
12041223
>>> np.ptp(x)
12051224
array(10)
12061225
1226+
This example shows that a negative value can be returned when the input is
1227+
an array of signed integers:
1228+
1229+
>>> y = np.array([[1, 127],
1230+
... [0, 127],
1231+
... [-1, 127],
1232+
... [-2, 127]], dtype="i1")
1233+
>>> np.ptp(y, axis=1)
1234+
array([ 126, 127, -128, -127], dtype=int8)
1235+
12071236
"""
12081237

12091238
return dpnp.subtract(

0 commit comments

Comments
 (0)