Browse Source

Skip tests if numpy is unavailable

refactoring
Matthias Volk 4 years ago
parent
commit
dbeb079789
No known key found for this signature in database GPG Key ID: 83A57678F739FCD3
  1. 11
      doc/source/doc/models/building_ctmcs.rst
  2. 11
      doc/source/doc/models/building_mas.rst
  3. 12
      examples/building_ctmcs/01-building-ctmcs.py
  4. 12
      examples/building_mas/01-building-mas.py
  5. 1
      examples/building_mdps/01-building-mdps.py

11
doc/source/doc/models/building_ctmcs.rst

@ -3,6 +3,17 @@ Continuous-time Markov chains (CTMCs)
**************************************
.. check if the following doctest should be run (and hide it in Sphinx)
>>> # Skip tests if numpy is not available
>>> import pytest
>>> try:
... import numpy as np
... except ModuleNotFoundError:
... np = None
>>> if np is None:
... pytest.skip("skipping the doctest below since it's not going to work.")
Background
=====================

11
doc/source/doc/models/building_mas.rst

@ -3,6 +3,17 @@ Markov automata (MAs)
**************************************
.. check if the following doctest should be run (and hide it in Sphinx)
>>> # Skip tests if numpy is not available
>>> import pytest
>>> try:
... import numpy as np
... except ModuleNotFoundError:
... np = None
>>> if np is None:
... pytest.skip("skipping the doctest below since it's not going to work.")
Background
=====================

12
examples/building_ctmcs/01-building-ctmcs.py

@ -1,8 +1,18 @@
import stormpy
import numpy as np
# Check if numpy is available
try:
import numpy as np
numpy_found = True
except ModuleNotFoundError:
numpy_found = False
def example_building_ctmcs_01():
if not numpy_found:
print("Numpy not available")
return
# Building the transition matrix using numpy
transitions = np.array([
[0, 1.5, 0, 0],

12
examples/building_mas/01-building-mas.py

@ -1,8 +1,18 @@
import stormpy
import numpy as np
# Check if numpy is available
try:
import numpy as np
numpy_found = True
except ModuleNotFoundError:
numpy_found = False
def example_building_mas_01():
if not numpy_found:
print("Numpy not available")
return
# Building the transition matrix using numpy
transitions = np.array([
[0, 1, 0, 0, 0],

1
examples/building_mdps/01-building-mdps.py

@ -1,5 +1,4 @@
import stormpy
import numpy as np
# Knuth's model of a fair die using only fair coins

Loading…
Cancel
Save