Skip to main content

pyvoro2

CI Docs PyPI Python Versions License

Documentation: https://delonecommons.github.io/pyvoro2/


pyvoro2 is a scientific Python package for computing 2D and 3D Voronoi and power/Laguerre tessellations, with particular support for periodic topology and inverse fitting of power weights from partial geometric data.

v0.7.0 documentation: this site describes the v0.7.0 transition release, distributed through the v0.7.0 Git tag and PyPI. The archived v0.6.3 release remains the software baseline cited by the current separator-inverse manuscript. By maintainer decision, v0.7.0 has no GitHub Release or Zenodo record; the next full GitHub/Zenodo archival release is planned for v0.8.0.

v0.7.0 provides:

  • standard Voronoi tessellations;
  • power/Laguerre tessellations directly from mathematical weights, with the existing radius representation retained;
  • a dedicated pyvoro2.planar namespace for 2D rectangular domains;
  • bounded, partially periodic, and triclinic periodic 3D domains;
  • explicit periodic neighbor-image shifts;
  • diagnostics, validation, topology normalization, and visualization helpers;
  • separator-based inverse fitting in 2D and 3D, including graph/connectivity diagnostics, hard-constraint witnesses, realized-boundary matching, and an optional realization-aware active-set loop.

The package is evolving toward a stable architecture for forward and inverse weighted tessellations. v0.8 is a cleanup-only compatibility-removal release. Prescribed cell measures move to v0.9 and mixed separator-plus-measure fitting to v0.10; none of those later capabilities is part of v0.7.

pyvoro2 is designed to be explicit and predictable:

  • it vendors and wraps upstream Voro++ sources, including a small numeric robustness fix already accepted upstream for power/Laguerre pruning;
  • 3D and planar APIs remain separate where their backends and domain support differ;
  • power weights are the mathematical quantities, while Voro++ radii are a backend representation;
  • algebraic inverse fit and realized geometry are reported as separate layers;
  • numerical and topological failure modes are exposed through diagnostics rather than hidden fallback.

License note: pyvoro2-authored code is released under LGPLv3+ starting with version 0.6.0. Earlier versions were released under MIT. Vendored third-party code remains under its own licenses.

Quickstart

1) Standard Voronoi in a 3D box

For 3D visualization, install the optional dependency with pip install "pyvoro2[viz]".

import numpy as np
import pyvoro2 as pv
from pyvoro2.viz3d import view_tessellation

points = np.random.default_rng(0).uniform(-1.5, 1.5, size=(10, 3))
box = pv.Box(((-2, 2), (-2, 2), (-2, 2)))
result = pv.compute(points, domain=box, mode='standard')

view_tessellation(
    result.cells,
    domain=box,
    show_vertices=False,
)
Voronoi tessellation in a box

2) Planar periodic workflow

import numpy as np
import pyvoro2.planar as pv2

points2d = np.array([
    [0.2, 0.2],
    [0.8, 0.25],
    [0.4, 0.8],
], dtype=float)

cell2d = pv2.RectangularCell(
    ((0.0, 1.0), (0.0, 1.0)),
    periodic=(True, True),
)
result2d = pv2.compute(
    points2d,
    domain=cell2d,
    return_diagnostics=True,
    normalize='topology',
)

diagnostics2d = result2d.require_tessellation_diagnostics()
topology2d = result2d.require_normalized_topology()

3) Power/Laguerre tessellation

The forward compute(...) APIs accept mathematical power weights directly:

weights = np.linspace(-0.2, 0.2, len(points))

result = pv.compute(
    points,
    domain=box,
    mode='power',
    weights=weights,
    include_empty=True,
)

The power function is ||x - p_i||^2 - w_i: weights have squared-length units, may be negative, and are converted to non-negative backend radii using one common global shift. Adding the same constant to every weight leaves the complete diagram unchanged. Existing radii= calls remain available, but the resulting length-unit radii are a non-unique backend representation rather than necessarily physical radii. Supply exactly one of weights= or radii= in power mode. Finite representability is necessary for conversion but does not guarantee a numerically resolvable native tessellation. Voro++ evaluates radical geometry with binary64 squared-radius arithmetic, so very large absolute radii**2 values or genuine weight ranges relative to squared coordinate/domain scales can lose geometric resolution. There is no universal safe cutoff: the onset depends on scale, geometry, platform, and compiler, and periodic power tessellations are a particularly sensitive regime. See Power diagrams for the precise distinction.

4) Periodic crystal cell with neighbor image shifts

cell = pv.PeriodicCell(
    vectors=(
        (10.0, 0.0, 0.0),
        (2.0,  9.0, 0.0),
        (1.0,  0.5, 8.0),
    )
)

result = pv.compute(points, domain=cell, return_face_shifts=True)

