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

VelocityCalculator.__init__()   A

Complexity

Conditions 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 6
rs 9.4285
cc 1
1
import numpy as np
0 ignored issues
show
Coding Style introduced by
This module should have a docstring.

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.

Loading history...
Configuration introduced by
The import numpy 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...
2
3
4
class VelocityCalculator:
5
    """Calculate Velocity fo single stage.
6
7
    Attributes:
8
        current_velocity (list) : list of coordinates of speed for current stage
9
        """
10
11
    def __init__(self, stage):
12
        self.stage = stage
13
        self.C1 = 0.5
0 ignored issues
show
Coding Style Naming introduced by
The name C1 does not conform to the attribute naming conventions ([a-z_][a-z0-9_]{2,30}$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
14
        self.C2 = 0.5
0 ignored issues
show
Coding Style Naming introduced by
The name C2 does not conform to the attribute naming conventions ([a-z_][a-z0-9_]{2,30}$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
15
        self.w = 0.8
0 ignored issues
show
Coding Style Naming introduced by
The name w does not conform to the attribute naming conventions ([a-z_][a-z0-9_]{2,30}$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
16
        self.current_velocity = None
17
18
    def calculate_initial_velocity(self):
0 ignored issues
show
Coding Style introduced by
This method should have a docstring.

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.

Loading history...
19
        velocity = 0.02 * np.random.rand(len(self.stage.control_params)) - 0.01
20
        self.current_velocity = velocity
21
        return velocity
22
23
    def calculate(self, particle_best_position, leader_best_position):
0 ignored issues
show
Coding Style introduced by
This method should have a docstring.

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.

Loading history...
24
        velocity = self.w * self.current_velocity
25
        + self.C1 * np.random.rand(len(self.stage.control_params)) * (
0 ignored issues
show
Unused Code Bug introduced by
The expression ((+self.C1) * (np.random....stage.control_params)) does not seem to have sideeffects and its result is not used.

If a expression has no sideeffects (any lasting effect after it has been called) and its return value is not used, this usually means that this code can be removed or that an assignment is missing.

Loading history...
26
            leader_best_position - self.stage.control_params)
27
        + self.C2 * np.random.rand(len(self.stage.control_params)) * (
0 ignored issues
show
Unused Code Bug introduced by
The expression ((+self.C2) * (np.random....stage.control_params)) does not seem to have sideeffects and its result is not used.

If a expression has no sideeffects (any lasting effect after it has been called) and its return value is not used, this usually means that this code can be removed or that an assignment is missing.

Loading history...
28
            particle_best_position - self.stage.control_params)
29
        self.current_velocity = velocity
30
        return velocity
31