Python bindings for Voro++ (3D Voronoi and Laguerre tessellations) with periodic and topology utilities.
Project description
pyvoro2
Documentation: https://delonecommons.github.io/pyvoro2/
pyvoro2 is a Python interface to the C++ library Voro++ for computing 3D tessellations around a set of points:
- Voronoi tessellations (standard, unweighted)
- power / Laguerre tessellations (weighted Voronoi, via per-site radii)
The focus is not only on computing polyhedra, but on making the results useful in scientific settings that are common in chemistry, materials science, and condensed matter physics — especially periodic boundary conditions and neighbor graphs.
pyvoro2 is designed to be honest and predictable:
- it vendors and wraps an upstream Voro++ snapshot (with a small numeric robustness patch for power/Laguerre diagrams);
- the core tessellation modes are standard Voronoi and power/Laguerre.
Quickstart
1) Standard Voronoi in a bounding box
For 3D visualization, install the optional dependency: 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)))
cells = pv.compute(points, domain=box, mode='standard')
view_tessellation(
cells,
domain=box,
show_vertices=False,
)
2) Power/Laguerre tessellation (weighted Voronoi)
radii = np.full(len(points), 1.2)
cells = pv.compute(
points,
domain=box,
mode='power',
radii=radii,
include_empty=True, # power diagrams can have zero-volume cells
)
3) 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),
)
)
cells = pv.compute(points, domain=cell, return_face_shifts=True)
# Each face can include:
# adjacent_cell (neighbor id)
# adjacent_shift (which periodic image produced the face)
Numerical safety notes
Voro++ uses a few fixed absolute tolerances internally (most importantly a hard
near-duplicate check around ~1e-5 in container distance units). For very small
or very large coordinate systems, this can lead to hard process termination or
loss of accuracy.
pyvoro2 does not silently rescale your coordinates. If you work in unusual units, rescale explicitly before calling into the C++ layer.
As an additional safety net, you can ask pyvoro2 to run a fast Python-side near-duplicate pre-check before entering the C++ layer:
cells = 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')
Note: pyvoro2 vendors a Voro++ snapshot that includes the upstream numeric robustness fix for power/Laguerre mode (radical pruning). This avoids rare cross-platform edge cases where fully periodic power tessellations could yield a non-reciprocal face/neighbor graph under aggressive floating-point codegen.
Why use pyvoro2
Voro++ is fast and feature-rich, but it is a C++ library with a low-level API. pyvoro2 aims to be a scientific interface that stays close to Voro++ while adding practical pieces that are easy to get wrong:
- triclinic periodic cells (
PeriodicCell) with robust coordinate mapping - partially periodic orthorhombic cells (
OrthorhombicCell) for slabs and wires - optional per-face periodic image shifts (
adjacent_shift) for building periodic graphs - diagnostics and normalization utilities for reproducible topology work
- convenience operations beyond full tessellation:
locate(...)(owner lookup for arbitrary query points)ghost_cells(...)(probe cell at a query point without inserting it)- inverse fitting utilities for fitting power weights from desired pairwise plane locations
Documentation overview
The documentation is written as a short scientific tutorial: it starts with the geometric ideas, then explains domains and operations, and only then dives into implementation-oriented details.
| Section | What it contains |
|---|---|
| Concepts | What Voronoi and power/Laguerre tessellations are, and what you can expect from them. |
| Domains | Which containers exist (Box, OrthorhombicCell, PeriodicCell) and how to choose between them. |
| Operations | How to compute tessellations, assign query points, and compute probe (ghost) cells. |
| Topology and graphs | How to build a neighbor graph that respects periodic images, and how normalization helps. |
| Inverse fitting | Fit power/Laguerre radii from desired pairwise plane positions (with optional constraints/penalties). |
| Visualization | Optional py3Dmol helpers for debugging and exploratory analysis. |
| Examples (notebooks) | End-to-end examples that combine the pieces above. |
| API reference | The full reference (docstrings). |
Installation
Most users should install a prebuilt wheel:
pip install pyvoro2
To build from source (requires a C++ compiler and Python development headers):
pip install -e .
Testing
pyvoro2 uses pytest. The default test suite is intended to be fast and deterministic:
pip install -e ".[test]"
pytest
Additional test groups are opt-in:
-
Fuzz/property tests (randomized):
pytest -m fuzz --fuzz-n 100
-
Cross-check tests vs
pyvoro(requires installingpyvorofirst):pip install pyvoro pytest -m pyvoro --fuzz-n 100
-
Slow tests (if any are added in the future):
pytest -m slow
Tip: you can combine markers, e.g. pytest -m "fuzz and pyvoro" --fuzz-n 100.
Project status
pyvoro2 is currently in beta.
The core tessellation modes (standard and power/Laguerre) are stable, and a large part of the work in this repository focuses on tests and documentation. A future 1.0 release is planned once the inverse-fitting workflow is more mature and native 2D support is added.
AI-assisted development
Some parts of the implementation, tests, and documentation were developed with AI assistance (OpenAI ChatGPT). The maintainer reviews and integrates changes, and remains responsible for the resulting code and scientific claims.
Details are documented in the AI usage page.
License
- pyvoro2 is released under the MIT License.
- Voro++ is vendored and redistributed under its original license (see the project pages).
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyvoro2-0.4.2.post1.tar.gz.
File metadata
- Download URL: pyvoro2-0.4.2.post1.tar.gz
- Upload date:
- Size: 3.3 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f5e2ba95c41c0a1cdb6b08fecc9e311fa1e0a05d51dfb7c1eed0186f604dafda
|
|
| MD5 |
2651c1e8c6e21570f4ece92b72392103
|
|
| BLAKE2b-256 |
f86415279f3954653db097f0cb7290741b7c0fccda1609c7ad71a3e4b565321a
|
File details
Details for the file pyvoro2-0.4.2.post1-cp313-cp313-win_amd64.whl.
File metadata
- Download URL: pyvoro2-0.4.2.post1-cp313-cp313-win_amd64.whl
- Upload date:
- Size: 212.4 kB
- Tags: CPython 3.13, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ee8cc5acb98162f7081207ea27663810158de6d9376c8748e9b99fcaf89239a5
|
|
| MD5 |
9d0d9ac1bb83b7d7bfdec2c6571e3e2f
|
|
| BLAKE2b-256 |
16d86fca30c3314e2a1a3da63934c30a6db112a03bd002dc651ed0f5d5c95b1f
|
File details
Details for the file pyvoro2-0.4.2.post1-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: pyvoro2-0.4.2.post1-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 267.2 kB
- Tags: CPython 3.13, manylinux: glibc 2.24+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b8e77353ab25cd3eb1149ce6e9e4a5042e90e07e261a37b8848504329d74aaa2
|
|
| MD5 |
6056397b1beaa6eed6994b7072ba43ff
|
|
| BLAKE2b-256 |
dd1d0c075cb28eb9a6c1fc81b7a24ae9a50671c845e0e6e0ecfe1a15278c1a3a
|
File details
Details for the file pyvoro2-0.4.2.post1-cp313-cp313-macosx_11_0_arm64.whl.
File metadata
- Download URL: pyvoro2-0.4.2.post1-cp313-cp313-macosx_11_0_arm64.whl
- Upload date:
- Size: 203.2 kB
- Tags: CPython 3.13, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
105ac6651ab4e0fe66f827f96985f5891db104acfc4a8eb7750b40c3c4abc7eb
|
|
| MD5 |
ba72676ba1e0c49b81df61b26cb4ff00
|
|
| BLAKE2b-256 |
8cfe3f35d79e3ad92ae0307f0f806bb0d7d996d9e32911263fa67ba4ae8d6cd4
|
File details
Details for the file pyvoro2-0.4.2.post1-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: pyvoro2-0.4.2.post1-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 212.4 kB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a122857b443e594abfb7fdbaaf6a22f6c6cecdecc85bb750813fa34ff410ca7f
|
|
| MD5 |
4688ca9c1c3e6ce7522af566a38e0c6c
|
|
| BLAKE2b-256 |
bcc74fe9a5e65e1f8dde0e1545bb3c9a38df220aeb3fd2709daaebdf4cf630be
|
File details
Details for the file pyvoro2-0.4.2.post1-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: pyvoro2-0.4.2.post1-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 267.3 kB
- Tags: CPython 3.12, manylinux: glibc 2.24+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d157cd3e3008be996598e7dd5b76051b4908ff69710f09e05fc3a487a4eea581
|
|
| MD5 |
a705f4fd35ef367f3746851e63cb181d
|
|
| BLAKE2b-256 |
148e07bb1afb1d15494a33a5ef7d9551f96faf09d19a894db28d005bdafa134f
|
File details
Details for the file pyvoro2-0.4.2.post1-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: pyvoro2-0.4.2.post1-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 203.1 kB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8323801d0089b963441f801744006d5ad9e8a792dbe9a985994714a67126c212
|
|
| MD5 |
c7a059780c4f07b94350b3ae31ea4daf
|
|
| BLAKE2b-256 |
7329d12fe9745bfcab55ecfef67d540d16fdbd14f2cd1ed1b4006a80a591a1bb
|
File details
Details for the file pyvoro2-0.4.2.post1-cp311-cp311-win_amd64.whl.
File metadata
- Download URL: pyvoro2-0.4.2.post1-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 211.4 kB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9bd91b684a80addf8cd7e5a94edf0108e67556fdc2822de5ea6514daab6d44de
|
|
| MD5 |
7e52c4f93a97c410ff3c3ef807428397
|
|
| BLAKE2b-256 |
a51e46111e21e28ac6876885656a4240770573c48ec5ff475547232ea00ff82b
|
File details
Details for the file pyvoro2-0.4.2.post1-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: pyvoro2-0.4.2.post1-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 267.5 kB
- Tags: CPython 3.11, manylinux: glibc 2.24+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d4808d71de9045fc094142ba5d3c3dfa4a4c7d94a6adfabe078b657371dba7da
|
|
| MD5 |
b782280534d07e8b0e21881c7b2f74a9
|
|
| BLAKE2b-256 |
fec16c3df63109c9938e0a4d0fe967f3d032e684bc9eedaf36f5864ecd15f813
|
File details
Details for the file pyvoro2-0.4.2.post1-cp311-cp311-macosx_11_0_arm64.whl.
File metadata
- Download URL: pyvoro2-0.4.2.post1-cp311-cp311-macosx_11_0_arm64.whl
- Upload date:
- Size: 203.8 kB
- Tags: CPython 3.11, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a06d95f268da6f83d8af291db9089f32b64ec0c113bce5ec0cdff8f5af2f29db
|
|
| MD5 |
3a3103a19f34c90855fb78c9ba31f458
|
|
| BLAKE2b-256 |
e7055adac2007b83b99944dd9f069b1d99e0142b5422da96d196e2db28284409
|
File details
Details for the file pyvoro2-0.4.2.post1-cp310-cp310-win_amd64.whl.
File metadata
- Download URL: pyvoro2-0.4.2.post1-cp310-cp310-win_amd64.whl
- Upload date:
- Size: 210.8 kB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c2b0bd165d2b6bb828b8fcb40810e5efc134c1a41bfbc8ad85df73652ff3cc77
|
|
| MD5 |
c47edb40dc3b1aea8ff2cca1ac277f42
|
|
| BLAKE2b-256 |
b6d410fd3804498e8b0823e059d21fa063a1c52cab6e6f91b675febaa14db7d5
|
File details
Details for the file pyvoro2-0.4.2.post1-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: pyvoro2-0.4.2.post1-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 265.7 kB
- Tags: CPython 3.10, manylinux: glibc 2.24+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c3d2bef1753e28b2b63fc237576b8e69b1d3ffea14e6062131aab8ab8a7803a9
|
|
| MD5 |
159275b15c8f58cebac8581c8c638d89
|
|
| BLAKE2b-256 |
b9d6d3c3490bafe4c14d2f47ea82506261457e264cee4d0489b09a665752c4cb
|
File details
Details for the file pyvoro2-0.4.2.post1-cp310-cp310-macosx_11_0_arm64.whl.
File metadata
- Download URL: pyvoro2-0.4.2.post1-cp310-cp310-macosx_11_0_arm64.whl
- Upload date:
- Size: 202.6 kB
- Tags: CPython 3.10, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a6ede4376e23eceff51e34e2618a15a27b4672300d16f30b48c6ec579f2a056d
|
|
| MD5 |
1bf00e4af9f2f20addca30296f6f957e
|
|
| BLAKE2b-256 |
3975ee93626be403b744174fad82515c3d43d7abe5eeb62f5cab9d288cd09b9d
|