Beispiel #1
0
def test_generate_encoding_diagram_with_window_with_stride():
    congruent_bookend = Factor("congruent bookend?", [
        DerivedLevel("yes", Window(lambda colors, texts: colors[0] == texts[0], [color, text], 1, 3)),
        DerivedLevel("no",  Window(lambda colors, texts: colors[0] != texts[0], [color, text], 1, 3))
    ])

    block = fully_cross_block([color, text, congruent_bookend], [color, text], [])

    assert __generate_encoding_diagram(block) == "\
------------------------------------------------------\n\
|   Trial |  color   |   text   | congruent bookend? |\n\
|       # | red blue | red blue |    yes       no    |\n\
------------------------------------------------------\n\
|       1 |  1   2   |  3   4   |    17        18    |\n\
|       2 |  5   6   |  7   8   |                    |\n\
|       3 |  9   10  | 11   12  |                    |\n\
|       4 | 13   14  | 15   16  |    19        20    |\n\
------------------------------------------------------\n"

    congruent_bookend = Factor("congruent bookend?", [
        DerivedLevel("yes", Window(lambda colors, texts: colors[0] == texts[0], [color, text], 2, 2)),
        DerivedLevel("no",  Window(lambda colors, texts: colors[0] != texts[0], [color, text], 2, 2))
    ])

    block = fully_cross_block([color, text, congruent_bookend], [color, text], [])

    assert __generate_encoding_diagram(block) == "\
Beispiel #2
0
def test_generate_encoding_diagram_with_constraint_and_multiple_transitions_in_different_order(
):
    block = fully_cross_block(
        [text_repeats_factor, color, color_repeats_factor, text, con_factor],
        [color, text], [])

    assert __generate_encoding_diagram(block) == "\
Beispiel #3
0
def test_generate_encoding_diagram_with_windows():
    color3 = Factor("color3", ["red", "blue", "green"])

    yes_fn = lambda colors: colors[0] == colors[1] == colors[2]
    no_fn = lambda colors: not yes_fn(colors)
    color3_repeats_factor = Factor("color3 repeats?", [
        DerivedLevel("yes", Window(yes_fn, [color3], 3, 1)),
        DerivedLevel("no",  Window(no_fn, [color3], 3, 1))
    ])

    block = fully_cross_block([color3_repeats_factor, color3, text], [color3, text], [])

    assert __generate_encoding_diagram(block) == "\
Beispiel #4
0
def test_generate_encoding_diagram_with_transition():
    block = fully_cross_block([color, text, color_repeats_factor],
                              [color, text], [])

    assert __generate_encoding_diagram(block) == "\
Beispiel #5
0
def test_generate_encoding_diagram():
    assert __generate_encoding_diagram(blk) == "\