def test_correct_solution_count_with_repeated_color_factor_and_no_repetition_allowed(design): crossing = [[color, text], [mix, text]] constraints = [exclude(repeated_color_factor, get_level_from_name(repeated_color_factor, "yes"))] block = multiple_cross_block(design, crossing, constraints) experiments = synthesize_trials_non_uniform(block, 100) assert len(experiments) == 32
def test_correct_solution_count_when_bookends_must_not_be_congruent(design): crossing = [color, text] # Require both bookends to not be congruent. constraints = [ exclude(congruent_bookend, get_level_from_name(congruent_bookend, "yes")) ] block = fully_cross_block(design, crossing, constraints) experiments = synthesize_trials_non_uniform(block, 100) assert len(experiments) == 4
def test_correct_solution_count_with_repeated_color_factor_and_no_repetition_allowed_cnf(design=[color, text, mix, repeated_color_factor]): crossing = [[color, text], [mix, text]] constraints = [exclude(repeated_color_factor, get_level_from_name(repeated_color_factor, "yes"))] block = multiple_cross_block(design, crossing, constraints) cnf = build_cnf(block) # with open(path_to_cnf_files+'/test_correct_solution_count_with_repeated_color_factor_and_no_repetition_allowed.cnf', 'w') as f: # f.write(cnf.as_unigen_string()) with open(path_to_cnf_files+'/test_correct_solution_count_with_repeated_color_factor_and_no_repetition_allowed.cnf', 'r') as f: old_cnf = f.read() assert old_cnf == cnf.as_unigen_string()
def test_correct_solution_count_with_override_flag_and_multiple_trials_excluded( ): # With this constraint, there should only be ONE allowed crossing, and therefore one solution. constraints = [ exclude(stimulus_configuration, get_level_from_name(stimulus_configuration, "legal")) ] block = fully_cross_block(design, crossing, constraints, require_complete_crossing=False) experiments = synthesize_trials_non_uniform(block, 500) assert block.crossing_size() == 1 assert len(experiments) == 1 assert_no_repetition(experiments)
def test_correct_solution_count_with_override_flag_and_multiple_trials_excluded_cnf( ): # With this constraint, there should only be ONE allowed crossing, and therefore one solution. constraints = [ exclude(stimulus_configuration, get_level_from_name(stimulus_configuration, "legal")) ] block = fully_cross_block(design, crossing, constraints, require_complete_crossing=False) cnf = build_cnf(block) # with open(path_to_cnf_files+'/test_correct_solution_count_with_override_flag_and_multiple_trials_excluded.cnf', 'w') as f: # f.write(cnf.as_unigen_string()) with open( path_to_cnf_files + '/test_correct_solution_count_with_override_flag_and_multiple_trials_excluded.cnf', 'r') as f: old_cnf = f.read() assert old_cnf == cnf.as_unigen_string() # FIXME
def response_left(color): return color == "green" def response_right(color): return color == "brown" response = Factor("response", [ DerivedLevel("up", WithinTrial(response_up, [color])), DerivedLevel("down", WithinTrial(response_down, [color])), DerivedLevel("left", WithinTrial(response_left, [color])), DerivedLevel("right", WithinTrial(response_right, [color])), ]) # constraints constraints = [minimum_trials(20), exclude(congruency, conLevel)] # experiment design = [color, word, congruency, response] crossing = [color, word] block = fully_cross_block(design, crossing, constraints) experiments = synthesize_trials_non_uniform(block, 1) print_experiments(block, experiments)
def illegal_stimulus(color, word): return color == "green" and word == "blue" def legal_stimulus(color, word): return not illegal_stimulus(color, word) stimulus_configuration = factor("stimulus configuration", [ derived_level("legal", within_trial(legal_stimulus, [color, word])), derived_level("illegal", within_trial(illegal_stimulus, [color, word])) ]) constraints = [ exclude(stimulus_configuration, get_level_from_name(stimulus_configuration, "illegal")) ] design = [color, word, stimulus_configuration] crossing = [color, word] def test_no_solutions_without_override_flag(): block = fully_cross_block(design, crossing, constraints) experiments = synthesize_trials_non_uniform(block, 500) assert block.crossing_size() == 6 assert len(experiments) == 0 assert_no_repetition(experiments)