mirror of
https://github.com/micropython/micropython.git
synced 2026-01-08 05:00:26 +01:00
py/modmath: Add math.tau, math.nan and math.inf constants.
Configurable by the new MICROPY_PY_MATH_CONSTANTS option.
This commit is contained in:
11
tests/float/math_constants.py
Normal file
11
tests/float/math_constants.py
Normal file
@@ -0,0 +1,11 @@
|
||||
# Tests various constants of the math module.
|
||||
try:
|
||||
import math
|
||||
from math import exp, cos
|
||||
except ImportError:
|
||||
print("SKIP")
|
||||
raise SystemExit
|
||||
|
||||
print(math.e == exp(1.0))
|
||||
|
||||
print(cos(math.pi))
|
||||
17
tests/float/math_constants_extra.py
Normal file
17
tests/float/math_constants_extra.py
Normal file
@@ -0,0 +1,17 @@
|
||||
# Tests constants of the math module available only with MICROPY_PY_MATH_CONSTANTS.
|
||||
try:
|
||||
import math
|
||||
from math import isnan
|
||||
|
||||
math.tau
|
||||
except (ImportError, AttributeError):
|
||||
print("SKIP")
|
||||
raise SystemExit
|
||||
|
||||
print(math.tau == 2.0 * math.pi)
|
||||
|
||||
print(math.inf == float("inf"))
|
||||
print(-math.inf == -float("inf"))
|
||||
|
||||
print(isnan(math.nan))
|
||||
print(isnan(-math.nan))
|
||||
Reference in New Issue
Block a user