Skip to content

Commit

Permalink
fix connections
Browse files Browse the repository at this point in the history
  • Loading branch information
AugustUnderground committed Feb 6, 2024
1 parent aafb133 commit f44bf6b
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion yal/util/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,16 @@ def as_participant( module: core.Module, opt_fields: list[str] = None

return participant

def connects(participant, participants) -> set[str]:
"""
Weighted connections between participants
"""
name = participant['module_name']
sigs = set(participant.get('signal_names', []))
cons = { p['module_name']: len((set(p.get('signal_names', [])) & sigs) - {'G', 'P'})
for p in participants if p['module_name'] not in [name, 'bound'] }
return cons

def as_participants( modules: list[core.Module]
, rng_placement: bool = True
, colorize: bool = True
Expand Down Expand Up @@ -150,4 +160,8 @@ def as_participants( modules: list[core.Module]
else:
participants = parts

return participants
bound = [p for p in participants if p['idx'] == 'bound']
network = bound[0].get('network', []) if bound else []
cons = {n['module_name'] : connects(n, network) for n in network}

return [p | {'connections': cons.get(p['idx'])} for p in participants]

0 comments on commit f44bf6b

Please sign in to comment.