Skip to content

Commit

Permalink
Merge pull request #413 from qutech/fix/fixing_tests_rebase
Browse files Browse the repository at this point in the history
Travis Reconfiguration to fix tests
  • Loading branch information
terrorfisch committed Nov 6, 2018
2 parents 94f9825 + ed60d44 commit 0fabda2
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 45 deletions.
43 changes: 23 additions & 20 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,38 +1,41 @@
language: python
python:
- "3.4"
- "3.5"
- "3.6"
- 3.5
- 3.6
env:
- INSTALL_EXTRAS=[VISA,plotting]
- INSTALL_EXTRAS=[VISA,plotting,Faster-fractions]

matrix:
include:
- python: 3.7
dist: xenial
sudo: true
env: INSTALL_EXTRAS=[VISA,plotting]
- python: 3.7
dist: xenial
sudo: true
env: INSTALL_EXTRAS=[VISA,plotting,Faster-fractions]

#use container based infrastructure
sudo: false

#these directories are persistent
cache:
directories:
- $HOME/.cache/pip
- $HOME/.cache/miniconda3_pkgs
- $HOME/Downloads
cache: pip

# install dependencies for gmpy2
addons:
apt:
update: true
packages:
- libgmp-dev
- libmpfr-dev
- libmpc-dev

# Setup anaconda
before_install:
# install miniconda with symlink of pkg dir to cache
- chmod +x ./install_miniconda3.sh
- ./install_miniconda3.sh
#
- export PATH=$HOME/miniconda3/bin:$PATH
- hash -r
- conda config --set always_yes yes --set changeps1 no
- conda update -q conda
- conda create -q -n test-environment python=$TRAVIS_PYTHON_VERSION pip
- conda install -q -n test-environment gmpy2
- source activate test-environment
- pip install coverage coveralls
install:
- pip install -r requirements.txt
- pip install .$INSTALL_EXTRAS
script:
- "coverage run --source=qupulse --rcfile=coverage.ini setup.py test"
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ Alternatively, the current development version of qupulse can be installed by ex
pip3 install .
```

qupulse is developed using Python 3.6 and tested on 3.4 - 3.6. It relies on some external Python packages as dependencies;
`requirements.txt` lists the versions of these qupulse is developed against and tested with.
qupulse is developed using Python 3.6 and tested on 3.5 - 3.7 It relies on some external Python packages as dependencies;
`requirements.txt` lists the versions of these qupulse is developed against.
We intentionally did not restrict versions of dependencies in the install scripts to not unnecessarily prevent usage of
newer releases of dependencies that might be compatible. However, if qupulse does encounter problems with a particular dependency version,
try installing the version listed in `requirements.txt`.
Expand Down
2 changes: 2 additions & 0 deletions ReleaseNotes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

- General:
- Introduce qupulse.utils.isclose (an alias for math.isclose if available)
- Dropped support for Python 3.4 in setup.py due to incompatible syntax in qupulse.
- Official support for Python 3.7 has begun.

- Pulse Templates:
- `AtomicMultichannelPulseTemplate`:
Expand Down
13 changes: 4 additions & 9 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,11 @@ def extract_version(version_file):
raise RuntimeError("Unable to find version string.")


if sys.version_info < (3, 4):
sys.stderr.write('ERROR: You need Python 3.4 or later '
if sys.version_info < (3, 5):
sys.stderr.write('ERROR: You need Python 3.5 or later '
'to install the qupulse package.\n')
exit(1)

if sys.version_info < (3, 5):
requires_typing = ['typing==3.5.0']
else:
requires_typing = []

packages = [package for package in find_packages()
if package.startswith('qupulse')] + ['qctoolkit']

Expand All @@ -40,8 +35,8 @@ def extract_version(version_file):
author='Quantum Technology Group and Chair of Software Engineering, RWTH Aachen University',
package_dir={'qupulse': 'qupulse', 'qctoolkit': 'qctoolkit'},
packages=packages,
python_requires='>=3.4',
install_requires=['sympy>=1.1.1', 'numpy', 'cached_property'] + requires_typing,
python_requires='>=3.5',
install_requires=['sympy>=1.1.1', 'numpy', 'cached_property'],
extras_require={
'plotting': ['matplotlib'],
'VISA': ['pyvisa'],
Expand Down
37 changes: 23 additions & 14 deletions tests/utils/sympy_tests.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import unittest
import contextlib
import math
import sys

from typing import Union

Expand Down Expand Up @@ -238,24 +239,17 @@ def test_get_variables_indexed(self):
self.assertEqual({'a', 'b', 'i', 'j'}, set(get_variables(expr)))


class EvaluationTests(TestCase):
def evaluate(self, expression: Union[sympy.Expr, np.ndarray], parameters):
if isinstance(expression, np.ndarray):
variables = set.union(*map(set, map(get_variables, expression.flat)))
else:
variables = get_variables(expression)
return evaluate_lambdified(expression, variables=list(variables), parameters=parameters, lambdified=None)[0]
class EvaluationTestsBase:

def test_eval_simple(self):
for expr, parameters, expected in eval_simple:
result = self.evaluate(expr, parameters)
self.assertEqual(result, expected)

def test_eval_many_arguments(self, expected_exception=SyntaxError):
with self.assertRaises(expected_exception):
for expr, parameters, expected in eval_many_arguments:
result = self.evaluate(expr, parameters)
self.assertEqual(result, expected)
def test_eval_many_arguments(self):
for expr, parameters, expected in eval_many_arguments:
result = self.evaluate(expr, parameters)
self.assertEqual(result, expected)

def test_eval_simple_functions(self):
for expr, parameters, expected in eval_simple_functions:
Expand All @@ -278,7 +272,22 @@ def test_eval_array_expression(self):
np.testing.assert_equal(result, expected)


class CompiledEvaluationTest(EvaluationTests):
class LamdifiedEvaluationTest(EvaluationTestsBase, unittest.TestCase):

def evaluate(self, expression: Union[sympy.Expr, np.ndarray], parameters):
if isinstance(expression, np.ndarray):
variables = set.union(*map(set, map(get_variables, expression.flat)))
else:
variables = get_variables(expression)
return evaluate_lambdified(expression, variables=list(variables), parameters=parameters, lambdified=None)[0]

@unittest.skipIf(sys.version_info[0] == 3 and sys.version_info[1] < 7, "causes syntax error for python < 3.7")
def test_eval_many_arguments(self):
super().test_eval_many_arguments()


class CompiledEvaluationTest(EvaluationTestsBase, unittest.TestCase):

def evaluate(self, expression: Union[sympy.Expr, np.ndarray], parameters):
if isinstance(expression, np.ndarray):
return self.evaluate(sympy.Array(expression), parameters)
Expand All @@ -291,7 +300,7 @@ def evaluate(self, expression: Union[sympy.Expr, np.ndarray], parameters):
return result

def test_eval_many_arguments(self):
super().test_eval_many_arguments(None)
super().test_eval_many_arguments()


class RepresentationTest(unittest.TestCase):
Expand Down

0 comments on commit 0fabda2

Please sign in to comment.