diff --git a/pyrightconfig.json b/pyrightconfig.json index f032c9c..3b66687 100644 --- a/pyrightconfig.json +++ b/pyrightconfig.json @@ -6,5 +6,6 @@ "ignore": [ "**/.vscode/**", "**.ipynb" - ] + ], + "reportInvalidTypeForm": false } diff --git a/stormvogel/mapping.py b/stormvogel/mapping.py index bdfffd1..b3e30c0 100644 --- a/stormvogel/mapping.py +++ b/stormvogel/mapping.py @@ -1,11 +1,9 @@ import stormvogel.model try: - import stormpy.storage - - stormpy_installed = True + import stormpy except ImportError: - stormpy_installed = False + stormpy = None def stormvogel_to_stormpy( @@ -25,6 +23,7 @@ def build_matrix( Takes a model and creates a stormpy sparsematrix that represents the same transitions """ + assert stormpy is not None row_grouping = model.supports_actions() builder = stormpy.SparseMatrixBuilder( rows=0, @@ -62,6 +61,7 @@ def add_labels(model: stormvogel.model.Model) -> stormpy.storage.StateLabeling: """ Takes a model creates a state labelling object that determines which states get which labels in the stormpy representation """ + assert stormpy is not None state_labeling = stormpy.storage.StateLabeling(len(model.states)) @@ -82,6 +82,8 @@ def add_rewards( """ Takes a model and creates a dictionary of all the stormpy representations of reward models """ + assert stormpy is not None + reward_models = {} for rewardmodel in model.rewards: reward_models[rewardmodel.name] = stormpy.SparseRewardModel( @@ -94,6 +96,7 @@ def map_dtmc(model: stormvogel.model.Model) -> stormpy.storage.SparseDtmc: """ Takes a simple representation of a dtmc as input and outputs a dtmc how it is represented in stormpy """ + assert stormpy is not None # we first build the SparseMatrix matrix = build_matrix(model, None) @@ -118,6 +121,7 @@ def map_mdp(model: stormvogel.model.Model) -> stormpy.storage.SparseMdp: """ Takes a simple representation of an mdp as input and outputs an mdp how it is represented in stormpy """ + assert stormpy is not None # we determine the number of choices and the labels count = 0 @@ -158,6 +162,7 @@ def map_ctmc(model: stormvogel.model.Model) -> stormpy.storage.SparseCtmc: """ Takes a simple representation of a ctmc as input and outputs a ctmc how it is represented in stormpy """ + assert stormpy is not None # we first build the SparseMatrix (in stormvogel these are always the rate transitions) matrix = build_matrix(model, None) @@ -186,6 +191,7 @@ def map_pomdp(model: stormvogel.model.Model) -> stormpy.storage.SparsePomdp: """ Takes a simple representation of an pomdp as input and outputs an pomdp how it is represented in stormpy """ + assert stormpy is not None # we determine the number of choices and the labels count = 0 @@ -236,6 +242,7 @@ def map_ma(model: stormvogel.model.Model) -> stormpy.storage.SparseMA: """ Takes a simple representation of an ma as input and outputs an ma how it is represented in stormpy """ + assert stormpy is not None # we determine the number of choices and the labels count = 0 @@ -289,6 +296,8 @@ def map_ma(model: stormvogel.model.Model) -> stormpy.storage.SparseMA: return ma if model.all_states_outgoing_transition(): + assert stormpy is not None + # we make a mapping between stormvogel and stormpy ids in case they are out of order. stormpy_id = {} for index, stormvogel_id in enumerate(model.states.keys()): diff --git a/tests/test_mapping.py b/tests/test_mapping.py index 2099805..9ac1edf 100644 --- a/tests/test_mapping.py +++ b/tests/test_mapping.py @@ -12,12 +12,8 @@ import examples.simple_ma from stormvogel.model import EmptyAction -try: - import stormpy - stormpy_installed = True -except ImportError: - stormpy_installed = False +import stormpy.storage def sparse_equal( diff --git a/tests/test_model_checking.py b/tests/test_model_checking.py index 646439f..34d8d15 100644 --- a/tests/test_model_checking.py +++ b/tests/test_model_checking.py @@ -3,12 +3,7 @@ import examples.die -try: - import stormpy - - stormpy_installed = True -except ImportError: - stormpy_installed = False +import stormpy def test_model_checking(): diff --git a/tests/test_result.py b/tests/test_result.py index 21c5620..cf0a26d 100644 --- a/tests/test_result.py +++ b/tests/test_result.py @@ -1,12 +1,8 @@ import stormvogel.result import pytest -try: - import stormpy - stormpy_installed = True -except ImportError: - stormpy_installed = False +import stormpy def test_convert_model_checker_results_dtmc():