Completed
Pull Request — master (#43)
by Wojtek
07:29
created

BaseOptimizer   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
dl 0
loc 27
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __init__() 0 4 1
A optimize_process() 0 7 1
A set_custom_optimizing_order() 0 11 3
1
"""Base optimizer."""
2
import networkx as nx
0 ignored issues
show
Configuration introduced by
The import networkx could not be resolved.

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.

# .scrutinizer.yml
before_commands:
    - sudo pip install abc # Python2
    - sudo pip3 install abc # Python3
Tip: We are currently not using virtualenv to run pylint, when installing your modules make sure to use the command for the correct version.

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.

Loading history...
3
4
5
class BaseOptimizer(object):
6
    """Optimizer is object which optimize process."""
7
8
    def __init__(self, process):
9
        self.process = process
10
        self.ordered_stages = nx.topological_sort(self.process)
11
        self.swarm_size = 40
12
13
    def set_custom_optimizing_order(self, ordered_stages):
14
        """Set custom order.
15
16
        Raises:
17
            ValueError: When order doesn't contain all stages.
18
        """
19
        if set(self.ordered_stages) == set(ordered_stages) and len(
20
                self.ordered_stages) == len(ordered_stages):
21
            self.ordered_stages = ordered_stages
22
        else:
23
            raise ValueError("List of stages must contain all stages.")
24
25
    def optimize_process(self):
26
        """Optimize process.
27
28
        Raises:
29
            NotImplementedError: Abstract method.
30
        """
31
        raise NotImplementedError
32