Skip to content

Commit 723b0d2

Browse files
committed
Merge branch 'master' into heterogeneous-Lambdify
2 parents 2c2abad + 5fadf70 commit 723b0d2

31 files changed

+1737
-1208
lines changed

.travis.yml

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ addons:
1616

1717
env:
1818
global:
19-
- secure: "jkvObuYjs4oT0bbUzLOtKLPkD2AVt/c4ZOS2qNkStC8dwtLpcYd4tLn1S07PCMYzCLL/DGvp6J8IKmzhQV7a/Yl/wVySTNBFnPecjku8Spf1UqdJbrJa8Ln/nxnajFyc2Q7QnKj8s4sguN1GRY7Jdylp9l7XgebjGwVrpKXIR+JqiSAhxkEyMmWklzu80m+BOTep0xTY/E9fFMCznQFM96jTSjq9vFxCAzToOpP3EFQyBjhDkPNQvaI3KYcBabe5DQs0wMvLEboxDEGYG+Y4ijp1d8JFmWZgzU1nQm++n8WG/Igz8rF6Asy7fHeE2/sexQf0LEqtTFtSmJFFnn6vJdn+6JOB05ARbdXc2KKzP81BCCjhPIH/KNQNMpD6p7KfXhthM0np/dxBRDlCh+6kDiuei+798YSJ63Svdr+lmg4weuxWRQh7D2lmXTcygWSW4iafCgK+D0lekg239HKcvDXPx352obM/HAz7tUiIaiOvHNlKlVL7bbHDhKWyaduAHB9jVnAIvcDWjumwyOaIPPLQL1JsL8Tha1H5uUPYWYjfNjjqk57pXq1YPUFoyiylViqX1eTWypwkXFKFJCWb6IhuW32OKEYACXJLZm7zui/qvIKiNn7PNGBxtrW/rvpvVAM94yQNhlmjxiu4/V74D0/9Oh90cPGFtoocbj5MT98="
19+
- secure: "gdcw4nEd06q+E8yZkaqtgexX4kHgKqFuTRHKyx5QJBW/q+vL94ntbFft7jZssXEmFtijyjjNbhTucwcSaXIAP1X4tct5kHcuBH5LVvCxi7r4NfhERJDE/EAOS4xbQJ9IUHjdBWCWTCCiXpg0bG/1YcCVsppcKi2Z864CBDpa8DPuDUtyxFpkHW7PdALitLWDIIkIJU817JqYlJKcnR62OYGdVlHiUHhSGI6JKnqou7gf6fgXLsXNnUDUeWS+9vElOTV6OU7vHbG1Ka2N2vwpLIoBoSrw80EDAyP+QqqBRP1B2CyPGvEu9lTyqxUVkb0DAjsltn1bt36UVIb+l55B1JWPSriI3xiVstXa9D2Xb1uth9h712c0cwXw9LJ7YsXEcwdAfCRF/Zywt9IdwCWlnRkiGD2fOHPBkjpXVAV+2xFSD8WLuV6hc3xZjFLvzRxiDZ1CYSY+Wh6IxOp7411GT3BgtH0kEXb5+cg55cjPxgWAWOsU1WkrrWMl9DngeiWNwGZQCU+UkPB1WaITtA6JbFdEZPinZFWtYPMj6ZdA+ARkmwQnG6Y6sg37Zq76n8mDjLb5ECLXq22uRLaATl8lRLOaNDStg9PSxtVGON65NeesPMRFRC7+2ySQ/8KqsZZubHk7SoSY8APP+5mqzBuMbt2bnBVLmf04TI7RnVPSZ6A="
2020

2121
## All these variables are sent into the bin/test_travis.sh script. See this
2222
## script to know how they are used. Most of them are just passed to cmake,
@@ -25,20 +25,17 @@ env:
2525
## statement, so if the variable is not set, the other if branch will get
2626
## executed.
2727
matrix:
28-
## Out of tree builds (default):
28+
# Debug builds:
2929
- BUILD_TYPE="Debug" WITH_BFD="yes" PYTHON_VERSION="2.7" TRIGGER_FEEDSTOCK="yes"
30+
- BUILD_TYPE="Debug" WITH_BFD="yes" PYTHON_VERSION="3.6"
3031

31-
## In-tree builds (we just check a few configurations to make sure they work):
32-
# Debug build with Python 2.7:
33-
- BUILD_TYPE="Debug" WITH_BFD="yes" PYTHON_VERSION="2.7"
34-
# Release build shared lib with Python 2.7:
32+
# Release builds:
3533
- PYTHON_VERSION="2.7" BUILD_SHARED_LIBS="yes"
36-
37-
# These test the setup.py file
38-
- PYTHON_VERSION="2.7" WITH_MPFR="yes" INTEGER_CLASS="gmp"
34+
- PYTHON_VERSION="2.7" WITH_MPFR="yes" INTEGER_CLASS="gmpxx"
3935
- PYTHON_VERSION="3.3" WITH_MPC="yes"
4036
- PYTHON_VERSION="3.4" WITH_MPFR="yes" WITH_NUMPY="yes"
41-
- PYTHON_VERSION="3.5" WITH_MPFR="yes" WITH_NUMPY="yes"
37+
- PYTHON_VERSION="3.5" WITH_MPC="yes" WITH_NUMPY="yes"
38+
- PYTHON_VERSION="3.6" WITH_MPC="yes" WITH_NUMPY="yes"
4239

4340
matrix:
4441
exclude:
@@ -81,13 +78,9 @@ matrix:
8178
- env: BUILD_TYPE="Release" PYTHON_VERSION="3.5"
8279
compiler: gcc
8380
os: osx
84-
- env: BUILD_TYPE="Release" WITH_SAGE="yes" WITH_MPC="yes"
81+
- env: BUILD_TYPE="Release" WITH_SAGE="yes" WITH_MPC="yes" PYTHON_VERSION="2.7"
8582
compiler: gcc
8683
os: linux
87-
addons:
88-
apt:
89-
packages:
90-
- lrzip
9184

9285
install:
9386
- export PYTHON_SOURCE_DIR=`pwd`
@@ -100,12 +93,13 @@ install:
10093
- git checkout `cat ../symengine_version.txt`
10194
- cd ..
10295

103-
# Setup travis for Python wrappers
104-
- source bin/install_travis.sh
105-
10696
# Setup travis for C++ library
10797
- cd $SOURCE_DIR
108-
- if [[ "${WITH_SAGE}" != "yes" ]]; then source bin/install_travis.sh; fi
98+
- source bin/install_travis.sh
99+
100+
# Setup travis for Python wrappers
101+
- cd $PYTHON_SOURCE_DIR
102+
- source bin/install_travis.sh
109103

110104
# Build C++ library
111105
- cd $SOURCE_DIR

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 2.8)
22
project(python_wrapper)
33

