-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinteraction.py
More file actions
36 lines (19 loc) · 1.03 KB
/
interaction.py
File metadata and controls
36 lines (19 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# Interaction control
import copy
import math
from collections import namedtuple
def scale_layout_zone(layout_zone : namedtuple, scaling_factor : float) -> dict:
new_layout_zone = layout_zone._replace(width = layout_zone.width * scaling_factor, height = layout_zone.height * scaling_factor)
return new_layout_zone
def reset_after_tightening(participants : namedtuple) -> namedtuple:
# Create defaults for clashes and aversion
idx_list = [p.idx for p in participants]
idx_str = ' '.join(idx_list)
Clashes = namedtuple('Clashes', idx_str)
Aversions = namedtuple('Aversions', idx_str)
clashes_default = Clashes(*(len(participants) * [0]))
aversions_default = Aversions(*(len(participants) * [0]))
# Insert default values
reset_participants = {p.idx : p._replace(aversions = aversions_default, clashes = clashes_default) for p in participants}
all_participants = participants._replace(**reset_participants)
return all_participants