Download prereg-v2/patch_tach.py from eigentactics/tacheometal: direct link, hf CLI and curl.
- Browser
- Download file 2.2 kB
-
https://huggingface.co/datasets/eigentactics/tacheometal/resolve/main/prereg-v2/patch_tach.py
- Command line
-
hf download hf://datasets/eigentactics/tacheometal/prereg-v2/patch_tach.py
-
curl -L -o patch_tach.py https://huggingface.co/datasets/eigentactics/tacheometal/resolve/main/prereg-v2/patch_tach.py
2.2 kB
| """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) | |