From d77446e5c76aed01c880092886be200ae013c394 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20A=2E=20Galindo?= Date: Thu, 22 Aug 2024 22:49:55 +0200 Subject: [PATCH] fix: issue solved in the configurations op --- .../pysat_metamodel/operations/pysat_filter.py | 16 +++++----------- .../pysat_metamodel/operations/pysat_metrics.py | 2 +- requirements.txt | 2 +- tests/operations/operations_test.py | 6 ++++-- 4 files changed, 11 insertions(+), 15 deletions(-) diff --git a/flamapy/metamodels/pysat_metamodel/operations/pysat_filter.py b/flamapy/metamodels/pysat_metamodel/operations/pysat_filter.py index deac961..87e9c4d 100644 --- a/flamapy/metamodels/pysat_metamodel/operations/pysat_filter.py +++ b/flamapy/metamodels/pysat_metamodel/operations/pysat_filter.py @@ -24,7 +24,7 @@ def get_result(self) -> list[list[Any]]: def set_configuration(self, configuration: Configuration) -> None: self.configuration = configuration - def execute(self, model: VariabilityModel) -> 'PySATFilter': + def execute(self, model: VariabilityModel) -> 'PySATFilter': # noqa: MC0001 model = cast(PySATModel, model) for clause in model.get_all_clauses(): # AC es conjunto de conjuntos @@ -40,23 +40,17 @@ def execute(self, model: VariabilityModel) -> 'PySATFilter': else: missing_features = [feature for feature in self.configuration.elements.keys() if feature not in model.variables.keys()] - if missing_features: - print("The features that are missing are:", list(missing_features)) - print("The feature model contains the following features:", - list(model.variables.keys())) - self.result = False - return self - + raise ValueError("The configuration contains features that are \ + not present in the feature model.", + list(missing_features)) assumptions = [] for feature in model.features.values(): - if self.configuration.elements.get(feature, False): assumptions.append(model.variables[feature]) else: assumptions.append(-model.variables[feature]) - for solution in self.solver.enum_models(assumptions=assumptions): product = [] for variable in solution: @@ -64,4 +58,4 @@ def execute(self, model: VariabilityModel) -> 'PySATFilter': product.append(model.features.get(variable)) self.filter_products.append(product) self.solver.delete() - return self + return self \ No newline at end of file diff --git a/flamapy/metamodels/pysat_metamodel/operations/pysat_metrics.py b/flamapy/metamodels/pysat_metamodel/operations/pysat_metrics.py index 5d5cb1c..cb4bec6 100644 --- a/flamapy/metamodels/pysat_metamodel/operations/pysat_metrics.py +++ b/flamapy/metamodels/pysat_metamodel/operations/pysat_metrics.py @@ -37,7 +37,7 @@ def __init__(self) -> None: @property def model_type_extension(self) -> str: return self._model_type_extension - + @model_type_extension.setter def model_type_extension(self, ext: str) -> None: self._model_type_extension = ext diff --git a/requirements.txt b/requirements.txt index 73c2630..c350a17 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ -flamapy-fw~=2.0.0 +flamapy-fw~=2.0.1 flamapy-fm~=2.0.0 python-sat~=0.1.7.dev1 \ No newline at end of file diff --git a/tests/operations/operations_test.py b/tests/operations/operations_test.py index eb8f5db..def72e7 100644 --- a/tests/operations/operations_test.py +++ b/tests/operations/operations_test.py @@ -70,14 +70,16 @@ def run( if expected_valid_product_list is not None: for product in expected_valid_product_list: valid_product = PySATSatisfiableConfiguration() - valid_product.set_configuration(configuration = product, is_full = True) + product.is_full = True + valid_product.set_configuration(configuration = product) valid_product.execute(model) assert valid_product.is_satisfiable() if expected_non_valid_product_list is not None: for product in expected_non_valid_product_list: valid_product = PySATSatisfiableConfiguration() - valid_product.set_configuration(configuration = product, is_full = True) + product.is_full = True + valid_product.set_configuration(configuration = product) valid_product.execute(model) assert not valid_product.is_satisfiable()