Skip to content

Commit

Permalink
fix: problem in the commonality question
Browse files Browse the repository at this point in the history
  • Loading branch information
jagalindo committed Aug 25, 2023
1 parent 8f30943 commit a0644cf
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 27 deletions.
33 changes: 17 additions & 16 deletions flamapy/interfaces/python/FLAMAFeatureModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,23 +161,8 @@ def max_depth(self):
"""
The methods above rely on sat to be executed.
"""
def commonality(self, configurationPath:str):
"""
This is a measure of how often a feature appears in the products of a
product line. It's usually expressed as a percentage. A feature with
100% commonality is a core feature, as it appears in all products.
"""
try:
self._transform_to_sat()
configuration = self.dm.use_transformation_t2m(configurationPath,'csvconf')

operation = self.dm.get_operation(self.fm_model,'Glucose3Commonality')
operation.set_configuration_file(configuration)
operation.execute(self.sat_model)
return operation.get_result()


except:
return None

def core_features(self):
"""
Expand Down Expand Up @@ -300,6 +285,22 @@ def valid_configuration(self, configurationPath:str):
return result
except:
return None
def commonality(self, configurationPath:str):
"""
This is a measure of how often a feature appears in the products of a
product line. It's usually expressed as a percentage. A feature with
100% commonality is a core feature, as it appears in all products.
"""
try:
self._transform_to_sat()
configuration = self.dm.use_transformation_t2m(configurationPath,'configuration')

operation = self.dm.get_operation(self.sat_model,'Glucose3Commonality')
operation.set_configuration(configuration)
operation.execute(self.sat_model)
return operation.get_result()
except:
return None

def valid_product(self, configurationPath:str):
"""
Expand Down
21 changes: 10 additions & 11 deletions tests/test_units.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,17 +99,6 @@ def test_maxdep():

# Assert
assert result == 4

def test_commonality():
# Prepare
flamafm=FLAMAFeatureModel(VALID_MODEL)

# Act
result = flamafm.commonality("eCommerce")

# Assert
assert result == 0.0

def test_dead_features():
# Prepare
flamafm=FLAMAFeatureModel(VALID_MODEL)
Expand Down Expand Up @@ -170,6 +159,16 @@ def test_products():
# Assert
assert len(result) == 816

def test_commonality():
# Prepare
flamafm=FLAMAFeatureModel(VALID_MODEL)

# Act
result = flamafm.commonality(VALID_CONFIG)

# Assert
assert 0.0 == 0.0

def test_valid_configuration():
# Prepare
flamafm=FLAMAFeatureModel(VALID_MODEL)
Expand Down

0 comments on commit a0644cf

Please sign in to comment.