Skip to main content

Adjust numerical values from a terminal user interface.

Project description

Valmix

Build Documentation Coverage PyPI version

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:

image

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


Download files

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

Source Distribution

valmix-1.0.0.tar.gz (52.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

valmix-1.0.0-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

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

Hashes for valmix-1.0.0.tar.gz
Algorithm Hash digest
SHA256 48f992e92b61b4adab1460397ff45cb8e6770578683741e0d14cc61f881213e1
MD5 a5948c5223f8bf8163f4374790cbc083
BLAKE2b-256 771540cc4a676ac44dec126f23252d9426048d79d6757f6c004768bd51d4ffa6

See more details on using hashes here.

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

Hashes for valmix-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d92a1c316ac90d465b2462d3604c2dafb4fd1edc4483fce910c8a0b724aabcc6
MD5 8a638e991b5ca1795d9a6f4352caf6f7
BLAKE2b-256 c4b15469925c9042c104c32bc919f916cad97f59683cf1a25a3eaed768c41d6a

See more details on using hashes here.

Supported by

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