Skip to content

Commit fc27d3a

Browse files
committed
Update docstring of reciprocal, rsqrt and sqrt functions to use math where applicable
1 parent 75dd574 commit fc27d3a

File tree

1 file changed

+54
-29
lines changed

1 file changed

+54
-29
lines changed

dpnp/dpnp_iface_trigonometric.py

Lines changed: 54 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -694,8 +694,8 @@ def _get_accumulation_res_dt(a, dtype):
694694
arctanh = atanh # arctanh is an alias for atanh
695695

696696

697-
_CBRT_DOCSTRING = """
698-
Computes positive cube-root for each element :math:`x_i` for input array `x`.
697+
_CBRT_DOCSTRING = r"""
698+
Computes the cube-root for each element :math:`x_i` for input array `x`.
699699
700700
For full documentation refer to :obj:`numpy.cbrt`.
701701
@@ -716,9 +716,8 @@ def _get_accumulation_res_dt(a, dtype):
716716
Returns
717717
-------
718718
out : dpnp.ndarray
719-
An array containing the element-wise positive cube-root.
720-
The data type of the returned array is determined by the Type Promotion
721-
Rules.
719+
An array containing the element-wise cube-root. The data type of the
720+
returned array is determined by the Type Promotion Rules.
722721
723722
Limitations
724723
-----------
@@ -728,7 +727,11 @@ def _get_accumulation_res_dt(a, dtype):
728727
729728
See Also
730729
--------
731-
:obj:`dpnp.sqrt` : Return the positive square-root of an array, element-wise.
730+
:obj:`dpnp.sqrt` : Calculate :math:`\sqrt{x}`, element-wise.
731+
732+
Notes
733+
-----
734+
This function is equivalent to :math:`\sqrt[3]{x}`, element-wise.
732735
733736
Examples
734737
--------
@@ -2047,15 +2050,15 @@ def logsumexp(x, /, *, axis=None, dtype=None, keepdims=False, out=None):
20472050
)
20482051

20492052

2050-
_RECIPROCAL_DOCSTRING = """
2051-
Computes the reciprocal square-root for each element `x_i` for input array `x`.
2053+
_RECIPROCAL_DOCSTRING = r"""
2054+
Computes the reciprocal for each element :math:`x_i` for input array `x`.
20522055
20532056
For full documentation refer to :obj:`numpy.reciprocal`.
20542057
20552058
Parameters
20562059
----------
20572060
x : {dpnp.ndarray, usm_ndarray}
2058-
Input array, expected to have a real-valued floating-point data type.
2061+
Input array, expected to have a floating-point data type.
20592062
out : {None, dpnp.ndarray, usm_ndarray}, optional
20602063
Output array to populate.
20612064
Array must have the correct shape and the expected data type.
@@ -2069,9 +2072,8 @@ def logsumexp(x, /, *, axis=None, dtype=None, keepdims=False, out=None):
20692072
Returns
20702073
-------
20712074
out : dpnp.ndarray
2072-
An array containing the element-wise reciprocals.
2073-
The returned array has a floating-point data type determined
2074-
by the Type Promotion Rules.
2075+
An array containing the element-wise reciprocals. The returned array has
2076+
a floating-point data type determined by the Type Promotion Rules.
20752077
20762078
Limitations
20772079
-----------
@@ -2081,7 +2083,11 @@ def logsumexp(x, /, *, axis=None, dtype=None, keepdims=False, out=None):
20812083
20822084
See Also
20832085
--------
2084-
:obj:`dpnp.rsqrt` : Return the reciprocal square-root of an array, element-wise.
2086+
:obj:`dpnp.rsqrt` : Calculate :math:`\frac{1}{\sqrt{x}}`, element-wise.
2087+
2088+
Notes
2089+
-----
2090+
This function is equivalent to :math:`\frac{1}{x}`, element-wise.
20852091
20862092
Examples
20872093
--------
@@ -2185,8 +2191,9 @@ def reduce_hypot(x, /, *, axis=None, dtype=None, keepdims=False, out=None):
21852191
)
21862192

21872193

