Browse Source

Check if DFT support was built

refactoring
Matthias Volk 8 years ago
parent
commit
790c62a48a
  1. 1
      lib/.gitignore
  2. 5
      lib/stormpy/dft/__init__.py
  3. 6
      setup.py
  4. 12
      tests/dft/test_build.py

1
lib/.gitignore

@ -1,3 +1,4 @@
*.so
__pycache__/
stormpy.egg-info/
stormpy/dft/_config.py

5
lib/stormpy/dft/__init__.py

@ -1,3 +1,8 @@
from . import _config
if not _config.has_storm_dft:
raise ImportError("No support for DFTs was built in Storm.")
from . import dft
from .dft import *

6
setup.py

@ -47,7 +47,10 @@ class CMakeBuild(build_ext):
match = re.search(r"HAVE-STORM-DFT: (.*)", output)
assert(match)
self.have_storm_dft = True if match.group(1) == "TRUE" else False
# Set variable in _config.py
with open(os.path.join("lib", "stormpy", "dft", "_config.py"), "w") as f:
f.write("# Generated from setup.py\n")
f.write("has_storm_dft = {}".format(self.have_storm_dft))
for ext in self.extensions:
if ext.name == "dft":
@ -58,6 +61,7 @@ class CMakeBuild(build_ext):
else:
self.build_extension(ext)
def initialize_options(self):
build_ext.initialize_options(self)
self.storm_dir = None

12
tests/dft/test_build.py

@ -1,12 +1,21 @@
import stormpy
import stormpy.dft
import stormpy.logic
from helpers.helper import get_example_path
import math
class TestBuild:
def test_import(self):
import stormpy.dft
def test_build_dft(self):
try:
import stormpy.dft
except ImportError:
# No support for DFTs
return
model = stormpy.dft.build_sparse_model_from_json_dft(get_example_path("dft", "and.json"))
formulas = stormpy.parse_properties("T=? [ F \"failed\" ]")
assert model.nr_states == 4
@ -16,4 +25,3 @@ class TestBuild:
assert initial_state == 1
result = stormpy.model_checking(model, formulas[0])
assert math.isclose(result.at(initial_state), 3)
Loading…
Cancel
Save