Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify _calc_min_uuid_length() #3075

Merged
merged 1 commit into from
Apr 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions volttron/platform/control/control_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
# under Contract DE-AC05-76RL01830
# }}}
import collections
import os
import itertools
import sys
import re
from volttron.platform import jsonapi
Expand All @@ -48,13 +48,10 @@

def _calc_min_uuid_length(agents):
n = 0
for agent1 in agents:
for agent2 in agents:
if agent1 is agent2:
continue
common_len = len(os.path.commonprefix([agent1.uuid, agent2.uuid]))
if common_len > n:
n = common_len
for agent1, agent2 in itertools.combinations(agents, 2):
common_len = sum(1 for a, b in zip(agent1.uuid, agent2.uuid) if a == b)
if common_len > n:
n = common_len
return n + 1


Expand Down