Skip to content

Commit 789c35e

Browse files
committed
Throw error when llvm is selected but not installed
1 parent 4fee72d commit 789c35e

File tree

3 files changed

+27
-8
lines changed

3 files changed

+27
-8
lines changed

.travis.yml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,23 @@ matrix:
6666
- g++-4.8
6767
- cmake
6868
- cmake-data
69-
- env: BUILD_TYPE="Debug" WITH_BFD="yes" PYTHON_VERSION="3.5"
69+
- env: BUILD_TYPE="Debug" WITH_BFD="yes" PYTHON_VERSION="3.5" WITH_LLVM="yes"
7070
compiler: clang
7171
os: linux
72+
addons:
73+
apt:
74+
sources:
75+
- ubuntu-toolchain-r-test
76+
- llvm-toolchain-precise-3.8
77+
- george-edison55-precise-backports
78+
packages:
79+
- clang
80+
- libstdc++-4.8-dev
81+
- libgmp-dev
82+
- binutils-dev
83+
- llvm-3.8-dev
84+
- cmake
85+
- cmake-data
7286
- env: BUILD_TYPE="Release" PYTHON_VERSION="2.7"
7387
compiler: clang
7488
os: linux

symengine/lib/symengine_wrapper.pyx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2831,10 +2831,13 @@ IF HAVE_SYMENGINE_LLVM:
28312831
self.lambda_double[0].call(&out[0], &inp[0])
28322832

28332833

2834-
def Lambdify(args, exprs, bool real=True, bool llvm=False):
2835-
IF HAVE_SYMENGINE_LLVM:
2836-
if llvm:
2834+
def Lambdify(args, exprs, bool real=True, backend="lambda"):
2835+
if backend == "llvm":
2836+
IF HAVE_SYMENGINE_LLVM:
28372837
return LLVMDouble(args, exprs, real)
2838+
ELSE:
2839+
raise ValueError("""llvm backend is chosen, but symengine is not compiled
2840+
with llvm support.""")
28382841

28392842
return LambdaDouble(args, exprs, real)
28402843

symengine/tests/test_lambdify.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,18 @@ def allclose(vec1, vec2, rtol=1e-13, atol=1e-13):
4646
def test_Lambdify():
4747
n = 7
4848
args = x, y, z = se.symbols('x y z')
49-
l = se.Lambdify(args, [x+y+z, x**2, (x-y)/z, x*y*z])
49+
l = se.Lambdify(args, [x+y+z, x**2, (x-y)/z, x*y*z], backend='lambda')
5050
assert allclose(l(range(n, n+len(args))),
5151
[3*n+3, n**2, -1/(n+2), n*(n+1)*(n+2)])
5252

5353
def test_Lambdify_LLVM():
54-
if not se.have_llvm:
55-
return
5654
n = 7
5755
args = x, y, z = se.symbols('x y z')
58-
l = se.Lambdify(args, [x+y+z, x**2, (x-y)/z, x*y*z], llvm=True)
56+
if not se.have_llvm:
57+
raises(ValueError, lambda: se.Lambdify(args, [x+y+z, x**2, (x-y)/z, x*y*z],
58+
backend='llvm'))
59+
return
60+
l = se.Lambdify(args, [x+y+z, x**2, (x-y)/z, x*y*z], backend='llvm')
5961
assert allclose(l(range(n, n+len(args))),
6062
[3*n+3, n**2, -1/(n+2), n*(n+1)*(n+2)])
6163

0 commit comments

Comments
 (0)