Skip to content

Commit

Permalink
Skip ma57 tests if not available
Browse files Browse the repository at this point in the history
  • Loading branch information
jgillis committed Jun 22, 2019
1 parent 5dec465 commit 9471ff8
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Expand Up @@ -21,8 +21,8 @@ before_script:
- set -e
- set -o pipefail # otherwise, piping with grep discards exit statuses
- git clone https://github.com/meco-group/bob.git
- pushd bob && source setup.sh && popd
- bob_get libhsl.tar.gz && mkdir $HOME/libhsl && tar -xf libhsl.tar.gz -C $HOME/libhsl
# - pushd bob && source setup.sh && popd
# - bob_get libhsl.tar.gz && mkdir $HOME/libhsl && tar -xf libhsl.tar.gz -C $HOME/libhsl

script:
- nosetests --verbosity=2 --nocapture --with-xcoverage --cover-package=omgtools --cover-tests
Expand Down
2 changes: 2 additions & 0 deletions examples/compare_distributed_optimization_quadrotors.py
Expand Up @@ -21,6 +21,8 @@
import numpy as np
import matplotlib.pyplot as plt

assert_ma57()

# settings
number_of_iterations = 100

Expand Down
2 changes: 2 additions & 0 deletions examples/formation_dubins.py
Expand Up @@ -19,6 +19,8 @@

from omgtools import *

assert_ma57()

# create fleet
N = 3
vehicles = [Dubins(options={'degree': 2}, bounds={'vmax': 1., 'wmax': np.pi/6., 'wmin': -np.pi/6.}) for l in range(N)]
Expand Down
2 changes: 2 additions & 0 deletions examples/p2p_agv.py
Expand Up @@ -19,6 +19,8 @@

from omgtools import *

assert_ma57()

# create vehicle
vehicle = AGV(length=0.8, options={'plot_type': 'agv'})
# vehicle.set_options({'safety_distance': 0.3})
Expand Down
2 changes: 2 additions & 0 deletions examples/p2p_agv2.py
Expand Up @@ -19,6 +19,8 @@

from omgtools import *

assert_ma57()

# create vehicle
vehicle = AGV(length=0.8, options={'plot_type': 'agv'})
vehicle.define_knots(knot_intervals=5) # choose lower amount of knot intervals
Expand Down
3 changes: 3 additions & 0 deletions examples/p2p_bicycle.py
Expand Up @@ -19,6 +19,9 @@

from omgtools import *


assert_ma57()

# create vehicle
vehicle = Bicycle(length=0.4, options={'plot_type': 'car', 'substitution': False})
vehicle.define_knots(knot_intervals=5) # choose lower amount of knot intervals
Expand Down
2 changes: 2 additions & 0 deletions examples/p2p_trailer.py
Expand Up @@ -19,6 +19,8 @@

from omgtools import *

assert_ma57()

# create vehicle
vehicle = Dubins(shapes=Circle(0.2), bounds={'vmax': 0.8, 'wmax': np.pi/3., 'wmin': -np.pi/3.})
vehicle.define_knots(knot_intervals=9) # adapt amount of knot intervals
Expand Down
2 changes: 2 additions & 0 deletions examples/revolving_door_diffdrive.py
Expand Up @@ -20,6 +20,8 @@
from omgtools import *
import numpy as np

assert_ma57()

# create vehicle
vehicle = Dubins(bounds={'vmax': 0.7, 'wmin': -30., 'wmax': 30.})
vehicle.define_knots(knot_intervals=6)
Expand Down
14 changes: 14 additions & 0 deletions omgtools/__init__.py
Expand Up @@ -5,3 +5,17 @@
from .execution import *
from .export import *
from .gui import *


def assert_ma57():
import casadi
import sys

x = casadi.MX.sym("x")
nlp = casadi.nlpsol('nlp','ipopt',{"x":x,"f":x**2},{"ipopt": {"linear_solver": "ma57", "print_level":0}, "print_time": False})

nlp()

if nlp.stats()["return_status"]=="Invalid_Option":
print("Could not find ma57 (from hsl library), which is needed for the code to run.")
sys.exit(0)
9 changes: 8 additions & 1 deletion tests/test_examples.py
Expand Up @@ -40,5 +40,12 @@ def test_export():
def run_example(filename):
example_dir = os.path.join(os.getcwd(), 'examples')
print('')
imp.load_source(filename.split('.')[-2],
try:
imp.load_source(filename.split('.')[-2],
os.path.join(example_dir, filename))

# Forgive sys.exit(0)
except SystemExit as e:
if e.code!=0:
import sys
sys.exit(e.code)

0 comments on commit 9471ff8

Please sign in to comment.