|
38 | 38 | #define MP_PI MICROPY_FLOAT_CONST(3.14159265358979323846) |
39 | 39 |
|
40 | 40 |
|
41 | | -//| :mod:`math` --- mathematical functions |
| 41 | +//| """:mod:`math` --- mathematical functions |
42 | 42 | //| ======================================================== |
43 | 43 | //| |
44 | 44 | //| .. module:: math |
45 | 45 | //| :synopsis: mathematical functions |
46 | 46 | //| :platform: SAMD21/SAMD51 |
47 | 47 | //| |
48 | 48 | //| The `math` module provides some basic mathematical functions for |
49 | | -//| working with floating-point numbers. |
| 49 | +//| working with floating-point numbers.""" |
50 | 50 | //| |
51 | 51 |
|
52 | 52 | STATIC NORETURN void math_error(void) { |
@@ -86,117 +86,113 @@ STATIC NORETURN void math_error(void) { |
86 | 86 | //| Constants |
87 | 87 | //| --------- |
88 | 88 | //| |
89 | | - //| .. data:: e |
| 89 | + //| e: Any = ... |
| 90 | + //| """base of the natural logarithm""" |
90 | 91 | //| |
91 | | - //| base of the natural logarithm |
92 | | - //| |
93 | | - //| .. data:: pi |
94 | | - //| |
95 | | - //| the ratio of a circle's circumference to its diameter |
| 92 | + //| pi: Any = ... |
| 93 | + //| """the ratio of a circle's circumference to its diameter""" |
96 | 94 | //| |
97 | 95 |
|
98 | 96 | //| Functions |
99 | 97 | //| --------- |
100 | 98 | //| |
101 | | - //| .. function:: acos(x) |
102 | | - //| |
103 | | - //| Return the inverse cosine of ``x``. |
104 | | - //| |
105 | | - //| .. function:: asin(x) |
106 | | - //| |
107 | | - //| Return the inverse sine of ``x``. |
108 | | - //| |
109 | | - //| .. function:: atan(x) |
110 | | - //| |
111 | | - //| Return the inverse tangent of ``x``. |
112 | | - //| |
113 | | - //| .. function:: atan2(y,x) |
114 | | - //| |
115 | | - //| Return the principal value of the inverse tangent of ``y/x``. |
116 | | - //| |
117 | | - //| .. function:: ceil(x) |
118 | | - //| |
119 | | - //| Return an integer, being ``x`` rounded towards positive infinity. |
120 | | - //| |
121 | | - //| .. function:: copysign(x,y) |
122 | | - //| |
123 | | - //| Return ``x`` with the sign of ``y``. |
124 | | - //| |
125 | | - //| .. function:: cos(x) |
126 | | - //| |
127 | | - //| Return the cosine of ``x``. |
128 | | - //| |
129 | | - //| .. function:: degrees(x) |
130 | | - //| |
131 | | - //| Return radians ``x`` converted to degrees. |
132 | | - //| |
133 | | - //| .. function:: exp(x) |
134 | | - //| |
135 | | - //| Return the exponential of ``x``. |
136 | | - //| |
137 | | - //| .. function:: fabs(x) |
138 | | - //| |
139 | | - //| Return the absolute value of ``x``. |
140 | | - //| |
141 | | - //| .. function:: floor(x) |
142 | | - //| |
143 | | - //| Return an integer, being ``x`` rounded towards negative infinity. |
144 | | - //| |
145 | | - //| .. function:: fmod(x,y) |
146 | | - //| |
147 | | - //| Return the remainder of ``x/y``. |
148 | | - //| |
149 | | - //| .. function:: frexp(x) |
| 99 | + //| def acos(x: Any) -> Any: |
| 100 | + //| """Return the inverse cosine of ``x``.""" |
| 101 | + //| ... |
150 | 102 | //| |
151 | | - //| Decomposes a floating-point number into its mantissa and exponent. |
152 | | - //| The returned value is the tuple ``(m, e)`` such that ``x == m * 2**e`` |
153 | | - //| exactly. If ``x == 0`` then the function returns ``(0.0, 0)``, otherwise |
154 | | - //| the relation ``0.5 <= abs(m) < 1`` holds. |
| 103 | + //| def asin(x: Any) -> Any: |
| 104 | + //| """Return the inverse sine of ``x``.""" |
| 105 | + //| ... |
155 | 106 | //| |
156 | | - //| .. function:: isfinite(x) |
| 107 | + //| def atan(x: Any) -> Any: |
| 108 | + //| """Return the inverse tangent of ``x``.""" |
| 109 | + //| ... |
157 | 110 | //| |
158 | | - //| Return ``True`` if ``x`` is finite. |
| 111 | + //| def atan2(y: Any, x: Any) -> Any: |
| 112 | + //| """Return the principal value of the inverse tangent of ``y/x``.""" |
| 113 | + //| ... |
159 | 114 | //| |
160 | | - //| .. function:: isinf(x) |
| 115 | + //| def ceil(x: Any) -> Any: |
| 116 | + //| """Return an integer, being ``x`` rounded towards positive infinity.""" |
| 117 | + //| ... |
161 | 118 | //| |
162 | | - //| Return ``True`` if ``x`` is infinite. |
| 119 | + //| def copysign(x: Any, y: Any) -> Any: |
| 120 | + //| """Return ``x`` with the sign of ``y``.""" |
| 121 | + //| ... |
163 | 122 | //| |
164 | | - //| .. function:: isnan(x) |
| 123 | + //| def cos(x: Any) -> Any: |
| 124 | + //| """Return the cosine of ``x``.""" |
| 125 | + //| ... |
165 | 126 | //| |
166 | | - //| Return ``True`` if ``x`` is not-a-number |
| 127 | + //| def degrees(x: Any) -> Any: |
| 128 | + //| """Return radians ``x`` converted to degrees.""" |
| 129 | + //| ... |
167 | 130 | //| |
168 | | - //| .. function:: ldexp(x, exp) |
| 131 | + //| def exp(x: Any) -> Any: |
| 132 | + //| """Return the exponential of ``x``.""" |
| 133 | + //| ... |
169 | 134 | //| |
170 | | - //| Return ``x * (2**exp)``. |
| 135 | + //| def fabs(x: Any) -> Any: |
| 136 | + //| """Return the absolute value of ``x``.""" |
| 137 | + //| ... |
171 | 138 | //| |
172 | | - //| .. function:: modf(x) |
| 139 | + //| def floor(x: Any) -> Any: |
| 140 | + //| """Return an integer, being ``x`` rounded towards negative infinity.""" |
| 141 | + //| ... |
173 | 142 | //| |
174 | | - //| Return a tuple of two floats, being the fractional and integral parts of |
175 | | - //| ``x``. Both return values have the same sign as ``x``. |
| 143 | + //| def fmod(x: Any, y: Any) -> Any: |
| 144 | + //| """Return the remainder of ``x/y``.""" |
| 145 | + //| ... |
176 | 146 | //| |
177 | | - //| .. function:: pow(x, y) |
| 147 | + //| def frexp(x: Any) -> Any: |
| 148 | + //| """Decomposes a floating-point number into its mantissa and exponent. |
| 149 | + //| The returned value is the tuple ``(m, e)`` such that ``x == m * 2**e`` |
| 150 | + //| exactly. If ``x == 0`` then the function returns ``(0.0, 0)``, otherwise |
| 151 | + //| the relation ``0.5 <= abs(m) < 1`` holds.""" |
| 152 | + //| ... |
178 | 153 | //| |
179 | | - //| Returns ``x`` to the power of ``y``. |
| 154 | + //| def isfinite(x: Any) -> Any: |
| 155 | + //| """Return ``True`` if ``x`` is finite.""" |
| 156 | + //| ... |
180 | 157 | //| |
181 | | - //| .. function:: radians(x) |
| 158 | + //| def isinf(x: Any) -> Any: |
| 159 | + //| """Return ``True`` if ``x`` is infinite.""" |
| 160 | + //| ... |
182 | 161 | //| |
183 | | - //| Return degrees ``x`` converted to radians. |
| 162 | + //| def isnan(x: Any) -> Any: |
| 163 | + //| """Return ``True`` if ``x`` is not-a-number""" |
| 164 | + //| ... |
184 | 165 | //| |
185 | | - //| .. function:: sin(x) |
| 166 | + //| def ldexp(x: Any, exp: Any) -> Any: |
| 167 | + //| """Return ``x * (2**exp)``.""" |
| 168 | + //| ... |
186 | 169 | //| |
187 | | - //| Return the sine of ``x``. |
| 170 | + //| def modf(x: Any) -> Any: |
| 171 | + //| """Return a tuple of two floats, being the fractional and integral parts of |
| 172 | + //| ``x``. Both return values have the same sign as ``x``.""" |
| 173 | + //| ... |
188 | 174 | //| |
189 | | - //| .. function:: sqrt(x) |
| 175 | + //| def pow(x: Any, y: Any) -> Any: |
| 176 | + //| """Returns ``x`` to the power of ``y``.""" |
190 | 177 | //| |
191 | | - //| Returns the square root of ``x``. |
| 178 | + //| def radians(x: Any) -> Any: |
| 179 | + //| """Return degrees ``x`` converted to radians.""" |
192 | 180 | //| |
193 | | - //| .. function:: tan(x) |
| 181 | + //| def sin(x: Any) -> Any: |
| 182 | + //| """Return the sine of ``x``.""" |
| 183 | + //| ... |
194 | 184 | //| |
195 | | - //| Return the tangent of ``x``. |
| 185 | + //| def sqrt(x: Any) -> Any: |
| 186 | + //| """Returns the square root of ``x``.""" |
| 187 | + //| ... |
196 | 188 | //| |
197 | | - //| .. function:: trunc(x) |
| 189 | + //| def tan(x: Any) -> Any: ... |
| 190 | + //| """Return the tangent of ``x``.""" |
| 191 | + //| ... |
198 | 192 | //| |
199 | | - //| Return an integer, being ``x`` rounded towards 0. |
| 193 | + //| def trunc(x: Any) -> Any: |
| 194 | + //| """Return an integer, being ``x`` rounded towards 0.""" |
| 195 | + //| ... |
200 | 196 | //| |
201 | 197 | MATH_FUN_1_ERRCOND(sqrt, sqrt, (x < (mp_float_t)0.0)) |
202 | 198 |
|
|
0 commit comments