Skip to content

Commit

Permalink
Test symengine on travis (#146)
Browse files Browse the repository at this point in the history
* test: run symengine tests on travis

* test: fix symengine matrix and properly indent .travis.yml

* test: fix indentation error in .travis.yml

* chore: check variable name type for symengine

* test: raise an exception on travis if symengine could not be used

* fix: add some pickle magic

Tell pickle how to pickle variables
  • Loading branch information
KristianJensen authored Nov 9, 2017
1 parent 652639a commit 15cad1c
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 41 deletions.
85 changes: 44 additions & 41 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
language: python
sudo: false
python:
- '2.7'
- '3.4'
- '3.5'
- '2.7'
- '3.4'
- '3.5'
env:
global:
- secure: PBcwrLg4ZwVi9Gw25Q2adNd0uK+NCqFSiYl+ZuumkEXs4NQBbSXVd719wrWKUFdIqBy+h9ETo4Vsz/QsTZzI2mSG4zqTkm+oUxMW1tJxYEeKZvCo7GfZ883VlKFgdqvh6iouEvHSjfGbwc5cUp98CbjgI5ni01vGpDQh2hgokkI=
matrix:
- OPTLANG_USE_SYMENGINE=False
- OPTLANG_USE_SYMENGINE=True
cache:
- pip: true
- pip: true
addons:
apt:
packages:
Expand All @@ -16,49 +22,46 @@ addons:
- glpk-utils
- pandoc
before_install:
- export SYMPY_USE_CACHE=no
- export OPTLANG_USE_SYMENGINE=no
- pip install pip --upgrade
- 'echo "this is a build for: $TRAVIS_BRANCH"'
- 'if [[ "$TRAVIS_PYTHON_VERSION" != "3.5" ]]; then bash ./.travis/install_cplex.sh; fi'
- export SYMPY_USE_CACHE=no
- pip install pip --upgrade
- 'echo "this is a build for: $TRAVIS_BRANCH"'
- 'if [[ "$TRAVIS_PYTHON_VERSION" != "3.5" ]]; then bash ./.travis/install_cplex.sh; fi'
install:
- pip install nose nose-progressive rednose coverage docutils flake8 codecov jsonschema
- pip install -r requirements.txt
- pip install inspyred
- pip install pypandoc
- pip install swiglpk
- pip install scipy
- python setup.py install
- pip install nose nose-progressive rednose coverage docutils flake8 codecov jsonschema
- pip install -r requirements.txt
- pip install inspyred
- pip install pypandoc
- pip install swiglpk
- pip install scipy
- pip install symengine
- python setup.py install
before_script:
- flake8 .
- flake8 .
script: nosetests
after_success:
- codecov
- codecov
notifications:
slack:
secure: s8Dj0MFreNwZ3Zhb0+5yJiHPL33JsxLjmoRo8f0ohLdD15L//E4VjkCsYkNEcLzid6HarEL/1JSmzAuGl40fCdLqTAoDRy01shT1zmfWQPXQlaALh5f8ExBAlyDHxKhd/B2SytYu6uhe0WOuxu/oo4c33a7pKhuV1piNcevPZew=
before_deploy:
- pip install twine
- python setup.py sdist bdist_wheel
env:
global:
- secure: PBcwrLg4ZwVi9Gw25Q2adNd0uK+NCqFSiYl+ZuumkEXs4NQBbSXVd719wrWKUFdIqBy+h9ETo4Vsz/QsTZzI2mSG4zqTkm+oUxMW1tJxYEeKZvCo7GfZ883VlKFgdqvh6iouEvHSjfGbwc5cUp98CbjgI5ni01vGpDQh2hgokkI=
- pip install twine
- python setup.py sdist bdist_wheel
deploy:
- provider: releases
api_key:
secure: u4aJv+5YoH3gjJpyiVoq33SqKIUtx8LWPp15pIh8hKHmUgJNyjGm7ELXOeczfQ5W7ZpnWj+ogewaes2oA0NLxBB1/MBPL7kr77hmzp+XhZomh73DzFKegbpBTgqpioBRxvPlq3HYNIWqrLkeg/HYlBW1WM6mKifFUwqbIaL+++4=
file_glob: true
file: dist/optlang*.whl
skip_cleanup: true
on:
branch: master
tags: true
repo: biosustain/optlang
- provider: pypi
user: Nikolaus.Sonnenschein
password:
secure: Gn23MUvzP1DPJXxRXUOXGBJjyMamawxey5ByrOd+JT90roljHKSk8v1wdBMH7+s1DB/ygUJqB2Zy0cBC3mr0waY6HmxKpXhddgzQzG56Eua/npTxpz58Y8xfSYF+5QqS3gcyBrYEXmeHWuEURERy0b7uYKMx/QcHAHYhTaVy4zE=
on:
branch: master
tags: true
repo: biosustain/optlang
- provider: releases
api_key:
secure: u4aJv+5YoH3gjJpyiVoq33SqKIUtx8LWPp15pIh8hKHmUgJNyjGm7ELXOeczfQ5W7ZpnWj+ogewaes2oA0NLxBB1/MBPL7kr77hmzp+XhZomh73DzFKegbpBTgqpioBRxvPlq3HYNIWqrLkeg/HYlBW1WM6mKifFUwqbIaL+++4=
file_glob: true
file: dist/optlang*.whl
skip_cleanup: true
on:
branch: master
tags: true
repo: biosustain/optlang
- provider: pypi
user: Nikolaus.Sonnenschein
password:
secure: Gn23MUvzP1DPJXxRXUOXGBJjyMamawxey5ByrOd+JT90roljHKSk8v1wdBMH7+s1DB/ygUJqB2Zy0cBC3mr0waY6HmxKpXhddgzQzG56Eua/npTxpz58Y8xfSYF+5QqS3gcyBrYEXmeHWuEURERy0b7uYKMx/QcHAHYhTaVy4zE=
on:
branch: master
tags: true
repo: biosustain/optlang
3 changes: 3 additions & 0 deletions optlang/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,9 @@ def __getstate__(self):
def __setstate__(self, state):
self.__dict__ = state

def __reduce__(self):
return (type(self), (self.name, self.lb, self.ub, self.type, self.problem))

def to_json(self):
"""
Returns a json-compatible object from the Variable that can be saved using the json module.
Expand Down
5 changes: 5 additions & 0 deletions optlang/symbolics.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
except ImportError as e:
if SYMENGINE_PREFERENCE.lower() in ("true", "yes", "on"):
logger.warn("Symengine could not be imported: " + str(e))
if os.getenv('TRAVIS', None) is not None: # Travis should error here # pragma: no cover
raise RuntimeError("Symengine should be used but could not be!")
USE_SYMENGINE = False
else:
USE_SYMENGINE = True
Expand Down Expand Up @@ -68,6 +70,9 @@

class Symbol(symengine_Symbol):
def __new__(cls, name, *args, **kwargs):
if not isinstance(name, six.string_types):
raise TypeError("name should be a string, not %s" % repr(type(name)))

return symengine_Symbol.__new__(cls, name)

def __init__(self, name, *args, **kwargs):
Expand Down

0 comments on commit 15cad1c

Please sign in to comment.