Skip to content

Commit 2aab90a

Browse files
committed
Add tests
1 parent 07cac4f commit 2aab90a

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

symengine/tests/test_cse.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from symengine import cse, sqrt, symbols
2+
3+
def test_cse_single():
4+
x, y, x0 = symbols("x, y, x0")
5+
e = pow(x + y, 2) + sqrt(x + y)
6+
substs, reduced = cse([e])
7+
assert substs == [(x0, x + y)]
8+
assert reduced == [sqrt(x0) + x0**2]
9+
10+
11+
def test_multiple_expressions():
12+
w, x, y, z, x0 = symbols("w, x, y, z, x0")
13+
e1 = (x + y)*z
14+
e2 = (x + y)*w
15+
substs, reduced = cse([e1, e2])
16+
assert substs == [(x0, x + y)]
17+
assert reduced == [x0*z, x0*w]

0 commit comments

Comments
 (0)