source: framspy/evolalg_steps/base/union_step.py @ 1277

Last change on this file since 1277 was 1185, checked in by Maciej Komosinski, 2 years ago

Renamed a module; new name is "evolalg_steps"

File size: 720 bytes
RevLine 
[1113]1from collections import Iterable
2
[1185]3from evolalg_steps.base.step import Step
[1113]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.