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

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

Cosmetic

File size: 714 bytes
RevLine 
[1113]1from collections import Iterable
2
3from evolalg.base.step import Step
4
5
6class UnionStep(Step):
[1139]7    def __init__(self, steps, *args, **kwargs):
8        super(UnionStep, self).__init__(*args, **kwargs)
[1113]9        if isinstance(steps, Iterable):
10            self.steps = steps
11        else:
12            self.steps = [steps]
13
[1146]14    def init(self):
15        for s in self.steps:
16            if isinstance(s, Step):
17                s.init()
18
[1113]19    def call(self, population):
[1139]20        super(UnionStep, self).call(population)
[1113]21        for s in self.steps:
22            population = s(population)
23        return population
[1139]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.