Skip to content

Commit

Permalink
Merge branch 'release/0.5.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
jara001 committed Mar 23, 2022
2 parents 82e7353 + a83047a commit 5ac98fa
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 4 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/).

## Unreleased
## 0.5.1 - 2022-03-23
### Added
- `reconfigure`:
- `update()` now supports `list(tuple(str, any))` for ordered addition of multiple parameters.

### Updated
- Readme now contains details about `update()`.

## 0.5.0 - 2022-03-22
### Added
- `reconfigure`:
Expand Down
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,23 @@ P.anotherparam = {'default': 5.2, 'min': 2, 'max': 6, 'description': 'I am just
P.smax = ["Speed_max", float, 0, "Level-1 speed", 0.158483034, 0, 0.3]
```

Parameters may be also defined at once using function `P.update(PARAMETERS)`. There are two ways to use it:

- Using dictionary (parameters are ordered randomly):
```python
PARAMETERS = {
"something": 4,
"anotherparam": {'default': 5.2, 'min': 2, 'max': 6, 'description': 'I am just a float.'},
}
```
- Using list of tuples (parameters are ordered):
```python
PARAMETERS = [
("something", 4),
("anotherparam", {'default': 5.2, 'min': 2, 'max': 6, 'description': 'I am just a float.'}),
]
```

##### Enumerated values

Example:
Expand Down
12 changes: 9 additions & 3 deletions autopsy/reconfigure.py
Original file line number Diff line number Diff line change
Expand Up @@ -840,8 +840,14 @@ def update(self, parameters):
"""Updates the parameters according to the passed dictionary.
Arguments:
parameters -- new values of the parameters, dict(str, any)
parameters -- new values of the parameters, dict(str, any) or list(tuple(str, any))
"""

for param, value in parameters.items():
self.__setattr__(param, value)
if isinstance(parameters, dict):
for param, value in parameters.items():
self.__setattr__(param, value)
elif isinstance(parameters, list):
for param, value in parameters:
self.__setattr__(param, value)
else:
raise NotImplementedError("ParameterServer.update() is not supported for type '%s'." % type(parameters))
2 changes: 1 addition & 1 deletion package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>autopsy</name>
<version>0.5.0</version>
<version>0.5.1</version>
<description>A set of Python utils for F1Tenth project.</description>

<maintainer email="[email protected]">Jaroslav Klapálek</maintainer>
Expand Down

0 comments on commit 5ac98fa

Please sign in to comment.