Adjust numerical values from a terminal user interface.
Project description
Valmix
Valmix ("value mixer") gives a systematic way to tune Python program parameters from your terminal (similar to alsamixer for Linux users familiar with it). Wrap your parameters in multiprocessing values, pass them to both your program and valmix.run(), and a terminal user interface will appear 🪔 allowing you to modify parameters in real time while your program is running.
Code is shorter than words in Usage below :wink:
Installation
From conda-forge
conda install -c conda-forge valmix
From PyPI
pip install valmix
Usage
Suppose you have a Python program with parameters you want to tune:
def main(kp: float, kd: float):
pass # your code here
Valmix gives a systematic way to tune these parameters from the command line. First, wrap your parameters in multiprocessing.Values:
import multiprocessing as mp
kp = mp.Value("f", 10.0)
kd = mp.Value("f", 1.0)
Next, update your program to read from the multiprocessing values. For example:
import numpy as np
import time
def main(kp: mp.Value, kd: mp.Value):
with open("/tmp/output", "w") as output:
for _ in range(100):
u = np.clip(kp.value * 1.0 + kd.value * 0.1, 5.0, 20.0)
output.write(f"{u}\n")
output.flush()
time.sleep(1.0)
Finally, run your program and Valmix together, specifying the tuning range for each value:
main_process = mp.Process(target=main, args=(kp, kd))
main_process.start()
valmix.run(
{
"kp": (kp, np.arange(0.0, 20.0, 0.5)),
"kd": (kd, np.arange(0.0, 10.0, 0.5)),
}
)
This will fire up a terminal user interface (TUI) where you can tune kp and kd while the program runs in the background:
Useful for instance to tune robot behaviors in real-time 😉
See also
Related software:
- Textual: terminal user interface (TUI) framework for Python, used to build this tool.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file valmix-1.0.0.tar.gz.
File metadata
- Download URL: valmix-1.0.0.tar.gz
- Upload date:
- Size: 52.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.32.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
48f992e92b61b4adab1460397ff45cb8e6770578683741e0d14cc61f881213e1
|
|
| MD5 |
a5948c5223f8bf8163f4374790cbc083
|
|
| BLAKE2b-256 |
771540cc4a676ac44dec126f23252d9426048d79d6757f6c004768bd51d4ffa6
|
File details
Details for the file valmix-1.0.0-py3-none-any.whl.
File metadata
- Download URL: valmix-1.0.0-py3-none-any.whl
- Upload date:
- Size: 10.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.32.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d92a1c316ac90d465b2462d3604c2dafb4fd1edc4483fce910c8a0b724aabcc6
|
|
| MD5 |
8a638e991b5ca1795d9a6f4352caf6f7
|
|
| BLAKE2b-256 |
c4b15469925c9042c104c32bc919f916cad97f59683cf1a25a3eaed768c41d6a
|