Ejemplo n.º 1
0
def test__sloppy_shuffles_composition_2_2():
    items = ('a', 'b', 'c', 'd')
    comp = (2, 2)
    unsigned_shuffles = list(sloppy_shuffles(items, comp))
    signed_shuffle = list(sloppy_shuffles(items, comp, yield_signature=True))
    assert (
        unsigned_shuffles == [
            ('a', 'b', 'c', 'd'),
            ('a', 'd', 'b', 'c'),
            ('a', 'd', 'c', 'b'),
            ('c', 'b', 'a', 'd'),
            ('c', 'b', 'd', 'a'),
            ('c', 'd', 'a', 'b')
        ]
    )
    assert (
        signed_shuffle == [
            (('a', 'b', 'c', 'd'), +1),
            (('a', 'd', 'b', 'c'), +1),
            (('a', 'd', 'c', 'b'), -1),
            (('c', 'b', 'a', 'd'), -1),
            (('c', 'b', 'd', 'a'), +1),
            (('c', 'd', 'a', 'b'), +1)
        ]
    )
Ejemplo n.º 2
0
def test__sloppy_shuffles_composition_1_2():
    items = ('a', 'b', 'c')
    comp = (1, 2)
    unsigned_shuffles = list(sloppy_shuffles(items, comp))
    signed_shuffle = list(sloppy_shuffles(items, comp, yield_signature=True))
    assert (unsigned_shuffles == [('a', 'b', 'c'), ('c', 'a', 'b'),
                                  ('c', 'b', 'a')])
    assert (signed_shuffle == [(('a', 'b', 'c'), +1), (('c', 'a', 'b'), +1),
                               (('c', 'b', 'a'), -1)])