File size: 2,195 Bytes
8bb0693
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""Add v2's tach_rel to census.py, with d (RULES.md): break_rel's questions, halves and reading, doses ±d and ±2d of the
stream, the collapse rule at its upper dose. Run from the checkout: python3 patch_tach.py 0.6"""
import sys
d = float(sys.argv[1])
p = "backend/census.py"
s = open(p).read()
assert '"tach_rel"' not in s
s = s.replace('DESIGN_QUESTIONS["match_ceil"] = DESIGN_QUESTIONS["break_rel"]\n',
              'DESIGN_QUESTIONS["match_ceil"] = DESIGN_QUESTIONS["break_rel"]\n'
              '# Tacheometal v2 (eigentactics, notes/tacheometal/prereg-v2): break_rel with its lower dose at the 12B\'s text-breaking edge\n'
              f'TACH_REL = {d!r}\n'
              'DESIGN_QUESTIONS["tach_rel"] = DESIGN_QUESTIONS["break_rel"]\n', 1)
s = s.replace('DESIGN_HALVES["match_ceil"] = DESIGN_HALVES["break_rel"]\n',
              'DESIGN_HALVES["match_ceil"] = DESIGN_HALVES["break_rel"]\nDESIGN_HALVES["tach_rel"] = DESIGN_HALVES["break_rel"]\n', 1)
a = '    "soft_ceil": [(p, s * d) for p in DESIGN_QUESTIONS["soft_ceil"] for d in SOFT_CEIL for s in (-1.0, 1.0)],\n'
assert s.count(a) == 1
s = s.replace(a, a + '    "tach_rel": [(p, s * d) for p in DESIGN_QUESTIONS["tach_rel"] for d in (TACH_REL, 2 * TACH_REL) for s in (-1.0, 1.0)],\n')
b = '    "match_ceil": {"max_rel": 100.0, "reference": "controls", "exclude": "own"},  # and so here\n'
assert s.count(b) == 1
s = s.replace(b, b + '    "tach_rel": {"max_rel": 2.5, "reference": "controls", "exclude": "own"},  # as break_rel: every answer counted\n')
c = 'COLLAPSE_RULE["match_ceil"] = {"doses": "upper", "answers": 2, "per_1024": 10}\n'
assert s.count(c) == 1
s = s.replace(c, c + 'COLLAPSE_RULE["tach_rel"] = {"doses": (2 * TACH_REL,), "answers": 2, "per_1024": 10}\n')
e = 'DESIGN_UNITS = {"calib_ceil": "ceiling", "break_rel": "stream",'
assert s.count(e) == 1
s = s.replace(e, 'DESIGN_UNITS = {"calib_ceil": "ceiling", "break_rel": "stream", "tach_rel": "stream",')
for key in ('DESIGN_QUESTIONS["tach_rel"]', 'DESIGN_HALVES["tach_rel"]', '"tach_rel": [(p', '"tach_rel": {"max_rel"', 'COLLAPSE_RULE["tach_rel"]', '"tach_rel": "stream"'):
    assert key in s, key
open(p, "w").write(s)
print("tach_rel added with d =", d)