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

PositionUpdater._fix_coordinates()   A

Complexity

Conditions 4

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.2
cc 4
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 PositionUpdater:
0 ignored issues
show
Coding Style introduced by
This class 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...
5
    def __init__(self, stage):
6
        self.stage = stage
7
        self.lower_bounds = np.asarray(self.stage.lower_bounds)
8
        self.upper_bounds = np.asarray(self.stage.upper_bounds)
9
10
    def set_initial_control_params(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...
11
        random = np.random.rand(len(self.stage.control_params))
12
        delta = self.upper_bounds - self.lower_bounds
13
        control_params = self.lower_bounds + random * delta
14
        self.stage.control_params = control_params.tolist()
15
16
    def update_position(self, velocity):
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...
17
        self.stage.control_params = self.stage.control_params + velocity
18
        self._fix_coordinates()
19
20
    def _fix_coordinates(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...
21
        for i in range(len(self.stage.control_params)):
22
            if self.stage.control_params[i] > self.stage.upper_bounds[i]:
23
                self.stage.control_params[i] = self.stage.upper_bounds[i]
24
            elif self.stage.control_params[i] < self.stage.lower_bounds[i]:
25
                self.stage.control_params[i] = self.stage.lower_bounds[i]
26