Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit fe71f81

Browse filesBrowse files
committed
Part of SF patch [#431848] mathmodule.c: doc strings & conversion, from
Peter Schneider-Kamp. Clarified some docstrings in the spirit of the patch; left out the degrees() and radians() functions (see the patch comments on SF).
1 parent 54e99e8 commit fe71f81
Copy full SHA for fe71f81

1 file changed

+18-15Lines changed: 18 additions & 15 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎Modules/mathmodule.c‎

Copy file name to clipboardExpand all lines: Modules/mathmodule.c
+18-15Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ is_error(double x)
5151
* the result for zero suffices to distinguish the cases).
5252
*/
5353
if (x)
54-
PyErr_SetString(PyExc_OverflowError,
54+
PyErr_SetString(PyExc_OverflowError,
5555
"math range error");
5656
else
5757
result = 0;
@@ -109,25 +109,28 @@ math_2(PyObject *args, double (*func) (double, double), char *argsfmt)
109109
static char math_##funcname##_doc [] = docstring;
110110

111111
FUNC1(acos, acos,
112-
"acos(x)\n\nReturn the arc cosine of x.")
112+
"acos(x)\n\nReturn the arc cosine (measured in radians) of x.")
113113
FUNC1(asin, asin,
114-
"asin(x)\n\nReturn the arc sine of x.")
114+
"asin(x)\n\nReturn the arc sine (measured in radians) of x.")
115115
FUNC1(atan, atan,
116-
"atan(x)\n\nReturn the arc tangent of x.")
116+
"atan(x)\n\nReturn the arc tangent (measured in radians) of x.")
117117
FUNC2(atan2, atan2,
118-
"atan2(y, x)\n\nReturn atan(y/x).")
118+
"atan2(y, x)\n\nReturn the arc tangent (measured in radians) of y/x.\n"
119+
"Unlike atan(y/x), the signs of both x and y are considered.")
119120
FUNC1(ceil, ceil,
120-
"ceil(x)\n\nReturn the ceiling of x as a real.")
121+
"ceil(x)\n\nReturn the ceiling of x as a float.\n"
122+
"This is the smallest integral value >= x.")
121123
FUNC1(cos, cos,
122-
"cos(x)\n\nReturn the cosine of x.")
124+
"cos(x)\n\nReturn the cosine of x (measured in radians).")
123125
FUNC1(cosh, cosh,
124126
"cosh(x)\n\nReturn the hyperbolic cosine of x.")
125127
FUNC1(exp, exp,
126128
"exp(x)\n\nReturn e raised to the power of x.")
127129
FUNC1(fabs, fabs,
128-
"fabs(x)\n\nReturn the absolute value of the real x.")
130+
"fabs(x)\n\nReturn the absolute value of the float x.")
129131
FUNC1(floor, floor,
130-
"floor(x)\n\nReturn the floor of x as a real.")
132+
"floor(x)\n\nReturn the floor of x as a float.\n"
133+
"This is the largest integral value <= x.")
131134
FUNC2(fmod, fmod,
132135
"fmod(x,y)\n\nReturn fmod(x, y), according to platform C."
133136
" x % y may differ.")
@@ -139,19 +142,19 @@ FUNC1(log10, log10,
139142
"log10(x)\n\nReturn the base-10 logarithm of x.")
140143
#ifdef MPW_3_1 /* This hack is needed for MPW 3.1 but not for 3.2 ... */
141144
FUNC2(pow, power,
142-
"pow(x,y)\n\nReturn x**y.")
145+
"pow(x,y)\n\nReturn x**y (x to the power of y).")
143146
#else
144147
FUNC2(pow, pow,
145-
"pow(x,y)\n\nReturn x**y.")
148+
"pow(x,y)\n\nReturn x**y (x to the power of y).")
146149
#endif
147150
FUNC1(sin, sin,
148-
"sin(x)\n\nReturn the sine of x.")
151+
"sin(x)\n\nReturn the sine of x (measured in radians).")
149152
FUNC1(sinh, sinh,
150153
"sinh(x)\n\nReturn the hyperbolic sine of x.")
151154
FUNC1(sqrt, sqrt,
152155
"sqrt(x)\n\nReturn the square root of x.")
153156
FUNC1(tan, tan,
154-
"tan(x)\n\nReturn the tangent of x.")
157+
"tan(x)\n\nReturn the tangent of x (measured in radians).")
155158
FUNC1(tanh, tanh,
156159
"tanh(x)\n\nReturn the hyperbolic tangent of x.")
157160

@@ -198,7 +201,7 @@ math_ldexp(PyObject *self, PyObject *args)
198201
return PyFloat_FromDouble(x);
199202
}
200203

201-
static char math_ldexp_doc [] =
204+
static char math_ldexp_doc [] =
202205
"ldexp_doc(x, i)\n\
203206
\n\
204207
Return x * (2**i).";
@@ -270,7 +273,7 @@ DL_EXPORT(void)
270273
initmath(void)
271274
{
272275
PyObject *m, *d, *v;
273-
276+
274277
m = Py_InitModule3("math", math_methods, module_doc);
275278
d = PyModule_GetDict(m);
276279

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.