|
29 | 29 | from openai_pygenerator import Completion, logger |
30 | 30 | from pytest_lazyfixture import lazy_fixture |
31 | 31 |
|
32 | | -from llm_cooperation import DEFAULT_MODEL_SETUP, Group, Participant, Payoffs |
33 | | -from llm_cooperation.experiments import AI_PARTICIPANTS |
| 32 | +from llm_cooperation import DEFAULT_MODEL_SETUP, Group, Participant, Payoffs, exhaustive |
| 33 | +from llm_cooperation.experiments import AI_PARTICIPANTS, GROUP_PROMPT_CONDITIONS |
34 | 34 | from llm_cooperation.experiments.dilemma import ( |
35 | 35 | CONDITION_LABELS_REVERSED, |
36 | 36 | CONDITION_PRONOUN, |
|
47 | 47 | defect_label, |
48 | 48 | extract_choice_pd, |
49 | 49 | get_choice_template, |
| 50 | + get_participants, |
50 | 51 | get_prompt_pd, |
51 | 52 | get_pronoun_phrasing, |
52 | 53 | move_as_str, |
@@ -236,6 +237,18 @@ def test_cooperate_label_reversed(condition: Participant, expected: str): |
236 | 237 | assert cooperate_label(condition_reversed) == expected |
237 | 238 |
|
238 | 239 |
|
| 240 | +def test_get_participants(): |
| 241 | + n = 5 |
| 242 | + random_participants = get_participants(num_participant_samples=n) |
| 243 | + assert len(random_participants) == n * len( |
| 244 | + list(exhaustive(GROUP_PROMPT_CONDITIONS)) |
| 245 | + ) |
| 246 | + assert get_participants(n) == random_participants |
| 247 | + factorial_participants = get_participants(num_participant_samples=0) |
| 248 | + assert get_participants(0) == factorial_participants |
| 249 | + assert len(factorial_participants) == 3888 |
| 250 | + |
| 251 | + |
239 | 252 | def test_run_repeated_game(mocker, base_condition): |
240 | 253 | completions = [ |
241 | 254 | {"role": "assistant", "content": "project green"}, |
|
0 commit comments