Skip to content

Commit 58eb8df

Browse files
committed
Update docstring of deg2rad, rad2deg, radians, and degrees functions to use math where applicable
1 parent fcc0390 commit 58eb8df

File tree

1 file changed

+46
-22
lines changed

1 file changed

+46
-22
lines changed

dpnp/dpnp_iface_trigonometric.py

Lines changed: 46 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -960,15 +960,16 @@ def cumlogsumexp(
960960
)
961961

962962

963-
_DEG2RAD_DOCSTRING = """
964-
Convert angles from degrees to radians.
963+
_DEG2RAD_DOCSTRING = r"""
964+
Convert angles from degrees to radians for each element :math:`x_i` for input
965+
array `x`.
965966
966967
For full documentation refer to :obj:`numpy.deg2rad`.
967968
968969
Parameters
969970
----------
970971
x : {dpnp.ndarray, usm_ndarray}
971-
Angles in degrees.
972+
Input array, expected to have a real-valued floating-point data type.
972973
out : {None, dpnp.ndarray, usm_ndarray}, optional
973974
Output array to populate.
974975
Array must have the correct shape and the expected data type.
@@ -982,8 +983,9 @@ def cumlogsumexp(
982983
Returns
983984
-------
984985
out : dpnp.ndarray
985-
The corresponding angle in radians. The data type of the returned array is
986-
determined by the Type Promotion Rules.
986+
An array containing the element-wise angle in radians.
987+
The data type of the returned array is determined by the Type Promotion
988+
Rules.
987989
988990
Limitations
989991
-----------
@@ -999,7 +1001,9 @@ def cumlogsumexp(
9991001
10001002
Notes
10011003
-----
1002-
dpnp.deg2rad(x) is ``x * pi / 180``.
1004+
The mathematical definition is
1005+
1006+
.. math:: \operatorname{deg2rad}(x) = \frac{x * \pi}{180}
10031007
10041008
Examples
10051009
--------
@@ -1018,15 +1022,16 @@ def cumlogsumexp(
10181022
)
10191023

10201024

1021-
_DEGREES_DOCSTRING = """
1022-
Convert angles from radians to degrees.
1025+
_DEGREES_DOCSTRING = r"""
1026+
Convert angles from degrees to radians for each element :math:`x_i` for input
1027+
array `x`.
10231028
10241029
For full documentation refer to :obj:`numpy.degrees`.
10251030
10261031
Parameters
10271032
----------
10281033
x : {dpnp.ndarray, usm_ndarray}
1029-
Input array in radians.
1034+
Input array, expected to have a real-valued floating-point data type.
10301035
out : {None, dpnp.ndarray, usm_ndarray}, optional
10311036
Output array to populate.
10321037
Array must have the correct shape and the expected data type.
@@ -1040,8 +1045,9 @@ def cumlogsumexp(
10401045
Returns
10411046
-------
10421047
out : dpnp.ndarray
1043-
The corresponding degree values. The data type of the returned array is
1044-
determined by the Type Promotion Rules.
1048+
An array containing the element-wise angle in degrees.
1049+
The data type of the returned array is determined by the Type Promotion
1050+
Rules.
10451051
10461052
Limitations
10471053
-----------
@@ -1053,6 +1059,12 @@ def cumlogsumexp(
10531059
--------
10541060
:obj:`dpnp.rad2deg` : Equivalent function.
10551061
1062+
Notes
1063+
-----
1064+
The mathematical definition is
1065+
1066+
.. math:: \operatorname{degrees}(x) = \frac{180 * x}{\pi}
1067+
10561068
Examples
10571069
--------
10581070
>>> import dpnp as np
@@ -1811,15 +1823,16 @@ def logsumexp(x, /, *, axis=None, dtype=None, keepdims=False, out=None):
18111823
)
18121824

18131825

1814-
_RAD2DEG_DOCSTRING = """
1815-
Convert angles from radians to degrees.
1826+
_RAD2DEG_DOCSTRING = r"""
1827+
Convert angles from degrees to radians for each element :math:`x_i` for input
1828+
array `x`.
18161829
18171830
For full documentation refer to :obj:`numpy.rad2deg`.
18181831
18191832
Parameters
18201833
----------
18211834
x : {dpnp.ndarray, usm_ndarray}
1822-
Angle in radians.
1835+
Input array, expected to have a real-valued floating-point data type.
18231836
out : {None, dpnp.ndarray, usm_ndarray}, optional
18241837
Output array to populate.
18251838
Array must have the correct shape and the expected data type.
@@ -1833,8 +1846,9 @@ def logsumexp(x, /, *, axis=None, dtype=None, keepdims=False, out=None):
18331846
Returns
18341847
-------
18351848
out : dpnp.ndarray
1836-
The corresponding angle in degrees. The data type of the returned array is
1837-
determined by the Type Promotion Rules.
1849+
An array containing the element-wise angle in degrees.
1850+
The data type of the returned array is determined by the Type Promotion
1851+
Rules.
18381852
18391853
Limitations
18401854
-----------
@@ -1850,7 +1864,9 @@ def logsumexp(x, /, *, axis=None, dtype=None, keepdims=False, out=None):
18501864
18511865
Notes
18521866
-----
1853-
dpnp.rad2deg(x) is ``180 * x / pi``.
1867+
The mathematical definition is
1868+
1869+
.. math:: \operatorname{rad2deg}(x) = \frac{180 * x}{\pi}
18541870
18551871
Examples
18561872
--------
@@ -1869,15 +1885,16 @@ def logsumexp(x, /, *, axis=None, dtype=None, keepdims=False, out=None):
18691885
)
18701886

18711887

1872-
_RADIANS_DOCSTRING = """
1873-
Convert angles from degrees to radians.
1888+
_RADIANS_DOCSTRING = r"""
1889+
Convert angles from degrees to radians for each element :math:`x_i` for input
1890+
array `x`.
18741891
18751892
For full documentation refer to :obj:`numpy.radians`.
18761893
18771894
Parameters
18781895
----------
18791896
x : {dpnp.ndarray, usm_ndarray}
1880-
Input array in degrees.
1897+
Input array, expected to have a real-valued floating-point data type.
18811898
out : {None, dpnp.ndarray, usm_ndarray}, optional
18821899
Output array to populate.
18831900
Array must have the correct shape and the expected data type.
@@ -1891,8 +1908,9 @@ def logsumexp(x, /, *, axis=None, dtype=None, keepdims=False, out=None):
18911908
Returns
18921909
-------
18931910
out : dpnp.ndarray
1894-
The corresponding radian values. The data type of the returned array is
1895-
determined by the Type Promotion Rules.
1911+
An array containing the element-wise angle in radians.
1912+
The data type of the returned array is determined by the Type Promotion
1913+
Rules.
18961914
18971915
Limitations
18981916
-----------
@@ -1904,6 +1922,12 @@ def logsumexp(x, /, *, axis=None, dtype=None, keepdims=False, out=None):
19041922
--------
19051923
:obj:`dpnp.deg2rad` : Equivalent function.
19061924
1925+
Notes
1926+
-----
1927+
The mathematical definition is
1928+
1929+
.. math:: \operatorname{radians}(x) = \frac{x * \pi}{180}
1930+
19071931
Examples
19081932
--------
19091933
>>> import dpnp as np

0 commit comments

Comments
 (0)