2188-
_RSQRT_DOCSTRING = """
2189-
Computes the reciprocal square-root for each element `x_i` for input array `x`.
2194+
_RSQRT_DOCSTRING = r"""
2195+
Computes the reciprocal square-root for each element :math:`x_i` for input
2196+
array `x`.
21902197
21912198
Parameters
21922199
----------
@@ -2204,7 +2211,7 @@ def reduce_hypot(x, /, *, axis=None, dtype=None, keepdims=False, out=None):
22042211
Returns
22052212
-------
22062213
out : dpnp.ndarray
2207-
An array containing the element-wise reciprocal square-root.
2214+
An array containing the element-wise reciprocal square-roots.
22082215
The returned array has a floating-point data type determined by
22092216
the Type Promotion Rules.
22102217
@@ -2216,8 +2223,12 @@ def reduce_hypot(x, /, *, axis=None, dtype=None, keepdims=False, out=None):
22162223
22172224
See Also
22182225
--------
2219-
:obj:`dpnp.sqrt` : Return the positive square-root of an array, element-wise.
2220-
:obj:`dpnp.reciprocal` : Return the reciprocal of an array, element-wise.
2226+
:obj:`dpnp.sqrt` : Calculate :math:`\sqrt{x}`, element-wise.
2227+
:obj:`dpnp.reciprocal` : Calculate :math:`\frac{1}{x}`, element-wise.
2228+
2229+
Notes
2230+
-----
2231+
This function is equivalent to :math:`\frac{1}{\sqrt{x}}`, element-wise.
22212232
22222233
Examples
22232234
--------
@@ -2350,15 +2361,16 @@ def reduce_hypot(x, /, *, axis=None, dtype=None, keepdims=False, out=None):
23502361
)
23512362

23522363

2353-
_SQRT_DOCSTRING = """
2354-
Computes the positive square-root for each element `x_i` of input array `x`.
2364+
_SQRT_DOCSTRING = r"""
2365+
Computes the principal square-root for each element :math:`x_i` of input array
2366+
`x`.
23552367
23562368
For full documentation refer to :obj:`numpy.sqrt`.
23572369
23582370
Parameters
23592371
----------
23602372
x : {dpnp.ndarray, usm_ndarray}
2361-
Input array.
2373+
Input array, expected to have a floating-point data type.
23622374
out : {None, dpnp.ndarray, usm_ndarray}, optional
23632375
Output array to populate.
23642376
Array must have the correct shape and the expected data type.
@@ -2372,9 +2384,8 @@ def reduce_hypot(x, /, *, axis=None, dtype=None, keepdims=False, out=None):
23722384
Returns
23732385
-------
23742386
out : dpnp.ndarray
2375-
An array containing the element-wise positive square-roots of `x`. The
2376-
data type of the returned array is determined by the Type Promotion
2377-
Rules.
2387+
An array containing the element-wise principal square-roots of `x`. The
2388+
data type of the returned array is determined by the Type Promotion Rules.
23782389
23792390
Limitations
23802391
-----------
@@ -2384,8 +2395,23 @@ def reduce_hypot(x, /, *, axis=None, dtype=None, keepdims=False, out=None):
23842395
23852396
See Also
23862397
--------
2387-
:obj:`dpnp.cbrt` : Return the cube-root of an array, element-wise.
2388-
:obj:`dpnp.rsqrt` : Return the reciprocal square-root of an array, element-wise.
2398+
:obj:`dpnp.cbrt` : Calculate :math:`\sqrt[3]{x}`, element-wise.
2399+
:obj:`dpnp.rsqrt` : Calculate :math:`\frac{1}{\sqrt{x}}`, element-wise.
2400+
2401+
Notes
2402+
-----
2403+
This function is equivalent to :math:`\sqrt{x}`, element-wise.
2404+
2405+
By convention, the branch cut of the square root is the negative real axis
2406+
:math:`(-\infty, 0)`.
2407+
2408+
The square root is a continuous function from above the branch cut, taking into
2409+
account the sign of the imaginary component.
2410+
2411+
Accordingly, for complex arguments, the function returns the square root in the
2412+
range of the right half-plane, including the imaginary axis (i.e., the plane
2413+
defined by :math:`[0, +\infty)` along the real axis and
2414+
:math:`(-\infty, +\infty)` along the imaginary axis).
23892415
23902416
Examples
23912417
--------
@@ -2410,7 +2436,7 @@ def reduce_hypot(x, /, *, axis=None, dtype=None, keepdims=False, out=None):
24102436
)
24112437

24122438

2413-
_SQUARE_DOCSTRING = """
2439+
_SQUARE_DOCSTRING = r"""
24142440
Squares each element `x_i` of input array `x`.
24152441
24162442
For full documentation refer to :obj:`numpy.square`.
@@ -2445,8 +2471,7 @@ def reduce_hypot(x, /, *, axis=None, dtype=None, keepdims=False, out=None):
24452471
--------
24462472
:obj:`dpnp..linalg.matrix_power` : Raise a square matrix
24472473
to the (integer) power `n`.
2448-
:obj:`dpnp.sqrt` : Return the positive square-root of an array,
2449-
element-wise.
2474+
:obj:`dpnp.sqrt` : Calculate :math:`\sqrt{x}`, element-wise.
24502475
:obj:`dpnp.power` : First array elements raised to powers
24512476
from second array, element-wise.
24522477

0 commit comments

Comments
 (0)