Skip to content

Commit 602563b

Browse files
committed
added tests for lambdify with optlevel
1 parent 54ee8f2 commit 602563b

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

symengine/tests/test_lambdify.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ def test_Lambdify():
7575
assert allclose(L(range(n, n+len(args))),
7676
[3*n+3, n**2, -1/(n+2), n*(n+1)*(n+2)])
7777

78+
@unittest.skipUnless(have_numpy, "Numpy not installed")
79+
def test_Lambdify_with_opt_level():
80+
args = x, y, z = se.symbols('x y z')
81+
raises(TypeError, lambda: se.Lambdify(args, [x+y+z, x**2, (x-y)/z, x*y*z], backend='lambda', opt_level=0))
7882

7983
def _test_Lambdify_Piecewise(Lambdify):
8084
x = se.symbols('x')
@@ -91,7 +95,6 @@ def test_Lambdify_Piecewise():
9195
if se.have_llvm:
9296
_test_Lambdify_Piecewise(lambda *args: se.Lambdify(*args, backend='llvm'))
9397

94-
9598
@unittest.skipUnless(have_numpy, "Numpy not installed")
9699
def test_Lambdify_LLVM():
97100
n = 7
@@ -105,6 +108,19 @@ def test_Lambdify_LLVM():
105108
assert allclose(L(range(n, n+len(args))),
106109
[3*n+3, n**2, -1/(n+2), n*(n+1)*(n+2)])
107110

111+
@unittest.skipUnless(have_numpy, "Numpy not installed")
112+
def test_Lambdify_LLVM_with_opt_level():
113+
for opt_level in range(4):
114+
n = 7
115+
args = x, y, z = se.symbols('x y z')
116+
if not se.have_llvm:
117+
raises(ValueError, lambda: se.Lambdify(args, [x+y+z, x**2,
118+
(x-y)/z, x*y*z],
119+
backend='llvm', opt_level=opt_level))
120+
raise SkipTest("No LLVM support")
121+
L = se.Lambdify(args, [x+y+z, x**2, (x-y)/z, x*y*z], backend='llvm', opt_level=opt_level)
122+
assert allclose(L(range(n, n+len(args))),
123+
[3*n+3, n**2, -1/(n+2), n*(n+1)*(n+2)])
108124

109125
def _get_2_to_2by2():
110126
args = x, y = se.symbols('x y')

0 commit comments

Comments
 (0)