Skip to content

Commit 7a23d42

Browse files
committed
fix(docstring): clarify deterministic group index mapping
1 parent 1f6b037 commit 7a23d42

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

‎CodeEntropy/levels/nodes/accumulators.py‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,16 @@ def run(self, shared_data: dict[str, Any]) -> dict[str, Any]:
8686

8787
@staticmethod
8888
def _build_group_index(groups: dict[int, Any]) -> GroupIndex:
89-
"""Build deterministic group id <-> index mappings.
89+
"""Build deterministic mappings between group IDs and contiguous indices.
90+
91+
Group IDs are sorted before indices are assigned, ensuring that the
92+
resulting mappings do not depend on dictionary insertion order.
9093
9194
Args:
92-
groups: Mapping of group id to group members.
95+
groups: Mapping of group IDs to their members.
9396
9497
Returns:
95-
GroupIndex mapping object.
98+
Bidirectional mappings between group IDs and contiguous indices.
9699
"""
97100
group_ids = sorted(groups)
98101
gid2i = {gid: index for index, gid in enumerate(group_ids)}

0 commit comments

Comments
 (0)