Download assignment.py from Scherzando/RIR-Resound-User-Study: direct link, hf CLI and curl.
- Browser
- Download file 1.06 kB
-
https://huggingface.co/spaces/Scherzando/RIR-Resound-User-Study/resolve/main/assignment.py
- Command line
-
hf download hf://spaces/Scherzando/RIR-Resound-User-Study/assignment.py
-
curl -L -o assignment.py https://huggingface.co/spaces/Scherzando/RIR-Resound-User-Study/resolve/main/assignment.py
1.06 kB
| """One frozen seeded selection and presentation order, shared by all participants.""" | |
| import copy | |
| import random | |
| import uuid | |
| def build_assignment(trials, seed): | |
| rng = random.Random(seed) | |
| trial_order, option_order = [], {} | |
| for kind in ["audio", "video"]: | |
| block = [t["id"] for t in trials if t["kind"] == kind] | |
| rng.shuffle(block) | |
| trial_order.extend(block) | |
| for trial in trials: | |
| baselines = [c["id"] for c in trial["candidates"] if c["id"] != trial["ours"]] | |
| options = [trial["ours"], *rng.sample(baselines, 2)] | |
| rng.shuffle(options) | |
| option_order[trial["id"]] = options | |
| # Move video first after drawing, preserving the existing seeded options and scene orders. | |
| kinds = {t["id"]: t["kind"] for t in trials} | |
| trial_order.sort(key=lambda key: kinds[key] != "video") | |
| return {"trial_order": trial_order, "option_order": option_order} | |
| def make_assignment(study, participant_id): | |
| uuid.UUID(participant_id) | |
| return study["random_seed"], copy.deepcopy(study["assignment"]) | |