Last change
on this file since 1195 was
1185,
checked in by Maciej Komosinski, 2 years ago
|
Renamed a module; new name is "evolalg_steps"
|
File size:
720 bytes
|
Line | |
---|
1 | from collections import Iterable |
---|
2 | |
---|
3 | from evolalg_steps.base.step import Step |
---|
4 | |
---|
5 | |
---|
6 | class 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.