Exemplo n.º 1
0
def test_valid_replace_bits(start, stop, result):
    ga = BinaryGA(list(range(21)), fitness_test_func, cross_prob=1)

    source = [10, 5, 20]
    mutant = ga._replace_bits(source, [], start, stop)

    assert len(mutant) == len(result)

    for bit in result:
        assert bit in mutant
Exemplo n.º 2
0
def test_valid_replace_bits(start, stop, result):
    ga = BinaryGA(list(range(21)), fitness_test_func, cross_prob=1)

    source = [10, 5, 20]
    mutant = ga._replace_bits(source, [], start, stop)

    assert len(mutant) == len(result)

    for bit in result:
        assert bit in mutant
Exemplo n.º 3
0
def test_invalid_replace_bits(start, stop):
    ga = BinaryGA(list(range(10)), fitness_test_func)

    with pytest.raises(ValueError):
        ga._replace_bits([], [], start, stop)
Exemplo n.º 4
0
def test_invalid_replace_bits(start, stop):
    ga = BinaryGA(list(range(10)), fitness_test_func)

    with pytest.raises(ValueError):
        ga._replace_bits([], [], start, stop)