# result.require_boundaries() returns faces aligned with input-site order.
# Each face can include:
#   adjacent_cell  (neighbor site id)
#   adjacent_shift (which periodic image produced the face)

5) Fit weights from separator observations

import pyvoro2.inverse as inverse
import pyvoro2.inverse.separator as separator

points_pair = np.array([
    [0.0, 0.0, 0.0],
    [2.0, 0.0, 0.0],
])
pair_box = pv.Box(((-5, 5), (-5, 5), (-5, 5)))

observations = inverse.resolve_separator_observations(
    points_pair,
    [(0, 1, 0.25)],
    measurement='fraction',
    domain=pair_box,
)

fit = inverse.fit_weights_from_separators(
    points_pair,
    observations,
    model=separator.FitModel(mismatch=separator.SquaredLoss()),
)

The small pyvoro2.inverse surface is the normal fixed-observation route. Advanced models, realized-boundary checks, reports, and the experimental active-set workflow are available explicitly from pyvoro2.inverse.separator.

Numerical safety notes

Voro++ uses fixed absolute tolerances internally, including a hard near-duplicate check around approximately 1e-5 in container distance units. Very small or very large coordinate systems can therefore cause process termination inside the backend or loss of geometric accuracy.

pyvoro2 does not silently rescale coordinates. Rescale explicitly when using unusual units.

A Python-side near-duplicate precheck can run before the native call:

result = pv.compute(points, domain=cell, duplicate_check='raise')

For stricter post-hoc checks, see:

  • pyvoro2.validate_tessellation(..., level='strict');
  • pyvoro2.validate_normalized_topology(..., level='strict');
  • pyvoro2.planar.validate_tessellation(..., level='strict');
  • pyvoro2.planar.validate_normalized_topology(..., level='strict').

The vendored Voro++ snapshot includes the upstream robustness fix for radical pruning in power mode. This avoids rare cross-platform cases where fully periodic power tessellations could produce a non-reciprocal face/neighbor graph under aggressive floating-point code generation.

Why use pyvoro2?

Voro++ is fast and mature, but its low-level C++ interface does not provide all of the Python-side contracts needed in scientific workflows. pyvoro2 adds:

  • triclinic periodic cells and coordinate mapping in 3D;
  • partially periodic orthorhombic cells for slabs and wires;
  • explicit planar support through pyvoro2.planar;
  • periodic image-labelled faces and edges for graph construction;
  • diagnostics and normalization for reproducible topology;
  • owner lookup with locate(...);
  • non-inserting probe cells with ghost_cells(...);
  • separator-based inverse fitting with inspectable graph, feasibility, realization, and active-set diagnostics.

Documentation overview

Section What it contains
Choosing an API Preferred forward and inverse entry points, lifecycle status, result layers, and the static scalability contract.
Concepts A concise user introduction to Voronoi and power/Laguerre tessellations.
Glossary Power weights, backend radii, gauge, separator observations, realization, and active-set terminology.
Domains (3D) Box, OrthorhombicCell, and PeriodicCell.
Planar (2D) The planar namespace, rectangular periodicity, diagnostics, normalization, and plotting.
Operations Forward tessellation, owner lookup, and ghost-cell workflows.
Topology and graphs Periodic image-labelled adjacency and normalized topology.
Separator fitting Current inverse API, result diagnostics, realization matching, and active-set refinement.
v0.7 migration Exact v0.6.3-to-v0.7 changes and the fixed v0.8 removal horizon.
Theory API-independent definitions of power diagrams, weights, gauge, and separator inversion.
Development Architecture, workflow, documentation conventions, release plans, API lifecycle, and decision records.
Visualization Optional py3Dmol and matplotlib helpers.
Examples Executable notebook workflows.
API reference Exact signatures and docstring reference for spatial, planar, and separator-fitting APIs.
Roadmap v0.7 stabilization, v0.8 cleanup, v0.9 prescribed measures, v0.10 mixed fitting, 1.0, and future research.

Installation

Most users should install a prebuilt wheel:

pip install pyvoro2

Optional extras:

  • pyvoro2[sparse] for optional SciPy sparse-direct static quadratic separator fitting;
  • pyvoro2[viz] for 3D py3Dmol and 2D plotting;
  • pyvoro2[viz2d] for 2D matplotlib plotting only;
  • pyvoro2[all] for the full local notebook, docs, lint, test, and release validation stack.

Source builds require Python 3.10+, a C++17 compiler, CMake 3.20 or newer, and Python development headers. Ninja is recommended because the build backend uses CMake efficiently with it. Typical toolchains are GCC or Clang on Linux, Xcode Command Line Tools on macOS, and Visual Studio Build Tools with the "Desktop development with C++" workload on Windows. These are source-build requirements, not pyvoro2 runtime dependencies.

For an editable runtime-only build:

python -m pip install --upgrade pip
python -m pip install -e .

For local repository development and all validation tools:

python -m pip install --upgrade pip
python -m pip install -e ".[all]"

See Contributing for platform notes and clean-environment verification.

Testing

The default deterministic suite is:

pip install -e ".[test]"
pytest -q

Additional opt-in groups:

# Randomized property/fuzz checks
pytest -m fuzz --fuzz-n 100

# Independent wrapper cross-checks; requires pyvoro
pip install pyvoro
pytest -m pyvoro --fuzz-n 100

For a complete local publishability pass:

python tools/release_check.py

Project status and support

pyvoro2 is currently beta. v0.7.0 is the current transition release, distributed through the v0.7.0 Git tag and PyPI, and contains the common forward/result contract and preferred separator API. The archived v0.6.3 release remains the software baseline cited by the separator-inverse manuscript. No GitHub Release or Zenodo archive was created for v0.7.0; v0.8 removes the bounded compatibility layer and is intended to be the next full GitHub/Zenodo archival release before new inverse families begin in v0.9. The archived v0.7 development plan records the delivered scope, accepted decisions, qualification evidence, and deferrals.

Reproducible bugs and focused feature proposals are welcome through GitHub issues. Development is currently led by one maintainer, so support is best-effort. Contribution and decision policies are described in CONTRIBUTING.md.

AI-assisted development

The project has used the latest Chat and Codex models available at the time of development for planning, implementation support, testing, and documentation. The maintainer reviews and validates all integrated changes and remains responsible for the software and scientific claims.

See AI-assisted development for details.

License

  • pyvoro2-authored code is LGPLv3+ starting with version 0.6.0;
  • versions before 0.6.0 were released under MIT;
  • vendored Voro++ code remains under its upstream license.

This README is auto-generated from the MkDocs sources in docs/. To update it, edit the docs pages and re-run: python tools/gen_readme.py.

Download files

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

Source Distribution

pyvoro2-0.7.0.tar.gz (965.5 kB view details)

Uploaded Source

Built Distributions

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

pyvoro2-0.7.0-cp313-cp313-win_amd64.whl (437.0 kB view details)

Uploaded CPython 3.13Windows x86-64

