Пример #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
Пример #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
Пример #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)
Пример #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)