def test_correct_solution_count_with_repeated_color_factor_but_unconstrained(design): crossing = [[color, text], [text, mix]] constraints = [] block = multiple_cross_block(design, crossing, constraints) experiments = synthesize_trials_non_uniform(block, 100) assert len(experiments) == 96
def test_correct_solution_count_with_congruence_factor_and_constrained(design): crossing = [[color, text], [text, mix]] constraints = [at_most_k_in_a_row(1, (con_factor, get_level_from_name(con_factor, "con")))] block = multiple_cross_block(design, crossing, constraints) experiments = synthesize_trials_non_uniform(block, 100) assert len(experiments) == 48
def test_correct_solution_count_with_congruence_factor_and_constrained_exactly(design): crossing = [[color, text], [text, mix]] constraints = [exactly_k_in_a_row(2, con_factor)] block = multiple_cross_block(design, crossing, constraints) experiments = synthesize_trials_non_uniform(block, 100) assert len(experiments) == 32
def test_correct_solution_count(design): crossing = [[color, mix], [text, mix]] constraints = [] block = multiple_cross_block(design, crossing, constraints) experiments = synthesize_trials_non_uniform(block, 100) assert len(experiments) == 96
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_with_repeated_color_factor_and_constrained(design): crossing = [[color, text], [mix, text]] constraints = [at_most_k_in_a_row(1, (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) # With only two colors, there can never be two color repetitons anyways, # so the total should still be the same. assert len(experiments) == 96
def test_correct_solution_count_with_repeated_color_and_text_factors_and_constrained(design): crossing = [[color, text], [mix, text]] constraints = [ at_most_k_in_a_row(1, (repeated_color_factor, get_level_from_name(repeated_color_factor, "yes"))), at_most_k_in_a_row(1, (repeated_text_factor, get_level_from_name(repeated_text_factor, "yes"))) ] block = multiple_cross_block(design, crossing, constraints) experiments = synthesize_trials_non_uniform(block, 100) assert len(experiments) == 96
def test_correct_solution_count_with_congruence_factor_and_constrained_exactly_cnf(design=[color, text, mix, con_factor]): crossing = [[color, text], [text, mix]] constraints = [exactly_k_in_a_row(2, con_factor)] block = multiple_cross_block(design, crossing, constraints) cnf = build_cnf(block) # with open(path_to_cnf_files+'/test_correct_solution_count_with_congruence_factor_and_constrained_exactly.cnf', 'w') as f: # f.write(cnf.as_unigen_string()) with open(path_to_cnf_files+'/test_correct_solution_count_with_congruence_factor_and_constrained_exactly.cnf', 'r') as f: old_cnf = f.read() assert old_cnf == cnf.as_unigen_string()
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()
return congruent_stimulus(left, right) and not congruent_context(left, right) def inc_inc(left, right): return not congruent_stimulus(left, right) and not congruent_context(left, right) def inc_con(left, right): return not congruent_stimulus(left, right) and congruent_context(left, right) four_case = Factor("four_case", [ DerivedLevel("con_con", WithinTrial(con_con, [left, right])), DerivedLevel("con_inc", WithinTrial(con_inc, [left, right])), DerivedLevel("inc_inc", WithinTrial(inc_inc, [left, right])), DerivedLevel("inc_con", WithinTrial(inc_con, [left, right])) ]) # DEFINE SEQUENCE CONSTRAINTS constraints = [] # DEFINE EXPERIMENT design = [left, right, four_case] crossing = [[left, four_case], [right,four_case]] block = multiple_cross_block(design, crossing, constraints) # SOLVE experiments = synthesize_trials_non_uniform(block, 1) print_experiments(block, experiments)