44
set(CMAKE_PREFIX_PATH ${SymEngine_DIR} ${CMAKE_PREFIX_PATH})
5-
find_package(SymEngine 0.2.0 REQUIRED CONFIG
5+
find_package(SymEngine 0.3.0 REQUIRED CONFIG
66
PATH_SUFFIXES lib/cmake/symengine cmake/symengine CMake/)
77
message("SymEngine_DIR : " ${SymEngine_DIR})
88
set(CMAKE_BUILD_TYPE ${SYMENGINE_BUILD_TYPE})

bin/install_travis.sh

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
#!/usr/bin/env bash
22

3-
if [[ "${WITH_SAGE}" != "yes" ]]; then
4-
# symengine's bin/install_travis.sh will install miniconda
5-
conda_pkgs="python=${PYTHON_VERSION} pip cython sympy nose pytest"
6-
if [[ "${WITH_NUMPY}" == "yes" ]]; then
7-
conda_pkgs="${conda_pkgs} numpy";
8-
fi
9-
else
10-
wget -O- https://dl.dropboxusercontent.com/u/46807346/sage-6.9-x86_64-Linux-Ubuntu_12.04_64_bit.tar.gz | tar xz
11-
SAGE_ROOT=`pwd`/sage-6.9-x86_64-Linux
12-
export PATH="$SAGE_ROOT:$PATH"
13-
source $SAGE_ROOT/src/bin/sage-env
14-
export our_install_dir=$SAGE_LOCAL
3+
# symengine's bin/install_travis.sh will install miniconda
4+
export conda_pkgs="python=${PYTHON_VERSION} pip cython sympy nose pytest"
5+
6+
if [[ "${WITH_NUMPY}" == "yes" ]]; then
7+
export conda_pkgs="${conda_pkgs} numpy";
8+
fi
9+
10+
if [[ "${WITH_SAGE}" == "yes" ]]; then
11+
export conda_pkgs="${conda_pkgs} sage";
1512
fi
13+
14+
conda update -q -n root conda
15+
conda install ${conda_pkgs} libgap=4.8.3
16+
source activate $our_install_dir;

bin/test_travis.sh

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,12 @@ set -x
99
python setup.py install build_ext --inplace --symengine-dir=$our_install_dir
1010

1111
# Test python wrappers
12-
if [[ "${WITH_SAGE}" != "yes" ]]; then
13-
nosetests -v
14-
# If switching to py.test, the following collects correct tests:
15-
#py.test -v $PYTHON_SOURCE_DIR/symengine/tests/test_*.py
16-
mkdir -p empty
17-
cd empty
18-
python $PYTHON_SOURCE_DIR/bin/test_python.py
19-
fi
20-
if [[ "${WITH_SAGE}" == "yes" ]]; then
21-
sage -t $PYTHON_SOURCE_DIR/symengine/tests/test_sage.py
22-
fi
12+
nosetests -v
13+
# If switching to py.test, the following collects correct tests:
14+
#py.test -v $PYTHON_SOURCE_DIR/symengine/tests/test_*.py
15+
mkdir -p empty && cd empty
16+
python $PYTHON_SOURCE_DIR/bin/test_python.py
17+
cd ..
2318

2419
if [[ "${TRIGGER_FEEDSTOCK}" == "yes" ]]; then
2520
cd $PYTHON_SOURCE_DIR

setup.py

Lines changed: 43 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@
33
import os
44
import subprocess
55
import sys
6+
from distutils.command.build_ext import build_ext as _build_ext
7+
from distutils.command.build import build as _build
68

79
# Make sure the system has the right Python version.
810
if sys.version_info[:2] < (2, 7):
9-
print("SymEngine requires Python 2.7 or newer. Python %d.%d detected" % sys.version_info[:2])
11+
print("SymEngine requires Python 2.7 or newer. "
12+
"Python %d.%d detected" % sys.version_info[:2])
1013
sys.exit(-1)
1114

1215
# use setuptools by default as per the official advice at:
@@ -18,12 +21,9 @@
1821
if use_distutils.lower() == 'true':
1922
use_setuptools = False
2023
else:
21-
print("Value {} for USE_DISTUTILS treated as False".\
24+
print("Value {} for USE_DISTUTILS treated as False".
2225
format(use_distutils))
2326

24-
from distutils.command.build_ext import build_ext as _build_ext
25-
from distutils.command.build import build as _build
26-
2727
if use_setuptools:
2828
try:
2929
from setuptools import setup
@@ -35,30 +35,37 @@
3535
from distutils.core import setup
3636
from distutils.command.install import install as _install
3737

38-
cmake_opts = [("PYTHON_BIN", sys.executable), ("CMAKE_INSTALL_RPATH_USE_LINK_PATH", "yes")]
38+
cmake_opts = [("PYTHON_BIN", sys.executable),
39+
("CMAKE_INSTALL_RPATH_USE_LINK_PATH", "yes")]
3940
cmake_generator = [None]
4041
cmake_build_type = ["Release"]
4142

43+
4244
def process_opts(opts):
4345
return ['-D'+'='.join(o) for o in opts]
4446

47+
4548
def get_build_dir(dist):
4649
source_dir = path.dirname(path.realpath(__file__))
4750
build = dist.get_command_obj('build')
4851
build_ext = dist.get_command_obj('build_ext')
4952
return source_dir if build_ext.inplace else build.build_platlib
5053

54+
5155
global_user_options = [
52-
('symengine-dir=', None, 'path to symengine installation or build directory'),
56+
('symengine-dir=', None,
57+
'path to symengine installation or build directory'),
5358
('generator=', None, 'cmake build generator'),
5459
('build-type=', None, 'build type: Release or Debug'),
5560
('define=', 'D',
5661
'options to cmake <var>:<type>=<value>'),
5762
]
5863

64+
5965
class BuildWithCmake(_build):
6066
sub_commands = [('build_ext', None)]
6167

68+
6269
class BuildExtWithCmake(_build_ext):
6370
_build_opts = _build_ext.user_options
6471
user_options = list(global_user_options)
@@ -98,22 +105,25 @@ def cmake_build(self):
98105
if build_dir != source_dir and path.exists("CMakeCache.txt"):
99106
os.remove("CMakeCache.txt")
100107

101-
cmake_cmd = ["cmake", source_dir, "-DCMAKE_BUILD_TYPE=" + cmake_build_type[0]]
108+
cmake_cmd = ["cmake", source_dir,
109+
"-DCMAKE_BUILD_TYPE=" + cmake_build_type[0]]
102110
cmake_cmd.extend(process_opts(cmake_opts))
103111
if not path.exists(path.join(build_dir, "CMakeCache.txt")):
104112
cmake_cmd.extend(self.get_generator())
105113
if subprocess.call(cmake_cmd, cwd=build_dir) != 0:
106114
raise EnvironmentError("error calling cmake")
107115

108-
if subprocess.call(["cmake", "--build", ".", "--config", cmake_build_type[0]],
109-
cwd=build_dir) != 0:
116+
if subprocess.call(["cmake", "--build", ".",
117+
"--config", cmake_build_type[0]],
118+
cwd=build_dir) != 0:
110119
raise EnvironmentError("error building project")
111120

112121
def get_generator(self):
113122
if cmake_generator[0]:
114123
return ["-G", cmake_generator[0]]
115124
else:
116-
import platform, sys
125+
import platform
126+
import sys
117127
if (platform.system() == "Windows"):
118128
compiler = str(self.compiler).lower()
119129
if ("msys" in compiler):
@@ -128,9 +138,11 @@ def get_generator(self):
128138

129139
def run(self):
130140
self.cmake_build()
131-
# can't use super() here because _build_ext is an old style class in 2.7
141+
# can't use super() here because
142+
# _build_ext is an old style class in 2.7
132143
_build_ext.run(self)
133144

145+
134146
class InstallWithCmake(_install):
135147
_install_opts = _install.user_options
136148
user_options = list(global_user_options)
@@ -157,7 +169,8 @@ def finalize_options(self):
157169

158170
cmake_build_type[0] = self.build_type
159171
cmake_opts.extend([('PYTHON_INSTALL_PATH', self.install_platlib)])
160-
cmake_opts.extend([('PYTHON_INSTALL_HEADER_PATH', self.install_headers)])
172+
cmake_opts.extend([('PYTHON_INSTALL_HEADER_PATH',
173+
self.install_headers)])
161174

162175
def cmake_install(self):
163176
source_dir = path.dirname(path.realpath(__file__))
@@ -170,8 +183,10 @@ def cmake_install(self):
170183
if subprocess.call(cmake_cmd, cwd=build_dir) != 0:
171184
raise EnvironmentError("error calling cmake")
172185

173-
if subprocess.call(["cmake", "--build", ".", "--config", cmake_build_type[0], "--target", "install"],
174-
cwd=build_dir) != 0:
186+
if subprocess.call(["cmake", "--build", ".",
187+
"--config", cmake_build_type[0],
188+
"--target", "install"],
189+
cwd=build_dir) != 0:
175190
raise EnvironmentError("error installing")
176191

177192
import compileall
@@ -182,24 +197,25 @@ def run(self):
182197
_install.run(self)
183198
self.cmake_install()
184199

200+
185201
long_description = '''
186202
SymEngine is a standalone fast C++ symbolic manipulation library.
187203
Optional thin Python wrappers (SymEngine) allow easy usage from Python and
188204
integration with SymPy and Sage.'''
189205

190-
setup(name = "symengine",
206+
setup(name="symengine",
191207
version="0.2.1.dev",
192-
description = "Python library providing wrappers to SymEngine",
193-
setup_requires = ['cython>=0.19.1'],
194-
long_description = long_description,
195-
author = "SymEngine development team",
196-
author_email = "[email protected]",
197-
license = "MIT",
198-
url = "https://github.com/symengine/symengine.py",
208+
description="Python library providing wrappers to SymEngine",
209+
setup_requires=['cython>=0.19.1'],
210+
long_description=long_description,
211+
author="SymEngine development team",
212+
author_email="[email protected]",
213+
license="MIT",
214+
url="https://github.com/symengine/symengine.py",
199215
cmdclass={
200-
'build' : BuildWithCmake,
201-
'build_ext' : BuildExtWithCmake,
202-
'install' : InstallWithCmake,
216+
'build': BuildWithCmake,
217+
'build_ext': BuildExtWithCmake,
218+
'install': InstallWithCmake,
203219
},
204220
classifiers=[
205221
'License :: OSI Approved :: MIT License',
@@ -213,4 +229,4 @@ def run(self):
213229
'Programming Language :: Python :: 3.4',
214230
'Programming Language :: Python :: 3.5',
215231
]
216-
)
232+
)

symengine/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ add_subdirectory(lib)
22
add_subdirectory(tests)
33

44
set(PY_PATH ${PYTHON_INSTALL_PATH}/symengine)
5-
install(FILES __init__.py utilities.py compatibility.py sympy_compat.py
5+
install(FILES __init__.py utilities.py compatibility.py sympy_compat.py functions.py
66
DESTINATION ${PY_PATH}
77
)

symengine/__init__.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1-
from .lib.symengine_wrapper import (Symbol, Integer, sympify, SympifyError,
2-
Add, Mul, Pow, exp, log, gamma, sqrt, function_symbol, I, E, pi,
3-
have_mpfr, have_mpc, have_flint, have_piranha, have_llvm,
4-
RealDouble, ComplexDouble, DenseMatrix, Matrix,
5-
sin, cos, tan, cot, csc, sec, asin, acos, atan, acot, acsc, asec,
6-
sinh, cosh, tanh, coth, asinh, acosh, atanh, acoth, Lambdify,
7-
LambdifyCSE, DictBasic, series, symarray, diff, zeros, eye, diag,
8-
ones, zeros, add, expand, has_symbol, UndefFunction)
1+
from .lib.symengine_wrapper import (Symbol, sympify as S, sympify,
2+
SympifyError, Add, Mul, Pow, function_symbol, I, E, pi, oo,
3+
zoo, nan, have_mpfr, have_mpc, have_flint, have_piranha,
4+
have_llvm, Integer, Rational, Float, Number, RealNumber,
5+
RealDouble, ComplexDouble, Max, Min, DenseMatrix, Matrix,
6+
ImmutableMatrix, ImmutableDenseMatrix, MutableDenseMatrix,
7+
MatrixBase, Basic, Lambdify, LambdifyCSE, Lambdify as lambdify,
8+
DictBasic, symarray, series, diff, zeros, eye, diag, ones,
9+
Derivative, Subs, add, expand, has_symbol, UndefFunction,
10+
Function, FunctionSymbol as AppliedUndef)
911
from .utilities import var, symbols
12+
from .functions import *
1013

1114
if have_mpfr:
1215
from .lib.symengine_wrapper import RealMPFR
@@ -16,7 +19,9 @@
1619

1720
__version__ = "0.2.1.dev"
1821

22+
1923
def test():
20-
import pytest, os
24+
import pytest
25+
import os
2126
return not pytest.cmdline.main(
2227
[os.path.dirname(os.path.abspath(__file__))])

symengine/functions.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from .lib.symengine_wrapper import (sin, cos, tan, cot, csc, sec,
2+
asin, acos, atan, acot, acsc, asec,
3+
sinh, cosh, tanh, coth, sech, csch,
4+
asinh, acosh, atanh, acoth, asech, acsch,
5+
gamma, log, atan2, sqrt, exp, Abs)

0 commit comments

Comments
 (0)