Skip to content

Commit 276d7bc

Browse files
authored
Merge pull request #108 from isuruf/lambdifycse
Fix two issues in LambdifyCSE
2 parents bb532cc + b0b4d64 commit 276d7bc

File tree

3 files changed

+19
-13
lines changed

3 files changed

+19
-13
lines changed

.travis.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,16 @@ matrix:
5656
sources:
5757
- ubuntu-toolchain-r-test
5858
- boost-latest
59+
- george-edison55-precise-backports
5960
packages:
6061
- libgmp-dev
6162
- libmpfr-dev
6263
- binutils-dev
6364
- libboost-serialization1.55-dev
6465
- libboost-iostreams1.55-dev
6566
- g++-4.8
67+
- cmake
68+
- cmake-data
6669
- env: BUILD_TYPE="Debug" WITH_BFD="yes" PYTHON_VERSION="3.5"
6770
compiler: clang
6871
os: linux
@@ -90,8 +93,6 @@ matrix:
9093
- lrzip
9194

9295
install:
93-
# Workaround till symengine C++ repo's script is fixed
94-
- if [[ "${TRAVIS_OS_NAME}" == "osx" ]]; then brew uninstall cmake; fi
9596
- export PYTHON_SOURCE_DIR=`pwd`
9697
- export TEST_CPP="no"
9798

symengine/lib/symengine_wrapper.pyx

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2845,17 +2845,22 @@ def LambdifyCSE(args, exprs, real=True, cse=None, concatenate=None):
28452845
from sympy import cse
28462846
if concatenate is None:
28472847
from numpy import concatenate
2848-
subs, new_exprs = cse(exprs)
2849-
cse_symbs, cse_exprs = zip(*subs)
2850-
lmb = Lambdify(tuple(args) + cse_symbs, new_exprs, real=real)
2851-
cse_lambda = Lambdify(args, cse_exprs, real=real)
2852-
2853-
def cb(inp, out=None, **kwargs):
2854-
cse_vals = cse_lambda(inp, **kwargs)
2855-
new_inp = concatenate((inp, cse_vals))
2856-
return lmb(new_inp, out, **kwargs)
2848+
from sympy import sympify as ssympify
2849+
subs, new_exprs = cse([ssympify(expr) for expr in exprs])
2850+
if subs:
2851+
cse_symbs, cse_exprs = zip(*subs)
2852+
lmb = Lambdify(tuple(args) + cse_symbs, new_exprs, real=real)
2853+
cse_lambda = Lambdify(args, cse_exprs, real=real)
2854+
2855+
def cb(inp, out=None, **kwargs):
2856+
cse_vals = cse_lambda(inp, **kwargs)
2857+
new_inp = concatenate((inp, cse_vals))
2858+
return lmb(new_inp, out, **kwargs)
2859+
2860+
return cb
2861+
else:
2862+
return Lambdify(args, exprs, real=real)
28572863

2858-
return cb
28592864

28602865
def has_symbol(obj, symbol=None):
28612866
cdef Basic b = sympify(obj)

symengine_version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v0.2.0
1+
c7a3bac9d715d9d78c3005b725c2cf4946514e32

0 commit comments

Comments
 (0)