File tree Expand file tree Collapse file tree 3 files changed +20
-1
lines changed
Expand file tree Collapse file tree 3 files changed +20
-1
lines changed Original file line number Diff line number Diff line change 11"math dialect, modeling functions in python's `math` stdlib" # This file is generated by gen.py
22
3+ import math as pymath
4+
35from kirin import lowering
46from kirin .dialects .math .dialect import dialect as dialect
57
68from . import stmts as stmts , interp as interp
79
10+ pi = pymath .pi
11+ e = pymath .e
12+ tau = pymath .tau
13+
814
915@lowering .wraps (stmts .acos )
1016def acos (x : float ) -> float : ...
Original file line number Diff line number Diff line change @@ -109,8 +109,12 @@ class MathMethodTable(MethodTable):
109109 f .write ("# This file is generated by gen.py\n " )
110110 f .write ("from kirin.dialects.math.dialect import dialect as dialect\n " )
111111 f .write ("from . import stmts as stmts, interp as interp\n " )
112-
112+ f .write ("import math as pymath\n " )
113+ f .write ("pi = pymath.pi\n " )
114+ f .write ("e = pymath.e\n " )
115+ f .write ("tau = pymath.tau\n " )
113116 f .write ("from kirin import lowering2\n " )
117+
114118 for name , obj , sig in builtin_math_functions ():
115119 f .write (
116120 textwrap .dedent (
Original file line number Diff line number Diff line change 1+ import math as pymath
2+
3+ from kirin .dialects import math
4+
5+
6+ def test_const ():
7+ assert math .pi == pymath .pi
8+ assert math .e == pymath .e
9+ assert math .tau == pymath .tau
You can’t perform that action at this time.
0 commit comments