From fa3006d787613d15f647bf33f513375b3df74760 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20A=2E=20Galindo?= Date: Sun, 28 Jul 2024 19:04:25 +0200 Subject: [PATCH] fix: solving prospector errors on colosal bdd and creating version --- .../bdd_metamodel/models/bdd_model.py | 20 ++++++++++++------- .../operations/bdd_configurations_number.py | 2 +- .../bdd_feature_inclusion_probability.py | 3 ++- requirements.txt | 4 ++-- setup.py | 4 ++-- 5 files changed, 20 insertions(+), 13 deletions(-) diff --git a/flamapy/metamodels/bdd_metamodel/models/bdd_model.py b/flamapy/metamodels/bdd_metamodel/models/bdd_model.py index 4258a33..91c472e 100644 --- a/flamapy/metamodels/bdd_metamodel/models/bdd_model.py +++ b/flamapy/metamodels/bdd_metamodel/models/bdd_model.py @@ -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 diff --git a/flamapy/metamodels/bdd_metamodel/operations/bdd_configurations_number.py b/flamapy/metamodels/bdd_metamodel/operations/bdd_configurations_number.py index 85c2adb..b389f8d 100644 --- a/flamapy/metamodels/bdd_metamodel/operations/bdd_configurations_number.py +++ b/flamapy/metamodels/bdd_metamodel/operations/bdd_configurations_number.py @@ -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 diff --git a/flamapy/metamodels/bdd_metamodel/operations/bdd_feature_inclusion_probability.py b/flamapy/metamodels/bdd_metamodel/operations/bdd_feature_inclusion_probability.py index 80085aa..37c4a71 100644 --- a/flamapy/metamodels/bdd_metamodel/operations/bdd_feature_inclusion_probability.py +++ b/flamapy/metamodels/bdd_metamodel/operations/bdd_feature_inclusion_probability.py @@ -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 diff --git a/requirements.txt b/requirements.txt index 9cc7eb2..4ff5900 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ -flamapy-fw==2.0.0.dev6 -flamapy-fm==2.0.0.dev6 \ No newline at end of file +flamapy-fw==2.0.0 +flamapy-fm==2.0.0 \ No newline at end of file diff --git a/setup.py b/setup.py index 2e84731..6cda59f 100644 --- a/setup.py +++ b/setup.py @@ -15,8 +15,8 @@ def read_requirements(file): dev_requirements = read_requirements("requirements-dev.txt") setuptools.setup( - name="flamapy-bdd", - version="2.0.0.uned.dev1", + name="flamapy-bdd-colosal", + version="2.0.0", author="Flamapy", author_email="flamapy@us.es", description="bdd-plugin for the automated analysis of feature models",