2-D Delaunay triangulation and convex hull, API-compatible with the triangle library.
Project description
triangular
Two-dimensional Delaunay triangulation and convex hull for Python, implemented in Rust.
The API is compatible with the triangle wrapper's
delaunay and convex_hull functions.
import numpy as np
import triangular
pts = np.array([[0, 0], [0, 1], [0.5, 0.5], [1, 1], [1, 0]], dtype=float)
triangular.delaunay(pts) # -> int32 (M, 3): 0-based vertex-index triples
triangular.convex_hull(pts) # -> int32 (K, 2): 0-based hull edge vertex pairs
These correspond to triangle.delaunay (Triangle options Qz) and triangle.convex_hull
(options Qzc). Inputs are validated in Python: anything coercible to a float64 (N, 2)
array is accepted; bad shapes, non-finite values, or fewer than three vertices raise
ValueError. Degenerate inputs with no triangulation or hull (all points collinear, all
points coincident) return an empty array of the correct shape. CONTRACT.md
documents the exact behavior, including the few places it intentionally differs from
triangle.
Layout
python/triangular/ Python package: input coercion, validation, error contract.
src/ Rust geometry core, built with PyO3.
corpus/ Validation corpus recorded from the triangle library.
tests/ pytest suite: equivalence, invariants, degenerate cases, benchmarks.
CONTRACT.md Spec for the native core.
Development
uv sync # installs dev dependencies and builds the Rust extension
uv run pytest
uv sync builds the native module via maturin; after changing
the Rust code, rebuild with uv sync --reinstall-package triangular.
The suite can also run against the real triangle library, to check that the corpus and
invariant tests are themselves correct:
TRIANGULAR_IMPL=triangle uv run pytest
Tests marked improvement (where triangular's degenerate-input behavior intentionally
differs from triangle's) are skipped in that mode.
Benchmarks
uv run pytest -m benchmark
Compares against the reference timings recorded in corpus/manifest.json. The suite reads
a few environment variables:
| Variable | Default | Meaning |
|---|---|---|
TRIANGULAR_IMPL |
triangular |
Which import package the suite exercises. |
TRIANGULAR_BENCH_TOLERANCE |
1.5 |
Max allowed triangular / triangle time ratio. |
TRIANGULAR_BENCH_MAX_N |
100000 |
Skip benchmark cases larger than this. |
TRIANGULAR_FULL_CIRCLE_MAX |
1500 |
Brute-force empty-circle check size cap. |
Linting
pre-commit runs ruff and pyright on Python and rustfmt and clippy on Rust:
uv run pre-commit install
uv run pre-commit run --all-files
Releasing
Versions live in git tags only — pyproject.toml stays pinned at the 0.0.0 placeholder
and is never edited for a release. To ship:
gh release create v0.3.0 --generate-notes
Publishing the GitHub release triggers .github/workflows/release.yml, which stamps the
version from the tag into pyproject.toml, builds wheels (linux x86_64/aarch64, macOS
universal2, windows x64 — all abi3-py312, one wheel per platform) plus an sdist, smoke
tests each wheel, and publishes to PyPI via trusted publishing. Tags must match
vX.Y.Z (optionally aN/bN/rcN suffixed); anything else fails the stamp step before
a build starts.
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 triangular-0.2.0.tar.gz.
File metadata
- Download URL: triangular-0.2.0.tar.gz
- Upload date:
- Size: 7.7 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1c80c814b04b13fd89c0d25eefa3852f902e0b2cf26731e30b06c21a9de3edd0
|
|
| MD5 |
d800f38c32813c39986afeb64301df7f
|
|
| BLAKE2b-256 |
9bd902c76b645f21aa1c2aebe163067a879fe8d58439801f1a898b8b13de0190
|
Provenance
The following attestation bundles were made for triangular-0.2.0.tar.gz:
Publisher:
release.yml on earth-mover/triangular
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
triangular-0.2.0.tar.gz -
Subject digest:
1c80c814b04b13fd89c0d25eefa3852f902e0b2cf26731e30b06c21a9de3edd0 - Sigstore transparency entry: 1805225297
- Sigstore integration time:
-
Permalink:
earth-mover/triangular@623b46aa47ddfa41b7c24846161aceccf5360748 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/earth-mover
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@623b46aa47ddfa41b7c24846161aceccf5360748 -
Trigger Event:
release
-
Statement type:
File details
Details for the file triangular-0.2.0-cp312-abi3-win_amd64.whl.
File metadata
- Download URL: triangular-0.2.0-cp312-abi3-win_amd64.whl
- Upload date:
- Size: 226.8 kB
- Tags: CPython 3.12+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b38b35a072c795de1e2ebfce89a4d1201268fa0c900018489f5d3e065cd99ec0
|
|
| MD5 |
f1a86c1a4a583b85e934374429a16c7c
|
|
| BLAKE2b-256 |
1192c7f7ef0257b8d71b94bf2f4307cb2cc3a53ea02537091add681f462c4d39
|
Provenance
The following attestation bundles were made for triangular-0.2.0-cp312-abi3-win_amd64.whl:
Publisher:
release.yml on earth-mover/triangular
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
triangular-0.2.0-cp312-abi3-win_amd64.whl -
Subject digest:
b38b35a072c795de1e2ebfce89a4d1201268fa0c900018489f5d3e065cd99ec0 - Sigstore transparency entry: 1805225337
- Sigstore integration time:
-
Permalink:
earth-mover/triangular@623b46aa47ddfa41b7c24846161aceccf5360748 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/earth-mover
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@623b46aa47ddfa41b7c24846161aceccf5360748 -
Trigger Event:
release
-
Statement type:
File details
Details for the file triangular-0.2.0-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: triangular-0.2.0-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 356.2 kB
- Tags: CPython 3.12+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3d7a7773611de08fc501f7a6e32a95ad018c14aaa683f63e0db48fd877c20da7
|
|
| MD5 |
e519fb64fd6f8b491d36f4f3c82f1fee
|
|
| BLAKE2b-256 |
b0bddaa28b7c62098e97615af6d8ca88a43ba64fac8d171d77e1e8c5b5e01dcc
|
Provenance
The following attestation bundles were made for triangular-0.2.0-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
release.yml on earth-mover/triangular
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
triangular-0.2.0-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
3d7a7773611de08fc501f7a6e32a95ad018c14aaa683f63e0db48fd877c20da7 - Sigstore transparency entry: 1805225351
- Sigstore integration time:
-
Permalink:
earth-mover/triangular@623b46aa47ddfa41b7c24846161aceccf5360748 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/earth-mover
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@623b46aa47ddfa41b7c24846161aceccf5360748 -
Trigger Event:
release
-
Statement type:
File details
Details for the file triangular-0.2.0-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: triangular-0.2.0-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 348.5 kB
- Tags: CPython 3.12+, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9eeead455ae988191a0e127a8f11a17ef586432cbf97cee09a211b91076861b0
|
|
| MD5 |
f3c4e2406b0614674079740859e5e008
|
|
| BLAKE2b-256 |
1109ccc093ad175961c836484e36df331389990ec7ac713ee79c55f276332c04
|
Provenance
The following attestation bundles were made for triangular-0.2.0-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:
Publisher:
release.yml on earth-mover/triangular
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
triangular-0.2.0-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl -
Subject digest:
9eeead455ae988191a0e127a8f11a17ef586432cbf97cee09a211b91076861b0 - Sigstore transparency entry: 1805225368
- Sigstore integration time:
-
Permalink:
earth-mover/triangular@623b46aa47ddfa41b7c24846161aceccf5360748 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/earth-mover
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@623b46aa47ddfa41b7c24846161aceccf5360748 -
Trigger Event:
release
-
Statement type:
File details
Details for the file triangular-0.2.0-cp312-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl.
File metadata
- Download URL: triangular-0.2.0-cp312-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
- Upload date:
- Size: 631.1 kB
- Tags: CPython 3.12+, macOS 10.12+ universal2 (ARM64, x86-64), macOS 10.12+ x86-64, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9235d8e7b82467064d7b7ced5eb83cb16348cb7bc44b8f976d5544169355f753
|
|
| MD5 |
adc34325637d0acf1412611e26ee24ab
|
|
| BLAKE2b-256 |
c30568db813198cd2279b26b1ef289aeee45665f5c93d8bc4adc46a5a3f049af
|
Provenance
The following attestation bundles were made for triangular-0.2.0-cp312-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl:
Publisher:
release.yml on earth-mover/triangular
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
triangular-0.2.0-cp312-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl -
Subject digest:
9235d8e7b82467064d7b7ced5eb83cb16348cb7bc44b8f976d5544169355f753 - Sigstore transparency entry: 1805225317
- Sigstore integration time:
-
Permalink:
earth-mover/triangular@623b46aa47ddfa41b7c24846161aceccf5360748 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/earth-mover
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@623b46aa47ddfa41b7c24846161aceccf5360748 -
Trigger Event:
release
-
Statement type: