multigeom.utils#

Shared utilities: RNG seeding, provenance records, device selection, a progress line and showing a figure in a notebook. Configuration loading and project paths are in multigeom.config.

Functions

count_parameters(module)

Return (trainable, total) parameter counts.

figure_to_png(fig[, dpi])

PNG bytes of a matplotlib figure, independent of the matplotlib backend in use.

get_device([arg])

Resolve a torch.device, preferring CUDA when available.

make_generator(seed, device)

A torch.Generator on device, seeded with seed.

provenance([config_paths, seed, argv])

Record what produced an output: git commit (and whether the tree was dirty), command line, seed, config file contents, and package versions.

set_seed(seed)

Seed Python's and torch's global generators (CPU + CUDA).

show_figure(fig[, dpi])

Display a figure in a notebook as an image.

subprocess_env([extra])

The environment for a child process that runs python -m multigeom...: this package is importable in it even if it is not installed (a source checkout), and extra is added.

Classes

ProgressLine(total[, initial, desc, unit, ...])

A one-line progress bar that is updated in place: in a notebook through display(..., display_id=True) (no ipywidgets needed, no extra lines), in a terminal with a carriage return.