for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
"""Represents optimization strategy for group in PSO."""
import numpy as np
numpy
This can be caused by one of the following:
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
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.
__init__.py
from grortir.main.pso.group_optimization_strategy import \
GroupOptimizationStrategy
class CallsGroupOptimizationStrategy(GroupOptimizationStrategy):
def __init__(self, stages_in_group):
self.stages_in_group = stages_in_group
self.max_cost = 0
self.expected_quality = np.inf
def initialize(self):
"""
Initialize strategy.
max_cost = 0
for stage in self.stages_in_group:
max_cost += stage.max_calls
if self.expected_quality > stage.maximum_acceptable_quality:
self.expected_quality = stage.maximum_acceptable_quality
self.max_cost = max_cost
def should_continue(self, best_particle):
Args:
best_particle Particle: best particle in swarm.
Returns:
bool: true if continuation is required.
return self._is_safe_cost() and not self._is_enough_quality(
best_particle)
def _is_safe_cost(self):
The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:
class SomeClass: def some_method(self): """Do x and return foo."""
If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.
current_cost = 0
current_cost += stage.get_cost()
return current_cost < self.max_cost
def _is_enough_quality(self, best_particle):
return best_particle.best_quality <= self.expected_quality
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.