-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_crossing.py
37 lines (28 loc) · 1.12 KB
/
test_crossing.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import crossing
from unit import Unit
def test_crossby_chromosomes():
parents = Unit('+'*80), Unit('-'*80)
assert crossing.crossby_chromosomes(parents) == ('+'*8 + '-'*8)*5
def test_crossby_token():
parents = Unit('++++>++'), Unit('+--+--+')
assert crossing.crossby_token(parents) == '++++ -- ++ --'.replace(' ', '')
def test_crossby_consensus():
parents = Unit('++++'), Unit('+-+-'), Unit('+++-')
assert crossing.crossby_consensus(parents) == '+++-'
def test_crossby_random_draw():
parents = Unit('+++-'), Unit('+-++')
founds = set.intersection({crossing.crossby_random_draw(parents) for _ in range(10)})
assert founds <= {'+++-', '++++', '+-+-', '+-++'}
def test_crossby_pivot():
parents = Unit(']<>.->><-.>>.+>.+<<]+>->]<.><>'), Unit('.>,-<[>-.[<-<]<-.>.>-<,>>-->.<->')
found = crossing.crossby_pivot(parents)
print(found)
assert found
parents = Unit('+++...,,,..-]'), Unit('+++.[.[.')
found = crossing.crossby_pivot(parents)
print(found)
assert found
parents = Unit('+++'), Unit('-----')
found = crossing.crossby_pivot(parents)
print(found)
assert found