From 1316162bba8a7ab20abc6b9040cecd02ae85b167 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20A=2E=20Galindo?= Date: Wed, 24 Jul 2024 00:26:02 +0200 Subject: [PATCH] fix: problem with diagnosys operations --- .github/workflows/main.yml | 2 +- .../models/pysat_diagnosis_model.py | 9 ++++++--- .../transformations/fm_to_diag_pysat.py | 5 ++--- .../pysat_metamodel/operations/pysat_configurations.py | 1 + 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e2aebb9..3c893c4 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -55,4 +55,4 @@ jobs: pip install pytest==5.4.3 - name: Running test run: | - python -m pytest tests/unit_tests/diagnosis_test.py::test_fastdiag_with_configuration + python -m pytest diff --git a/flamapy/metamodels/pysat_diagnosis_metamodel/models/pysat_diagnosis_model.py b/flamapy/metamodels/pysat_diagnosis_metamodel/models/pysat_diagnosis_model.py index ea89009..639f65b 100644 --- a/flamapy/metamodels/pysat_diagnosis_metamodel/models/pysat_diagnosis_model.py +++ b/flamapy/metamodels/pysat_diagnosis_metamodel/models/pysat_diagnosis_model.py @@ -5,6 +5,7 @@ from flamapy.metamodels.pysat_metamodel.models import PySATModel from flamapy.metamodels.fm_metamodel.models.feature_model import Feature + class DiagnosisModel(PySATModel): """ This is a new version of the PySATModel class to support the following tasks: @@ -165,9 +166,11 @@ def _prepare_assumptions_for_kb(self, assumption: List[int], id_assumption: int) return id_assumption def _convert_keys_to_features(self, configuration: 'Configuration') -> 'Configuration': - new_elements = {Feature(key) if isinstance(key, str) else key: value for key, value in configuration.elements.items()} + new_elements = {Feature(key) if isinstance(key, str) + else key: value for key, value + in configuration.elements.items()} return Configuration(new_elements) - + def _prepare_assumptions_for_configuration(self, assumption: List[int], configuration: Configuration, id_assumption: int) -> int: @@ -194,4 +197,4 @@ def _prepare_assumptions_for_configuration(self, assumption: List[int], id_assumption += 1 - return id_assumption + return id_assumption \ No newline at end of file diff --git a/flamapy/metamodels/pysat_diagnosis_metamodel/transformations/fm_to_diag_pysat.py b/flamapy/metamodels/pysat_diagnosis_metamodel/transformations/fm_to_diag_pysat.py index 0e11f7c..88fb2f0 100644 --- a/flamapy/metamodels/pysat_diagnosis_metamodel/transformations/fm_to_diag_pysat.py +++ b/flamapy/metamodels/pysat_diagnosis_metamodel/transformations/fm_to_diag_pysat.py @@ -1,4 +1,4 @@ -from typing import Any, List +from typing import Any from flamapy.metamodels.fm_metamodel.models.feature_model import ( FeatureModel, @@ -36,7 +36,6 @@ def add_root(self, feature: Feature) -> None: # for clause in clauses: # self.destination_model.add_clause(clause) # self.destination_model.add_clause_to_map(str(relation), clauses) - def add_relation(self, relation: Relation) -> None: if relation.is_mandatory(): clauses = self._add_mandatory_relation(relation) @@ -50,7 +49,7 @@ def add_relation(self, relation: Relation) -> None: clauses = self._add_constraint_relation(relation) self._store_constraint_clauses(clauses) self.destination_model.add_clause_to_map(str(relation), clauses) - + def add_constraint(self, ctc: Constraint) -> None: def get_term_variable(term: Any) -> int: negated = False diff --git a/flamapy/metamodels/pysat_metamodel/operations/pysat_configurations.py b/flamapy/metamodels/pysat_metamodel/operations/pysat_configurations.py index 39fdd2a..5bc242a 100644 --- a/flamapy/metamodels/pysat_metamodel/operations/pysat_configurations.py +++ b/flamapy/metamodels/pysat_metamodel/operations/pysat_configurations.py @@ -7,6 +7,7 @@ from flamapy.metamodels.pysat_metamodel.models.pysat_model import PySATModel from flamapy.core.models import VariabilityModel + class PySATConfigurations(Configurations): def __init__(self) -> None: