Total Complexity | 7 |
Total Lines | 29 |
Duplicated Lines | 0 % |
Coverage | 94.74% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | """Contain mechanism for changing position.""" |
||
6 | 1 | class PositionUpdater: |
|
7 | """Class responsible for moving objects. |
||
8 | |||
9 | Attributes: |
||
10 | stage (AbstractStage): Stage in which we are going to move. |
||
11 | """ |
||
12 | 1 | def __init__(self, stage): |
|
13 | 1 | self.stage = stage |
|
14 | 1 | self.lower_bounds = np.asarray(self.stage.lower_bounds) |
|
15 | 1 | self.upper_bounds = np.asarray(self.stage.upper_bounds) |
|
16 | |||
17 | 1 | def set_initial_control_params(self): |
|
18 | """Set initial positions.""" |
||
19 | 1 | random = np.random.rand(len(self.stage.control_params)) |
|
20 | 1 | delta = self.upper_bounds - self.lower_bounds |
|
21 | 1 | control_params = self.lower_bounds + random * delta |
|
22 | 1 | self.stage.control_params = control_params.tolist() |
|
23 | |||
24 | 1 | def update_position(self, velocity): |
|
25 | """Update positions.""" |
||
26 | 1 | self.stage.control_params = self.stage.control_params + velocity |
|
27 | 1 | self._fix_coordinates() |
|
28 | |||
29 | 1 | def _fix_coordinates(self): |
|
30 | 1 | for i in range(len(self.stage.control_params)): |
|
31 | 1 | if self.stage.control_params[i] > self.stage.upper_bounds[i]: |
|
32 | self.stage.control_params[i] = self.stage.upper_bounds[i] |
||
33 | 1 | elif self.stage.control_params[i] < self.stage.lower_bounds[i]: |
|
34 | self.stage.control_params[i] = self.stage.lower_bounds[i] |
||
35 |
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.