stk.RemoveBatches
- class stk.RemoveBatches(remover, selector)[source]
Bases:
Selector[T]Prevents a
Selectorfrom selecting some batches.Examples
Removing Batches From Selection
You want to use
Rouletteselection on all but the 5Worstbatchesimport stk selector = stk.RemoveBatches( remover=stk.Worst(5), selector=stk.Roulette(20), ) population = { stk.MoleculeRecord( topology_graph=stk.polymer.Linear( building_blocks=[ stk.BuildingBlock('BrCCBr', stk.BromoFactory()), ], repeating_unit='A', num_repeating_units=2, ), ): i for i in range(100) } for batch in selector.select(population): # Do stuff with batch. It was selected with roulette # selection and is not one of the worst 5 batches. pass
- Parameters:
Methods
Yield batches of molecule records from population.
- select(population, included_batches=None, excluded_batches=None)[source]
Yield batches of molecule records from population.
- Parameters:
population (dict[T, float]) – A collection of molecules from which batches are selected.
included_batches (set[BatchKey] | None) – The identity keys of batches which are allowed to be yielded, if
Noneall batches can be yielded. If notNoneonly batches included_batches will be yielded.excluded_batches (set[BatchKey] | None) – The identity keys of batches which are not allowed to be yielded. If
None, no batch is forbidden from being yielded.
- Yields:
A batch of selected molecule records.
- Return type: