Total Complexity | 9 |
Total Lines | 33 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | """Basic optimizer.""" |
||
7 | 1 | class Optimizer(object): |
|
8 | """Optimizer is object which optimize process.""" |
||
9 | |||
10 | 1 | def __init__(self, process): |
|
11 | 1 | self.process = process |
|
12 | 1 | self.ordered_stages = nx.topological_sort(self.process) |
|
13 | |||
14 | 1 | def set_custom_optimizing_order(self, ordered_stages): |
|
15 | """Set custom order.""" |
||
16 | 1 | if set(self.ordered_stages) == set(ordered_stages) and len( |
|
17 | self.ordered_stages) == len(ordered_stages): |
||
18 | 1 | self.ordered_stages = ordered_stages |
|
19 | else: |
||
20 | 1 | raise ValueError("List of stages must contain all stages.") |
|
21 | |||
22 | 1 | def optimize_process(self): |
|
23 | """Optimize process. |
||
24 | Returns: |
||
25 | True if success, False otherwise.""" |
||
26 | 1 | for stage in self.ordered_stages: |
|
27 | 1 | if not self.process.predecessors(stage): |
|
28 | 1 | pso(stage) |
|
29 | 1 | elif len(self.process.predecessors(stage)) == 1: |
|
30 | 1 | predecessor = self.process.predecessors(stage)[0] |
|
31 | 1 | stage.input_vector = predecessor.get_output_of_stage() |
|
32 | 1 | pso(stage) |
|
33 | else: |
||
34 | 1 | raise AttributeError('Incorrect process structure.') |
|
35 | |||
36 | 1 | if stage.optimization_status != OptimizationStatus.success: |
|
37 | 1 | return False |
|
38 | |||
39 | return True |
||
40 |
This can be caused by one of the following:
1. Missing Dependencies
This error could indicate a configuration issue of Pylint. Make sure that your libraries are available by adding the necessary commands.
2. Missing __init__.py files
This error could also result from missing
__init__.py
files in your module folders. Make sure that you place one file in each sub-folder.