Skip to content

Commit

Permalink
fix: problem with diagnosys operations
Browse files Browse the repository at this point in the history
  • Loading branch information
jagalindo committed Jul 23, 2024
1 parent fdf3765 commit 1316162
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -194,4 +197,4 @@ def _prepare_assumptions_for_configuration(self, assumption: List[int],

id_assumption += 1

return id_assumption
return id_assumption
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, List
from typing import Any

from flamapy.metamodels.fm_metamodel.models.feature_model import (
FeatureModel,
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 1316162

Please sign in to comment.