Fast N-dimensional Delaunay triangulation with incremental point insertion
Project description
adaptive-triangulation
Fast N-dimensional Delaunay triangulation in Rust with Python bindings (PyO3).
Drop-in replacement for adaptive's Triangulation class — 5-99× faster.
Performance
Standalone triangulation (incremental insertion)
| Case | Rust | Python | Speedup |
|---|---|---|---|
| 2D, 1K pts | 38.5 ms | 668 ms | 17× |
| 2D, 5K pts | 260 ms | 8,547 ms | 33× |
| 3D, 500 pts | 133 ms | 5,571 ms | 42× |
LearnerND integration (end-to-end, ring_of_fire 2D)
| N pts | Learner2D (scipy) | LearnerND (Python) | LearnerND (Rust) |
|---|---|---|---|
| 1,000 | 0.34 s | 0.91 s | 0.23 s |
| 2,000 | 1.17 s | 1.80 s | 0.38 s |
| 5,000 | 6.99 s | 4.57 s | 0.99 s |
LearnerND + Rust is 5× faster than LearnerND + Python, and 7× faster than Learner2D at 5K points.
Installation
pip install adaptive-triangulation
Requires a Rust toolchain for building from source. Pre-built wheels are available for common platforms via CI.
Quick start
from adaptive_triangulation import Triangulation
# Build a 2D triangulation
tri = Triangulation([(0, 0), (1, 0), (0, 1), (1, 1)])
# Insert points incrementally (Bowyer-Watson)
deleted, added = tri.add_point((0.5, 0.5))
# Query properties
print(len(tri.simplices)) # number of triangles
print(tri.dim) # 2
print(tri.reference_invariant()) # True
Usage with adaptive's LearnerND
This is a drop-in replacement for adaptive's built-in triangulation.
Monkey-patch the module to use Rust triangulation everywhere:
import adaptive_triangulation as at
from adaptive.learner import learnerND as lnd_mod
from adaptive.learner.learnerND import LearnerND
# Replace both the class and standalone functions
lnd_mod.Triangulation = at.Triangulation
lnd_mod.circumsphere = at.circumsphere
lnd_mod.simplex_volume_in_embedding = at.simplex_volume_in_embedding
lnd_mod.point_in_simplex = at.point_in_simplex
# Now use LearnerND as normal — it's 5× faster
learner = LearnerND(my_function, bounds=[(-1, 1), (-1, 1)])
See examples/adaptive_learnernd.py for a full working example with timing comparison.
API
Triangulation class
tri = Triangulation(coords) # Build from initial points
tri.add_point(point) # Incremental insertion → (deleted, added)
tri.locate_point(point) # Find containing simplex
tri.circumscribed_circle(simplex) # → (center, radius)
tri.volume(simplex) # Simplex volume
tri.volumes() # All simplex volumes
tri.point_in_simplex(point, simplex) # Containment test
tri.point_in_circumcircle(pt, simplex) # Circumcircle test
tri.bowyer_watson(pt_index) # Direct Bowyer-Watson
tri.reference_invariant() # Consistency check
Properties: vertices, simplices, vertex_to_simplices, hull, dim, default_transform
Standalone functions
from adaptive_triangulation import (
circumsphere, # General circumsphere
fast_2d_circumcircle, # Optimized 2D
fast_3d_circumsphere, # Optimized 3D
point_in_simplex, # Containment test
volume, # Simplex volume
simplex_volume_in_embedding, # Volume in embedding space
orientation, # Face orientation
)
Examples
examples/basic_usage.py— Core API walkthroughexamples/adaptive_learnernd.py— LearnerND integration with timingexamples/benchmark_vs_python.py— Standalone benchmarks across dimensions
Development
# Build (requires Rust toolchain)
pip install maturin
maturin develop --release
# Tests
cargo test # Rust tests
python -m pytest tests/ -v # Python tests
# Linting
pre-commit run --all-files # ruff, mypy, cargo fmt, cargo clippy
License
BSD-3-Clause
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 adaptive_triangulation-0.1.0.tar.gz.
File metadata
- Download URL: adaptive_triangulation-0.1.0.tar.gz
- Upload date:
- Size: 76.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9a1250d6cd8d72a205a5a356bdd3899ccb0220818749b5018d75672c4d50923a
|
|
| MD5 |
9e4898e1d12606ff1d53e72526233ae9
|
|
| BLAKE2b-256 |
93c4f7b681e659cb9ccb07f8e8d1afa406c4195d4d1deb03a8634273f2e9bc31
|
Provenance
The following attestation bundles were made for adaptive_triangulation-0.1.0.tar.gz:
Publisher:
ci.yml on python-adaptive/adaptive-triangulation
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
adaptive_triangulation-0.1.0.tar.gz -
Subject digest:
9a1250d6cd8d72a205a5a356bdd3899ccb0220818749b5018d75672c4d50923a - Sigstore transparency entry: 1238650434
- Sigstore integration time:
-
Permalink:
python-adaptive/adaptive-triangulation@55ffc2b6b0412dbcbf866db3285dc1896c62b04e -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/python-adaptive
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@55ffc2b6b0412dbcbf866db3285dc1896c62b04e -
Trigger Event:
push
-
Statement type:
File details
Details for the file adaptive_triangulation-0.1.0-cp310-abi3-win_amd64.whl.
File metadata
- Download URL: adaptive_triangulation-0.1.0-cp310-abi3-win_amd64.whl
- Upload date:
- Size: 290.7 kB
- Tags: CPython 3.10+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
87086075a1c0582ec7b66c982414156053746cb8a0d082a657e8739c183f8bf2
|
|
| MD5 |
fb0d9e6afcf50ad56324915ed45bcefb
|
|
| BLAKE2b-256 |
f1b450bca8f66cbd8b711df1a4762fd37ff827e80a478d221a86d1dbc942c563
|
Provenance
The following attestation bundles were made for adaptive_triangulation-0.1.0-cp310-abi3-win_amd64.whl:
Publisher:
ci.yml on python-adaptive/adaptive-triangulation
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
adaptive_triangulation-0.1.0-cp310-abi3-win_amd64.whl -
Subject digest:
87086075a1c0582ec7b66c982414156053746cb8a0d082a657e8739c183f8bf2 - Sigstore transparency entry: 1238650447
- Sigstore integration time:
-
Permalink:
python-adaptive/adaptive-triangulation@55ffc2b6b0412dbcbf866db3285dc1896c62b04e -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/python-adaptive
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@55ffc2b6b0412dbcbf866db3285dc1896c62b04e -
Trigger Event:
push
-
Statement type:
File details
Details for the file adaptive_triangulation-0.1.0-cp310-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: adaptive_triangulation-0.1.0-cp310-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 334.7 kB
- Tags: CPython 3.10+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0259002626fccd2b9765d06f5e09fc7e37968771516f20ff23a1d358e5324051
|
|
| MD5 |
17a64b473acbfcfe0ecae4b3c7bb963c
|
|
| BLAKE2b-256 |
524f33dc53d443dbf3519446d28c7d67aa38c9622c497a55530f53de98ded3c1
|
Provenance
The following attestation bundles were made for adaptive_triangulation-0.1.0-cp310-abi3-macosx_11_0_arm64.whl:
Publisher:
ci.yml on python-adaptive/adaptive-triangulation
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
adaptive_triangulation-0.1.0-cp310-abi3-macosx_11_0_arm64.whl -
Subject digest:
0259002626fccd2b9765d06f5e09fc7e37968771516f20ff23a1d358e5324051 - Sigstore transparency entry: 1238650438
- Sigstore integration time:
-
Permalink:
python-adaptive/adaptive-triangulation@55ffc2b6b0412dbcbf866db3285dc1896c62b04e -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/python-adaptive
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@55ffc2b6b0412dbcbf866db3285dc1896c62b04e -
Trigger Event:
push
-
Statement type:
File details
Details for the file adaptive_triangulation-0.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: adaptive_triangulation-0.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 366.6 kB
- Tags: CPython 3.8, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bfb7eae4f5f5fa84d4df662ce7d3f63b80ad42079c613d75b02f7ab0a22b9d75
|
|
| MD5 |
e780f1fdef6ae913e14fdd2c2ca77e36
|
|
| BLAKE2b-256 |
7797631aa92fdfe6fe2f92544240d49043da4bcf7c4037df85c901af34f659d7
|
Provenance
The following attestation bundles were made for adaptive_triangulation-0.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
ci.yml on python-adaptive/adaptive-triangulation
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
adaptive_triangulation-0.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
bfb7eae4f5f5fa84d4df662ce7d3f63b80ad42079c613d75b02f7ab0a22b9d75 - Sigstore transparency entry: 1238650440
- Sigstore integration time:
-
Permalink:
python-adaptive/adaptive-triangulation@55ffc2b6b0412dbcbf866db3285dc1896c62b04e -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/python-adaptive
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@55ffc2b6b0412dbcbf866db3285dc1896c62b04e -
Trigger Event:
push
-
Statement type: