Skip to content

Commit 232b9f8

Browse files
misutothHyukjinKwon
authored andcommitted
[SPARK-23329][SQL] Fix documentation of trigonometric functions
## What changes were proposed in this pull request? Provide more details in trigonometric function documentations. Referenced `java.lang.Math` for further details in the descriptions. ## How was this patch tested? Ran full build, checked generated documentation manually Author: Mihaly Toth <[email protected]> Closes #20618 from misutoth/trigonometric-doc. (cherry picked from commit a366b95) Signed-off-by: hyukjinkwon <[email protected]>
1 parent 88dd335 commit 232b9f8

File tree

4 files changed

+248
-107
lines changed

4 files changed

+248
-107
lines changed

R/pkg/R/functions.R

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,8 @@ setMethod("abs",
278278
})
279279

280280
#' @details
281-
#' \code{acos}: Computes the cosine inverse of the given value; the returned angle is in
282-
#' the range 0.0 through pi.
281+
#' \code{acos}: Returns the inverse cosine of the given value,
282+
#' as if computed by \code{java.lang.Math.acos()}
283283
#'
284284
#' @rdname column_math_functions
285285
#' @export
@@ -334,8 +334,8 @@ setMethod("ascii",
334334
})
335335

336336
#' @details
337-
#' \code{asin}: Computes the sine inverse of the given value; the returned angle is in
338-
#' the range -pi/2 through pi/2.
337+
#' \code{asin}: Returns the inverse sine of the given value,
338+
#' as if computed by \code{java.lang.Math.asin()}
339339
#'
340340
#' @rdname column_math_functions
341341
#' @export
@@ -349,8 +349,8 @@ setMethod("asin",
349349
})
350350

351351
#' @details
352-
#' \code{atan}: Computes the tangent inverse of the given value; the returned angle is in the range
353-
#' -pi/2 through pi/2.
352+
#' \code{atan}: Returns the inverse tangent of the given value,
353+
#' as if computed by \code{java.lang.Math.atan()}
354354
#'
355355
#' @rdname column_math_functions
356356
#' @export
@@ -613,7 +613,8 @@ setMethod("covar_pop", signature(col1 = "characterOrColumn", col2 = "characterOr
613613
})
614614

615615
#' @details
616-
#' \code{cos}: Computes the cosine of the given value. Units in radians.
616+
#' \code{cos}: Returns the cosine of the given value,
617+
#' as if computed by \code{java.lang.Math.cos()}. Units in radians.
617618
#'
618619
#' @rdname column_math_functions
619620
#' @aliases cos cos,Column-method
@@ -627,7 +628,8 @@ setMethod("cos",
627628
})
628629

629630
#' @details
630-
#' \code{cosh}: Computes the hyperbolic cosine of the given value.
631+
#' \code{cosh}: Returns the hyperbolic cosine of the given value,
632+
#' as if computed by \code{java.lang.Math.cosh()}.
631633
#'
632634
#' @rdname column_math_functions
633635
#' @aliases cosh cosh,Column-method
@@ -1463,7 +1465,8 @@ setMethod("sign", signature(x = "Column"),
14631465
})
14641466

14651467
#' @details
1466-
#' \code{sin}: Computes the sine of the given value. Units in radians.
1468+
#' \code{sin}: Returns the sine of the given value,
1469+
#' as if computed by \code{java.lang.Math.sin()}. Units in radians.
14671470
#'
14681471
#' @rdname column_math_functions
14691472
#' @aliases sin sin,Column-method
@@ -1477,7 +1480,8 @@ setMethod("sin",
14771480
})
14781481

14791482
#' @details
1480-
#' \code{sinh}: Computes the hyperbolic sine of the given value.
1483+
#' \code{sinh}: Returns the hyperbolic sine of the given value,
1484+
#' as if computed by \code{java.lang.Math.sinh()}.
14811485
#'
14821486
#' @rdname column_math_functions
14831487
#' @aliases sinh sinh,Column-method
@@ -1653,7 +1657,9 @@ setMethod("sumDistinct",
16531657
})
16541658

16551659
#' @details
1656-
#' \code{tan}: Computes the tangent of the given value. Units in radians.
1660+
#' \code{tan}: Returns the tangent of the given value,
1661+
#' as if computed by \code{java.lang.Math.tan()}.
1662+
#' Units in radians.
16571663
#'
16581664
#' @rdname column_math_functions
16591665
#' @aliases tan tan,Column-method
@@ -1667,7 +1673,8 @@ setMethod("tan",
16671673
})
16681674

16691675
#' @details
1670-
#' \code{tanh}: Computes the hyperbolic tangent of the given value.
1676+
#' \code{tanh}: Returns the hyperbolic tangent of the given value,
1677+
#' as if computed by \code{java.lang.Math.tanh()}.
16711678
#'
16721679
#' @rdname column_math_functions
16731680
#' @aliases tanh tanh,Column-method
@@ -1973,7 +1980,8 @@ setMethod("year",
19731980

19741981
#' @details
19751982
#' \code{atan2}: Returns the angle theta from the conversion of rectangular coordinates
1976-
#' (x, y) to polar coordinates (r, theta). Units in radians.
1983+
#' (x, y) to polar coordinates (r, theta),
1984+
#' as if computed by \code{java.lang.Math.atan2()}. Units in radians.
19771985
#'
19781986
#' @rdname column_math_functions
19791987
#' @aliases atan2 atan2,Column-method

python/pyspark/sql/functions.py

Lines changed: 38 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -106,18 +106,15 @@ def _():
106106

107107
_functions_1_4 = {
108108
# unary math functions
109-
'acos': 'Computes the cosine inverse of the given value; the returned angle is in the range' +
110-
'0.0 through pi.',
111-
'asin': 'Computes the sine inverse of the given value; the returned angle is in the range' +
112-
'-pi/2 through pi/2.',
113-
'atan': 'Computes the tangent inverse of the given value; the returned angle is in the range' +
114-
'-pi/2 through pi/2',
109+
'acos': ':return: inverse cosine of `col`, as if computed by `java.lang.Math.acos()`',
110+
'asin': ':return: inverse sine of `col`, as if computed by `java.lang.Math.asin()`',
111+
'atan': ':return: inverse tangent of `col`, as if computed by `java.lang.Math.atan()`',
115112
'cbrt': 'Computes the cube-root of the given value.',
116113
'ceil': 'Computes the ceiling of the given value.',
117-
'cos': """Computes the cosine of the given value.
118-
119-
:param col: :class:`DoubleType` column, units in radians.""",
120-
'cosh': 'Computes the hyperbolic cosine of the given value.',
114+
'cos': """:param col: angle in radians
115+
:return: cosine of the angle, as if computed by `java.lang.Math.cos()`.""",
116+
'cosh': """:param col: hyperbolic angle
117+
:return: hyperbolic cosine of the angle, as if computed by `java.lang.Math.cosh()`""",
121118
'exp': 'Computes the exponential of the given value.',
122119
'expm1': 'Computes the exponential of the given value minus one.',
123120
'floor': 'Computes the floor of the given value.',
@@ -127,14 +124,16 @@ def _():
127124
'rint': 'Returns the double value that is closest in value to the argument and' +
128125
' is equal to a mathematical integer.',
129126
'signum': 'Computes the signum of the given value.',
130-
'sin': """Computes the sine of the given value.
131-
132-
:param col: :class:`DoubleType` column, units in radians.""",
133-
'sinh': 'Computes the hyperbolic sine of the given value.',
134-
'tan': """Computes the tangent of the given value.
135-
136-
:param col: :class:`DoubleType` column, units in radians.""",
137-
'tanh': 'Computes the hyperbolic tangent of the given value.',
127+
'sin': """:param col: angle in radians
128+
:return: sine of the angle, as if computed by `java.lang.Math.sin()`""",
129+
'sinh': """:param col: hyperbolic angle
130+
:return: hyperbolic sine of the given value,
131+
as if computed by `java.lang.Math.sinh()`""",
132+
'tan': """:param col: angle in radians
133+
:return: tangent of the given value, as if computed by `java.lang.Math.tan()`""",
134+
'tanh': """:param col: hyperbolic angle
135+
:return: hyperbolic tangent of the given value,
136+
as if computed by `java.lang.Math.tanh()`""",
138137
'toDegrees': '.. note:: Deprecated in 2.1, use :func:`degrees` instead.',
139138
'toRadians': '.. note:: Deprecated in 2.1, use :func:`radians` instead.',
140139
'bitwiseNOT': 'Computes bitwise not.',
@@ -173,16 +172,31 @@ def _():
173172

174173
_functions_2_1 = {
175174
# unary math functions
176-
'degrees': 'Converts an angle measured in radians to an approximately equivalent angle ' +
177-
'measured in degrees.',
178-
'radians': 'Converts an angle measured in degrees to an approximately equivalent angle ' +
179-
'measured in radians.',
175+
'degrees': """
176+
Converts an angle measured in radians to an approximately equivalent angle
177+
measured in degrees.
178+
:param col: angle in radians
179+
:return: angle in degrees, as if computed by `java.lang.Math.toDegrees()`
180+
""",
181+
'radians': """
182+
Converts an angle measured in degrees to an approximately equivalent angle
183+
measured in radians.
184+
:param col: angle in degrees
185+
:return: angle in radians, as if computed by `java.lang.Math.toRadians()`
186+
""",
180187
}
181188

182189
# math functions that take two arguments as input
183190
_binary_mathfunctions = {
184-
'atan2': 'Returns the angle theta from the conversion of rectangular coordinates (x, y) to' +
185-
'polar coordinates (r, theta). Units in radians.',
191+
'atan2': """
192+
:param col1: coordinate on y-axis
193+
:param col2: coordinate on x-axis
194+
:return: the `theta` component of the point
195+
(`r`, `theta`)
196+
in polar coordinates that corresponds to the point
197+
(`x`, `y`) in Cartesian coordinates,
198+
as if computed by `java.lang.Math.atan2()`
199+
""",
186200
'hypot': 'Computes ``sqrt(a^2 + b^2)`` without intermediate overflow or underflow.',
187201
'pow': 'Returns the value of the first argument raised to the power of the second argument.',
188202
}

0 commit comments

Comments
 (0)