BaseOptimizer   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

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 1
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 1
class BaseOptimizer(object):
0 ignored issues
show
Complexity introduced by
This abstract class seems to be used only once.

Abstract classes which are used only once can usually be inlined into the class which already uses this abstract class.

Loading history...
6
    """Optimizer is object which optimize process."""
7
8 1
    def __init__(self, process):
9 1
        self.process = process
10 1
        self.ordered_stages = nx.topological_sort(self.process)
11 1
        self.swarm_size = 40
12
13 1
    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 1
        if set(self.ordered_stages) == set(ordered_stages) and len(
20
                self.ordered_stages) == len(ordered_stages):
21 1
            self.ordered_stages = ordered_stages
22
        else:
23 1
            raise ValueError("List of stages must contain all stages.")
24
25 1
    def optimize_process(self):
26
        """Optimize process.
27
28
        Raises:
29
            NotImplementedError: Abstract method.
30
        """
31
        raise NotImplementedError
32