source: framspy/evolalg/base/union_step.py @ 1139

Last change on this file since 1139 was 1139, checked in by Maciej Komosinski, 3 years ago

Added --debug mode that prints names of steps; final multiple evaluation now evaluates genotypes in hall of fame instead of the last population

File size: 603 bytes
Line 
1from collections import Iterable
2
3from evolalg.base.step import Step
4
5
6class UnionStep(Step):
7    def __init__(self, steps, *args, **kwargs):
8        super(UnionStep, self).__init__(*args, **kwargs)
9        if isinstance(steps, Iterable):
10            self.steps = steps
11        else:
12            self.steps = [steps]
13
14    def call(self, population):
15        super(UnionStep, self).call(population)
16        for s in self.steps:
17            population = s(population)
18        return population
19
20    def __len__(self):
21        return len(self.steps)
22
23    def __iter__(self):
24        return iter(self.steps)
Note: See TracBrowser for help on using the repository browser.