Skip to content

Commit

Permalink
Merge branch 'uned' of https://github.com/flamapy/bdd_metamodel into …
Browse files Browse the repository at this point in the history
…uned
  • Loading branch information
jmhorcas committed Aug 8, 2024
2 parents 268de66 + dfd8064 commit 47a7f46
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 12 deletions.
20 changes: 13 additions & 7 deletions flamapy/metamodels/bdd_metamodel/models/bdd_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,19 +130,25 @@ def expand_assignment(bdd_file: str, feature_assignment: list[str]) -> list[str]
# Get all feature names
with open(bdd_file, 'r', encoding='utf8') as file:
bdd_code = file.read()
varnames = re.search('varnames\\s+(.*)', bdd_code).group(1).split()
varnames_match = re.search(r'varnames\s+(.*)', bdd_code)
if not varnames_match:
raise FlamaException('No varnames found in the BDD file.')
varnames = varnames_match.group(1).split()

expanded_assignment = []
for feature in feature_assignment:
feat = None
if re.match('not\\s+', feature):
feat = re.search('not\\s+(.*)', feature).group(1)
if varnames.count(feat) == 0:
raise FlamaException(f'{feat} is not a valid feature of {bdd_file}')
feat += "=false"
if re.match(r'not\s+', feature):
feat_match = re.search(r'not\s+(.*)', feature)
if feat_match:
feat = feat_match.group(1)
if varnames.count(feat) == 0:
raise FlamaException(f'{feat} is not a valid feature of {bdd_file}')
feat += "=false"
else:
if varnames.count(feature) == 0:
raise FlamaException(feature + " is not a valid feature of " + bdd_file)
feat = feature + "=true"
expanded_assignment.append(feat)
if feat:
expanded_assignment.append(feat)
return expanded_assignment
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def configurations_number(bdd_model: BDDModel,
return result


def count(bdd_model: BDDModel, feature_assignment: list[str] = None) -> int:
def count(bdd_model: BDDModel, feature_assignment: Optional[list[str]] = None) -> int:
"""
Computes the number of valid configurations.
:param feature_assignment: a list with a partial or a complete features' assignment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ def execute(self, model: VariabilityModel) -> 'BDDFeatureInclusionProbability':

def feature_inclusion_probabilities(bdd_model: BDDModel,
precision: int,
partial_configuration: Optional[Configuration] = None) -> int:
partial_configuration: Optional[Configuration] = None
) -> dict[Any, float]:
"""
Computes the featue inclusion probabilities.
:param feature_assignment: a list with a partial or a complete features' assignment
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
flamapy-fw==2.0.0.dev6
flamapy-fm==2.0.0.dev6
flamapy-fw==2.0.0
flamapy-fm==2.0.0
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def read_requirements(file):

setuptools.setup(
name="flamapy-bdd",
version="2.0.0.uned.dev1",
version="2.0.0.post1",
author="Flamapy",
author_email="flamapy@us.es",
description="bdd-plugin for the automated analysis of feature models",
Expand Down

0 comments on commit 47a7f46

Please sign in to comment.