Skip to main content

Mathematical optimization for data visualization

Project description

vizopt

Mathematical optimization for data visualization, specifically designed for graph layouts with hierarchical inclusion constraints ("bubble layouts").

Uses JAX for automatic differentiation and JIT compilation to efficiently optimize layouts via gradient descent.

Read the documentation https://spectalizer.github.io/vizopt/.

Installation

pip install vizopt

To use Optuna-based schedule search (e.g. the star_curriculum notebook):

uv sync --group hyperoptim

Quick Start

import numpy as np
from vizopt.templates import circle_packing

# Define circle radii
rng = np.random.default_rng(0)
radii = rng.uniform(0.1, 1.0, size=20).tolist()

# Pack circles to minimize overlap and bounding box size
positions = circle_packing.optimize_circle_packing(
    radii=radii,
    weight_total_size=10.0,
    collision_offset=0.05,
    optim_kwargs={"n_iters": 3000, "learning_rate": 0.01},
)
# positions is a list of (x, y) tuples, one per circle

Features

  • Multi-objective optimization (edge lengths, compactness, collision avoidance, inclusion constraints)
  • Efficient JAX-based gradient descent with JIT compilation
  • Handles arbitrary hierarchical inclusion relationships
  • Automatic per-variable normalization so optimizer performance is independent of input coordinate scale
  • NetworkX integration with a consistent DiGraph convention: parent → child edges ((u, v) means v ⊂ u)

Examples

See examples/examples_with_bubbles.ipynb for detailed usage.

License

MIT

For developers

Quality assurance

Tests run automatically on every push and pull request via GitHub Actions:

uv run pytest

Type-check all notebooks locally (not in CI):

uv run python scripts/convert_all_notebooks_to_py.py

This converts each notebook to a temporary .py file, runs pyright across all of them, then deletes the generated files. Pass --no-cleanup to keep them for inspection.

Documentation

Using Zensical.

uv run zensical serve

uv run python scripts/nb_to_md.py --execute examples/circle_packing.ipynb docs/examples/from-notebook-circle-packing.md

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

vizopt-0.0.5.tar.gz (67.0 kB view details)

Uploaded Source

Built Distribution

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

vizopt-0.0.5-py3-none-any.whl (80.1 kB view details)

Uploaded Python 3

File details

Details for the file vizopt-0.0.5.tar.gz.

File metadata

  • Download URL: vizopt-0.0.5.tar.gz
  • Upload date:
  • Size: 67.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for vizopt-0.0.5.tar.gz
Algorithm Hash digest
SHA256 070d188590afd48385093ccd2c7e2dcee6cb2be4a3110c7c41a0e8e81e7408fd
MD5 cabdddb1861dfb3ad543e03124a33070
BLAKE2b-256 f7a6b995f8dad71308516af987a24f63cc7a1df25a638fce15985036852d8908

See more details on using hashes here.

Provenance

The following attestation bundles were made for vizopt-0.0.5.tar.gz:

Publisher: publish.yml on spectalizer/vizopt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file vizopt-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: vizopt-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 80.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for vizopt-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 c64da2370f8667d56ed77ea28b765bb8b81e0620639ea2953a51fea8150307eb
MD5 13352637509b40f0ca38dae7be280dea
BLAKE2b-256 75d1689b3697a0b4e5bc067dc711a0654040334855ecc8166d97a914620b34be

See more details on using hashes here.

Provenance

The following attestation bundles were made for vizopt-0.0.5-py3-none-any.whl:

Publisher: publish.yml on spectalizer/vizopt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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