Beispiel #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
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
Beispiel #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)
def test_invalid_replace_bits(start, stop):
    ga = BinaryGA(list(range(10)), fitness_test_func)

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