pyvoro2-0.7.0-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (484.3 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

pyvoro2-0.7.0-cp313-cp313-macosx_11_0_arm64.whl (392.6 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

pyvoro2-0.7.0-cp312-cp312-win_amd64.whl (437.0 kB view details)

Uploaded CPython 3.12Windows x86-64

pyvoro2-0.7.0-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (484.5 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

pyvoro2-0.7.0-cp312-cp312-macosx_11_0_arm64.whl (392.5 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

pyvoro2-0.7.0-cp311-cp311-win_amd64.whl (435.1 kB view details)

Uploaded CPython 3.11Windows x86-64

pyvoro2-0.7.0-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (484.6 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

pyvoro2-0.7.0-cp311-cp311-macosx_11_0_arm64.whl (393.4 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

pyvoro2-0.7.0-cp310-cp310-win_amd64.whl (434.4 kB view details)

Uploaded CPython 3.10Windows x86-64

pyvoro2-0.7.0-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (481.7 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

pyvoro2-0.7.0-cp310-cp310-macosx_11_0_arm64.whl (390.9 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

Details for the file pyvoro2-0.7.0.tar.gz.

File metadata

  • Download URL: pyvoro2-0.7.0.tar.gz
  • Upload date:
  • Size: 965.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.14

File hashes

Hashes for pyvoro2-0.7.0.tar.gz
Algorithm Hash digest
SHA256 ef7a2a24d7955210a5dc7607b8e20cefbe3930a2650c6730b90c8a4b8e36cf94
MD5 0d5df1cafaa73181e674ec752b5b4332
BLAKE2b-256 53def364236ac47fa1fa461dbda4396066cfffbc760e8c26e2da092fb14c1681

See more details on using hashes here.

File details

Details for the file pyvoro2-0.7.0-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: pyvoro2-0.7.0-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 437.0 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.14

File hashes

Hashes for pyvoro2-0.7.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 3e0ea0cc98fc6ec3afb47ba538460fceb26ab8042d65395f6db09746278d45f6
MD5 3a24642eebfb4f939051d34fe7770fcf
BLAKE2b-256 8035e0241d4030adc02d9e85cb6eeca9d6efdab075768c9e0bdddbb4eb0182f7

See more details on using hashes here.

File details

Details for the file pyvoro2-0.7.0-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyvoro2-0.7.0-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3734ef498078495574ef693e4cc84255fcdf84de8285ff3fc02d5a115eafc377
MD5 666fedd2b973030559d5d208dd4d5e13
BLAKE2b-256 366e834a6ed08563d392e2daa434cbd3fef933bd94f4fd03a8e9432b896f625a

See more details on using hashes here.

File details

Details for the file pyvoro2-0.7.0-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyvoro2-0.7.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 fcea8b81cc74475e517f1ffc245b14c39d7f41e21c6646e75be1941ef077904d
MD5 62d055866a4c9292a496759e7ec1d2b1
BLAKE2b-256 614de44f42d56b5ccbc4a314ad73bacce5d9381e102a548aac9c9c1be3998fb3

See more details on using hashes here.

File details

Details for the file pyvoro2-0.7.0-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: pyvoro2-0.7.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 437.0 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.14

File hashes

Hashes for pyvoro2-0.7.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 2218accc8e45c429f6abaf763b88025bb57bd1f00b47ede6a8de446bd012260e
MD5 b634aa734ef786cc8d08631fcad1e16e
BLAKE2b-256 3f311c09793371c58aa289a177309ecc36dcc26b2821ace05f37931cada11228

See more details on using hashes here.

File details

Details for the file pyvoro2-0.7.0-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyvoro2-0.7.0-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 9993d72c491513ea9627c86bc6ad5b264f91c65b217f0e40c8a9c4b4bab109e1
MD5 5735664e6f917d3e34f6f57c33d9dadc
BLAKE2b-256 fd5102fbeb002f5d238e157d91e900eb493e204590471372f3b8bab5cd1705b4

See more details on using hashes here.

File details

Details for the file pyvoro2-0.7.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyvoro2-0.7.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 76f16ea738d47d4d5bf879a378d76eba498eb43fa99312a3f5084413554cf6ce
MD5 5e3eb035610317906f5f29e5c564f6c9
BLAKE2b-256 5fdf832ea5e8ffb7ba284d9e4da19be754140323c8614cd1fc912eab0db9e925

See more details on using hashes here.

File details

Details for the file pyvoro2-0.7.0-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: pyvoro2-0.7.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 435.1 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.14

File hashes

Hashes for pyvoro2-0.7.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 d47117527e0b49257d3dff4780497d35c0f086687e731eb469b1cc76ccec2420
MD5 5ac4fee4b1b2ae14f62489477e2414b3
BLAKE2b-256 975b5346935272458d3da77d168437799bc520c8aadb73b44b022d66c0a6388f

See more details on using hashes here.

File details

Details for the file pyvoro2-0.7.0-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyvoro2-0.7.0-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 34df092b9f1a1ded324037c7d48f0e3c36cb692ae0bd2ea5a5f8d6ee488d283f
MD5 fc6beb28d201c52172829a4efaecd397
BLAKE2b-256 9d6251ca9194bb826d423b4fd7c51c65d9fe6778c3686ed70e2053254e924f87

See more details on using hashes here.

File details

Details for the file pyvoro2-0.7.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyvoro2-0.7.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2302139e4b07583b30c37584c25cb8a37c98b825fa1822a2b1ba6dc7108bd816
MD5 a06e8f71b56934a1aec5504e084ae4b5
BLAKE2b-256 a00e6ac8326ea8887d84a1ccbe3ebd3f2cec70dfbfd1670ae9aaf2672fb6f343

See more details on using hashes here.

File details

Details for the file pyvoro2-0.7.0-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: pyvoro2-0.7.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 434.4 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.14

File hashes

Hashes for pyvoro2-0.7.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 1d9b45f41a03cdcfdb4ffe71bcf87f28d2aabc220d998af48a4d17ae650528a4
MD5 b7c3afdfe960ffa7312f51fbd3dbba1e
BLAKE2b-256 472c18fd25d390c2e73d7aa082d50de2073b2f896bb39c371b2728118714058f

See more details on using hashes here.

File details

Details for the file pyvoro2-0.7.0-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyvoro2-0.7.0-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b9a4009e4d5668c5a3815c1773f7c86db4eef2b1841b619a531be43e0b2fbcb6
MD5 38b5887ee24671228e6d6bbcde42a187
BLAKE2b-256 3f4dccb81a1dc19c4beb7506320f41e745e92b57738d6b2f2684cde4a61ac387

See more details on using hashes here.

File details

Details for the file pyvoro2-0.7.0-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyvoro2-0.7.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4735a54a4145c41e6c069cbddeb3a2c0bf4b9c7fe025cd445021e606d0aa4318
MD5 f28f6dd0220ea40d7453b396a5676c38
BLAKE2b-256 1b15d7c34070624c529372e7de5fd266b0cc2075b8378fe96594d571b149d4dc

See more details on using hashes here.

Release history Release notifications | RSS feed

0.8.0

21 files

This release

0.7.0 This release

13 files

0.6.3

13 files

0.6.1

13 files

0.4.2.post1

13 files

0.4.2

21 files

0.4.0

21 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page