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

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

Cosmetic

File size: 714 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 init(self):
15        for s in self.steps:
16            if isinstance(s, Step):
17                s.init()
18
19    def call(self, population):
20        super(UnionStep, self).call(population)
21        for s in self.steps:
22            population = s(population)
23        return population
24
25    def __len__(self):
26        return len(self.steps)
27
28    def __iter__(self):
29        return iter(self.steps)
Note: See TracBrowser for help on using the repository browser.