Skip to content

Commit 591cc1a

Browse files
committed
Added type hints to math
1 parent f56deb6 commit 591cc1a

File tree

1 file changed

+39
-39
lines changed

1 file changed

+39
-39
lines changed

shared-bindings/math/__init__.c

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -79,108 +79,108 @@ STATIC NORETURN void math_error(void) {
7979
#define log2(x) (log(x) * 1.442695040888963407354163704)
8080
#endif
8181

82-
//| e: Any = ...
82+
//| e: float = ...
8383
//| """base of the natural logarithm"""
8484
//|
85-
//| pi: Any = ...
85+
//| pi: float = ...
8686
//| """the ratio of a circle's circumference to its diameter"""
8787
//|
8888

89-
//| def acos(x: Any) -> Any:
89+
//| def acos(x: float) -> float:
9090
//| """Return the inverse cosine of ``x``."""
9191
//| ...
9292
//|
93-
//| def asin(x: Any) -> Any:
93+
//| def asin(x: float) -> float:
9494
//| """Return the inverse sine of ``x``."""
9595
//| ...
9696
//|
97-
//| def atan(x: Any) -> Any:
97+
//| def atan(x: float) -> float:
9898
//| """Return the inverse tangent of ``x``."""
9999
//| ...
100100
//|
101-
//| def atan2(y: Any, x: Any) -> Any:
101+
//| def atan2(y: float, x: float) -> float:
102102
//| """Return the principal value of the inverse tangent of ``y/x``."""
103103
//| ...
104104
//|
105-
//| def ceil(x: Any) -> Any:
105+
//| def ceil(x: float) -> int:
106106
//| """Return an integer, being ``x`` rounded towards positive infinity."""
107107
//| ...
108108
//|
109-
//| def copysign(x: Any, y: Any) -> Any:
109+
//| def copysign(x: float, y: float) -> float:
110110
//| """Return ``x`` with the sign of ``y``."""
111111
//| ...
112112
//|
113-
//| def cos(x: Any) -> Any:
113+
//| def cos(x: float) -> float:
114114
//| """Return the cosine of ``x``."""
115115
//| ...
116116
//|
117-
//| def degrees(x: Any) -> Any:
117+
//| def degrees(x: float) -> float:
118118
//| """Return radians ``x`` converted to degrees."""
119119
//| ...
120120
//|
121-
//| def exp(x: Any) -> Any:
121+
//| def exp(x: float) -> float:
122122
//| """Return the exponential of ``x``."""
123123
//| ...
124124
//|
125-
//| def fabs(x: Any) -> Any:
125+
//| def fabs(x: float) -> float:
126126
//| """Return the absolute value of ``x``."""
127127
//| ...
128128
//|
129-
//| def floor(x: Any) -> Any:
129+
//| def floor(x: float) -> float:
130130
//| """Return an integer, being ``x`` rounded towards negative infinity."""
131131
//| ...
132132
//|
133-
//| def fmod(x: Any, y: Any) -> Any:
133+
//| def fmod(x: float, y: float) -> int:
134134
//| """Return the remainder of ``x/y``."""
135135
//| ...
136136
//|
137-
//| def frexp(x: Any) -> Any:
137+
//| def frexp(x: float) -> Tuple[int, int]:
138138
//| """Decomposes a floating-point number into its mantissa and exponent.
139139
//| The returned value is the tuple ``(m, e)`` such that ``x == m * 2**e``
140140
//| exactly. If ``x == 0`` then the function returns ``(0.0, 0)``, otherwise
141141
//| the relation ``0.5 <= abs(m) < 1`` holds."""
142142
//| ...
143143
//|
144-
//| def isfinite(x: Any) -> Any:
144+
//| def isfinite(x: float) -> bool:
145145
//| """Return ``True`` if ``x`` is finite."""
146146
//| ...
147147
//|
148-
//| def isinf(x: Any) -> Any:
148+
//| def isinf(x: float) -> bool:
149149
//| """Return ``True`` if ``x`` is infinite."""
150150
//| ...
151151
//|
152-
//| def isnan(x: Any) -> Any:
152+
//| def isnan(x: float) -> bool:
153153
//| """Return ``True`` if ``x`` is not-a-number"""
154154
//| ...
155155
//|
156-
//| def ldexp(x: Any, exp: Any) -> Any:
156+
//| def ldexp(x: float, exp: float) -> float:
157157
//| """Return ``x * (2**exp)``."""
158158
//| ...
159159
//|
160-
//| def modf(x: Any) -> Any:
160+
//| def modf(x: float) -> Tuple[float, float]:
161161
//| """Return a tuple of two floats, being the fractional and integral parts of
162162
//| ``x``. Both return values have the same sign as ``x``."""
163163
//| ...
164164
//|
165-
//| def pow(x: Any, y: Any) -> Any:
165+
//| def pow(x: float, y: float) -> float:
166166
//| """Returns ``x`` to the power of ``y``."""
167167
//|
168-
//| def radians(x: Any) -> Any:
168+
//| def radians(x: float) -> float:
169169
//| """Return degrees ``x`` converted to radians."""
170170
//|
171-
//| def sin(x: Any) -> Any:
171+
//| def sin(x: float) -> float:
172172
//| """Return the sine of ``x``."""
173173
//| ...
174174
//|
175-
//| def sqrt(x: Any) -> Any:
175+
//| def sqrt(x: float) -> float:
176176
//| """Returns the square root of ``x``."""
177177
//| ...
178178
//|
179-
//| def tan(x: Any) -> Any:
179+
//| def tan(x: float) -> float:
180180
//| """Return the tangent of ``x``."""
181181
//| ...
182182
//|
183-
//| def trunc(x: Any) -> Any:
183+
//| def trunc(x: float) -> int:
184184
//| """Return an integer, being ``x`` rounded towards 0."""
185185
//| ...
186186
//|
@@ -190,55 +190,55 @@ MATH_FUN_2(pow, pow)
190190

191191
MATH_FUN_1(exp, exp)
192192
#if MICROPY_PY_MATH_SPECIAL_FUNCTIONS
193-
//| def expm1(x):
193+
//| def expm1(x: float) -> float:
194194
//| """Return ``exp(x) - 1``."""
195195
//| ...
196196
//|
197197
MATH_FUN_1(expm1, expm1)
198198

199-
//| def log2(x):
199+
//| def log2(x: float) -> float:
200200
//| """Return the base-2 logarithm of ``x``."""
201201
//| ...
202202
//|
203203
MATH_FUN_1_ERRCOND(log2, log2, (x <= (mp_float_t)0.0))
204204

205-
//| def log10(x):
205+
//| def log10(x: float) -> float:
206206
//| """Return the base-10 logarithm of ``x``."""
207207
//| ...
208208
//|
209209
MATH_FUN_1_ERRCOND(log10, log10, (x <= (mp_float_t)0.0))
210210

211-
//| def cosh(x):
211+
//| def cosh(x: float) -> float:
212212
//| """Return the hyperbolic cosine of ``x``."""
213213
//| ...
214214
//|
215215
MATH_FUN_1(cosh, cosh)
216216

217-
//| def sinh(x):
217+
//| def sinh(x: float) -> float:
218218
//| """Return the hyperbolic sine of ``x``."""
219219
//| ...
220220
//|
221221
MATH_FUN_1(sinh, sinh)
222222

223-
//| def tanh(x):
223+
//| def tanh(x: float) -> float:
224224
//| """Return the hyperbolic tangent of ``x``."""
225225
//| ...
226226
//|
227227
MATH_FUN_1(tanh, tanh)
228228

229-
//| def acosh(x):
229+
//| def acosh(x: float) -> float:
230230
//| """Return the inverse hyperbolic cosine of ``x``."""
231231
//| ...
232232
//|
233233
MATH_FUN_1(acosh, acosh)
234234

235-
//| def asinh(x):
235+
//| def asinh(x: float) -> float:
236236
//| """Return the inverse hyperbolic sine of ``x``."""
237237
//| ...
238238
//|
239239
MATH_FUN_1(asinh, asinh)
240240

241-
//| def atanh(x):
241+
//| def atanh(x: float) -> float:
242242
//| """Return the inverse hyperbolic tangent of ``x``."""
243243
//| ...
244244
//|
@@ -280,25 +280,25 @@ MATH_FUN_1_TO_INT(trunc, trunc)
280280
MATH_FUN_2(ldexp, ldexp)
281281
#if MICROPY_PY_MATH_SPECIAL_FUNCTIONS
282282

283-
//| def erf(x):
283+
//| def erf(x: float) -> float:
284284
//| """Return the error function of ``x``."""
285285
//| ...
286286
//|
287287
MATH_FUN_1(erf, erf)
288288

289-
//| def erfc(x):
289+
//| def erfc(x: float) -> float:
290290
//| """Return the complementary error function of ``x``."""
291291
//| ...
292292
//|
293293
MATH_FUN_1(erfc, erfc)
294294

295-
//| def gamma(x):
295+
//| def gamma(x: float) -> float:
296296
//| """Return the gamma function of ``x``."""
297297
//| ...
298298
//|
299299
MATH_FUN_1(gamma, tgamma)
300300

301-
//| def lgamma(x):
301+
//| def lgamma(x: float) -> float:
302302
//| """Return the natural logarithm of the gamma function of ``x``."""
303303
//| ...
304304
//|

0 commit comments

Comments
 (0)