Skip to main content

Adjust numerical values from a terminal user interface.

Project description

Valmix

Build Documentation Coverage PyPI version

Adjust numerical values from a terminal user interface.

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:

    # Call the main function in a separate process
    main_process = mp.Process(target=main, args=(kp, kd))
    main_process.start()

    # Display the terminal user interface in this process (blocking call)
    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:

image

Useful for instance to tune robot behaviors in real-time 😉

Installation

From PyPI

pip install valmix

See also

Related software:

  • Textual: terminal user interface (TUI) framework for Python, used to build this tool.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

valmix-0.0.1.tar.gz (14.4 kB view details)

Uploaded Source

Built Distribution

valmix-0.0.1-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

Details for the file valmix-0.0.1.tar.gz.

File metadata

  • Download URL: valmix-0.0.1.tar.gz
  • Upload date:
  • Size: 14.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.28.2

File hashes

Hashes for valmix-0.0.1.tar.gz
Algorithm Hash digest
SHA256 2b7dc93e70ab7287526e9b8853571e92cc7a7315106a4caef34a28bd39e74e1c
MD5 9cab7e8007822c3017db8406787070e5
BLAKE2b-256 d5a634951f1cee414908b352d9ea25b5fca0bcde235d8cb212c341b03b280c08

See more details on using hashes here.

File details

Details for the file valmix-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: valmix-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 10.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.28.2

File hashes

Hashes for valmix-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 75e03aa4555a638742e52fc95e18d081df1e2c2cb769b20946e1729bc3d18841
MD5 3e52ac5880b017f0792ec385f5b8d6af
BLAKE2b-256 53cb64668a5a411e5582a3adb708a1a2ef471bdd1cdedbf42355163c2b1b9ddb

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page