How to use the stk.Population function in stk

To help you get started, we’ve selected a few stk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github lukasturcani / stk / tests / populations / test_populations.py View on Github external
def test_init(amine2, aldehyde2, amine3):
    """
    Tests the __init__ method of the stk.Population class.

    """

    pop = stk.Population(
        NewMol(),
        amine2,
        NewMol(),
        stk.Population(NewMol(), NewMol(), aldehyde2),
        stk.Population(),
        stk.Population(amine3, stk.Population(NewMol(), NewMol())),
        NewMol()
    )

    assert len(pop) == 10
    assert len(pop.direct_members) == 4
    assert len(pop.subpopulations) == 3
github lukasturcani / stk / tests / populations / test_populations.py View on Github external
def test_init(amine2, aldehyde2, amine3):
    """
    Tests the __init__ method of the stk.Population class.

    """

    pop = stk.Population(
        NewMol(),
        amine2,
        NewMol(),
        stk.Population(NewMol(), NewMol(), aldehyde2),
        stk.Population(),
        stk.Population(amine3, stk.Population(NewMol(), NewMol())),
        NewMol()
    )

    assert len(pop) == 10
    assert len(pop.direct_members) == 4
    assert len(pop.subpopulations) == 3
github lukasturcani / stk / tests / fixtures / populations.py View on Github external
c1,
        stk.BuildingBlock('O=CCC=O'),
        c1,
        stk.BuildingBlock('O=CCC=O', ['aldehyde']),
        stk.Population(
            c1,
            stk.BuildingBlock('[Br]CC[Br]'),
            bb1,
            bb2,
            bb1
        ),
        c2,
        stk.Population(
            bb1,
            stk.BuildingBlock('CCCC'),
            stk.Population(
                bb3,
                stk.BuildingBlock('NNNN'),
                c4
            )
github lukasturcani / stk / tests / calculators / ea / test_fitness_normalizers.py View on Github external
def test_normalizer_sequence(
    tmp_amine2,
    tmp_aldehyde2,
    tmp_bromine2
):
    sequence = stk.NormalizerSequence(
        stk.Power(2),
        stk.Sum()
    )
    for norm in sequence._normalizers:
        norm._handle_failed = False

    tmp_amine2.fitness = [1, 2, 3]
    tmp_aldehyde2.fitness = [4, 5, 6]
    tmp_bromine2.fitness = [7, 8, 9]
    pop = stk.Population(tmp_amine2, tmp_aldehyde2, tmp_bromine2)

    sequence.normalize(pop)

    assert tmp_amine2.fitness == 14
    assert tmp_aldehyde2.fitness == 77
    assert tmp_bromine2.fitness == 194
github lukasturcani / stk / tests / fixtures / populations.py View on Github external
def population():
    bb1, bb2, bb3, bb4, c1, c2, c3, c4 = _population_members()
    return stk.Population(
        c3,
        stk.BuildingBlock('NCCCN'),
        bb1,
        stk.BuildingBlock('NCCCN', ['amine']),
        c1,
        stk.BuildingBlock('O=CCC=O'),
        c1,
        stk.BuildingBlock('O=CCC=O', ['aldehyde']),
        stk.Population(
            c1,
            stk.BuildingBlock('[Br]CC[Br]'),
            bb1,
            bb2,
            bb1
        ),
        c2,
github lukasturcani / stk / tests / fixtures / populations.py View on Github external
def population():
    bb1, bb2, bb3, bb4, c1, c2, c3, c4 = _population_members()
    return stk.Population(
        c3,
        stk.BuildingBlock('NCCCN'),
        bb1,
        stk.BuildingBlock('NCCCN', ['amine']),
        c1,
        stk.BuildingBlock('O=CCC=O'),
        c1,
        stk.BuildingBlock('O=CCC=O', ['aldehyde']),
        stk.Population(
            c1,
            stk.BuildingBlock('[Br]CC[Br]'),
            bb1,
            bb2,
            bb1
        ),
        c2,
        stk.Population(
            bb1,
            stk.BuildingBlock('CCCC'),
            stk.Population(
                bb3,
                stk.BuildingBlock('NNNN'),
                c4
            )
github lukasturcani / stk / tests / fixtures / populations.py View on Github external
stk.BuildingBlock('NCCCN'),
        bb1,
        stk.BuildingBlock('NCCCN', ['amine']),
        c1,
        stk.BuildingBlock('O=CCC=O'),
        c1,
        stk.BuildingBlock('O=CCC=O', ['aldehyde']),
        stk.Population(
            c1,
            stk.BuildingBlock('[Br]CC[Br]'),
            bb1,
            bb2,
            bb1
        ),
        c2,
        stk.Population(
            bb1,
            stk.BuildingBlock('CCCC'),
            stk.Population(
                bb3,
                stk.BuildingBlock('NNNN'),
                c4
            )
github lukasturcani / stk / tests / calculators / ea / test_terminators.py View on Github external
def test_num_generations():
    pop1 = stk.Population(*(stk.Population() for i in range(5)))
    pop2 = stk.Population(*(stk.Population() for i in range(10)))
    pop3 = stk.Population(*(stk.Population() for i in range(15)))

    terminator = stk.NumGenerations(10)

    assert not terminator.terminate(pop1)
    assert terminator.terminate(pop2)
    assert terminator.terminate(pop3)
github lukasturcani / stk / tests / fixtures / populations.py View on Github external
def tmp_population():
    bb1, bb2, bb3, bb4, c1, c2, c3, c4 = _population_members()
    return stk.Population(
        c3,
        stk.BuildingBlock('NCCCN'),
        bb1,
        stk.BuildingBlock('NCCCN', ['amine']),
        c1,
        stk.BuildingBlock('O=CCC=O'),
        c1,
        stk.BuildingBlock('O=CCC=O', ['aldehyde']),
        stk.Population(
            c1,
            stk.BuildingBlock('[Br]CC[Br]'),
            bb1,
            bb2,
            bb1
        ),
        c2,
        stk.Population(
            bb1,
            stk.BuildingBlock('CCCC'),
            stk.Population(
                bb3,
                stk.BuildingBlock('NNNN'),
                c4
            )