ASP refactoring, sequence generation via clusterization
This commit is contained in:
parent
d2ab856d64
commit
fd59ab9e26
45 changed files with 1579 additions and 1267 deletions
53
geometric_feasibility_predicate/extensions/dict.py
Normal file
53
geometric_feasibility_predicate/extensions/dict.py
Normal file
|
@ -0,0 +1,53 @@
|
|||
class CoreDict(dict):
|
||||
"""
|
||||
Class for handling cases related to dictionaries:
|
||||
|
||||
|
||||
Args:
|
||||
dict (dict): dictionary to analysis
|
||||
"""
|
||||
|
||||
def isEquivalentByKeys(self, checkDict) -> bool:
|
||||
"""
|
||||
The function checks whether the values of the keys and the data associated with them match between the processed and the reference dictionary
|
||||
|
||||
|
||||
Args:
|
||||
checkDict (dict): reference dictionary
|
||||
|
||||
Returns:
|
||||
bool:
|
||||
"""
|
||||
|
||||
for key in self:
|
||||
value = checkDict.get(key)
|
||||
if value is None:
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
#
|
||||
def isMatchByKeys(self, checkList) -> bool:
|
||||
"""
|
||||
The function checks whether the key values match the elements of the reference list:
|
||||
|
||||
Args:
|
||||
checkList (list): reference list
|
||||
|
||||
Returns:
|
||||
bool
|
||||
"""
|
||||
if len(self) != len(checkList):
|
||||
return False
|
||||
|
||||
sorted_dict_keys = sorted(self.keys())
|
||||
sorted_list_elements = sorted(checkList)
|
||||
|
||||
if sorted_dict_keys != sorted_list_elements:
|
||||
missing_keys = [
|
||||
key for key in sorted_list_elements if key not in sorted_dict_keys
|
||||
]
|
||||
print(f"Отсутствующие элементы: {missing_keys}")
|
||||
return False
|
||||
|
||||
return True
|
Loading…
Add table
Add a link
Reference in a new issue