Completed
Pull Request — master (#36)
by Wojtek
02:16
created

Optimizer   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
dl 0
loc 14
rs 10
ccs 8
cts 8
cp 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A set_custom_optimizing_order() 0 7 3
A __init__() 0 3 1
1
"""Basic optimizer."""
2 1
from networkx import topological_sort
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 Optimizer(object):
6
    """Optimizer is object which optimize process."""
7
8 1
    def __init__(self, process):
9 1
        self.process = process
10 1
        self.ordered_stages = topological_sort(self.process)
11
12 1
    def set_custom_optimizing_order(self, ordered_stages):
13
        """Set custom order."""
14 1
        if set(self.ordered_stages) == set(ordered_stages) and len(
15
                self.ordered_stages) == len(ordered_stages):
16 1
            self.ordered_stages = ordered_stages
17
        else:
18
            raise ValueError("List of stages must contain all stages.")
19