Skip to content

Commit fcd8057

Browse files
committed
FIX:catch up with main
1 parent ccc7e35 commit fcd8057

1 file changed

Lines changed: 10 additions & 30 deletions

File tree

src/gh/diffCheck/diffCheck/df_util.py

Lines changed: 10 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -163,40 +163,20 @@ def get_doc_2_meters_unitf():
163163
def merge_shared_indexes(original_dict):
164164
"""
165165
Merge the shared indexes of a dictionary
166-
167166
Assume we have a dictionary with lists of indexes as values.
168167
We want to merge the lists that share some indexes, in order to have a dictionary with, for each key, indexes that are not present under other keys.
169-
170168
:param original_dict: the dictionary to merge
171169
:return: the merged dictionary
172170
"""
173-
merged_dict = {}
174-
index_to_key = {}
171+
new_dict = {}
175172

176173
for key, (face, indexes) in original_dict.items():
177-
merged_indexes = set(indexes)
178-
keys_to_merge = set()
179-
180-
for index in indexes:
181-
if index in index_to_key:
182-
keys_to_merge.add(index_to_key[index])
183-
184-
for merge_key in keys_to_merge:
185-
merged_indexes.update(merged_dict[merge_key][1])
186-
# del merged_dict[merge_key]
187-
188-
for index in merged_indexes:
189-
index_to_key[index] = key
190-
191-
merged_dict[key] = (face, list(merged_indexes))
192-
193-
keys_with_duplicates = {}
194-
195-
for key in merged_dict.keys():
196-
for other_key, (face, indexes) in merged_dict.items():
197-
if key in indexes:
198-
if key not in keys_with_duplicates:
199-
keys_with_duplicates[key] = []
200-
keys_with_duplicates[key].append(other_key)
201-
202-
return merged_dict
174+
intersection_found = False
175+
for other_key, (other_face, other_indexes) in original_dict.items():
176+
if key != other_key:
177+
if set(indexes).intersection(set(other_indexes)):
178+
new_dict[key] = (face, list(set(indexes).union(set(other_indexes))))
179+
intersection_found = True
180+
if not intersection_found:
181+
new_dict[key] = (face, indexes)
182+
return new_dict

0 commit comments

Comments
 (0)