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.
Metadata
Release files for triangular 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| triangular-0.2.1.tar.gz | 7.7 MB | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| triangular-0.2.1-cp312-abi3-win_amd64.whl | CPython 3.12 | abi3 | Windows x86-64 | Details |
| triangular-0.2.1-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | CPython 3.12 | abi3 | Linux glibc 2.17+ x86-64 | Details |
| triangular-0.2.1-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl | CPython 3.12 | abi3 | Linux glibc 2.17+ ARM64 | Details |
| triangular-0.2.1-cp312-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl | CPython 3.12 | abi3 | macOS 10.12+ universal2 (ARM64, x86-64), macOS 10.12+ x86-64, macOS 11.0+ ARM64 | Details |
Total release size: 9.3 MB
Release files / triangular-0.2.1.tar.gz
| Download URL | triangular-0.2.1.tar.gz |
|---|---|
| Size | 7.7 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1f7a0ea56a106dd955c08c4259f32c627514f4671fc853ff6c6e59cccb356e7e
|
|
BLAKE2b-256 checksum How to use checksums |
e312fbdb03fe1822816463c8f4c28788e358a664a2b96d98b6a5f96a0cdf8dbc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 18, 2026.
Transparency logRelease files / triangular-0.2.1-cp312-abi3-win_amd64.whl
| Download URL | triangular-0.2.1-cp312-abi3-win_amd64.whl |
|---|---|
| Size | 226.9 kB |
| Tags | CPython 3.12 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
943dcea0f6c5f2f0c58d7bb2ce43613710970c2e690b98544b253b424932c475
|
|
BLAKE2b-256 checksum How to use checksums |
5195901377551404f2a6b5b92adf2f7655e0625e83d0ba974d2c51914dd759ca
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 18, 2026.
Transparency logRelease files / triangular-0.2.1-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | triangular-0.2.1-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 356.3 kB |
| Tags | CPython 3.12 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
1fa4c9455913a77e4f704de3d4f9837d29cb2bf5867402eb09945a0b02496f3f
|
|
BLAKE2b-256 checksum How to use checksums |
e4d75d760c1f4f0a4eccb9427a5e62367230eb8b1a0769ea24b2b173da62fa3e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 18, 2026.
Transparency logRelease files / triangular-0.2.1-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | triangular-0.2.1-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 348.6 kB |
| Tags | CPython 3.12 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
9eedfff19a36088c8d92db243b6034a1d26d36d251dc87981ca7478d7c2395e0
|
|
BLAKE2b-256 checksum How to use checksums |
13fbf5484fd736ce94cd9327ad7aad7ccf9b8a437050fbc4813585a25a576721
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 18, 2026.
Transparency logRelease files / triangular-0.2.1-cp312-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
| Download URL | triangular-0.2.1-cp312-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl |
|---|---|
| Size | 631.6 kB |
| Tags | CPython 3.12 abi3 macOS 10.12+ universal2 (ARM64, x86-64) macOS 10.12+ x86-64 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
e60eac59deadc240bc4aa08056cfb5986d89152dd3b54214070a9430c09b2851
|
|
BLAKE2b-256 checksum How to use checksums |
689c9cc77b594a0257c0bc96a75dc6898f30bb3e5d0882e5b0a405cfaa9f35fb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 18, 2026.
Transparency log