| Total Complexity | 8 |
| Total Lines | 40 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | """Represents optimization strategy for group in PSO.""" |
||
| 8 | 1 | class CallsGroupOptimizationStrategy(GroupOptimizationStrategy): |
|
| 9 | """Represents optimization strategy for group in PSO.""" |
||
| 10 | |||
| 11 | 1 | def __init__(self, stages_in_group): |
|
| 12 | 1 | self.stages_in_group = stages_in_group |
|
| 13 | 1 | self.max_cost = 0 |
|
| 14 | 1 | self.expected_quality = np.inf |
|
| 15 | |||
| 16 | 1 | def initialize(self): |
|
| 17 | """ |
||
| 18 | Initialize strategy. |
||
| 19 | """ |
||
| 20 | 1 | max_cost = 0 |
|
| 21 | 1 | for stage in self.stages_in_group: |
|
| 22 | 1 | max_cost += stage.max_calls |
|
| 23 | 1 | if self.expected_quality > stage.maximum_acceptable_quality: |
|
| 24 | 1 | self.expected_quality = stage.maximum_acceptable_quality |
|
| 25 | 1 | self.max_cost = max_cost |
|
| 26 | |||
| 27 | 1 | def should_continue(self, best_particle): |
|
| 28 | """ |
||
| 29 | |||
| 30 | Args: |
||
| 31 | best_particle Particle: best particle in swarm. |
||
| 32 | |||
| 33 | Returns: |
||
| 34 | bool: true if continuation is required. |
||
| 35 | |||
| 36 | """ |
||
| 37 | 1 | return self._is_safe_cost() and not self._is_enough_quality( |
|
| 38 | best_particle) |
||
| 39 | |||
| 40 | 1 | def _is_safe_cost(self): |
|
| 41 | 1 | current_cost = 0 |
|
| 42 | 1 | for stage in self.stages_in_group: |
|
| 43 | 1 | current_cost += stage.get_cost() |
|
| 44 | 1 | return current_cost < self.max_cost |
|
| 45 | |||
| 46 | 1 | def _is_enough_quality(self, best_particle): |
|
| 47 | return best_particle.best_quality <= self.expected_quality |
||
| 48 |
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__.pyfiles in your module folders. Make sure that you place one file in each sub-folder.