Skip to main content

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.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for triangular 0.2.2
File Size Uploaded Provenance Actions
triangular-0.2.2.tar.gz 7.7 MB With provenance Details for triangular-0.2.2.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for triangular 0.2.2
File Actions
triangular-0.2.2-cp312-abi3-win_amd64.whl CPython 3.12 abi3 Windows x86-64 Details for triangular-0.2.2-cp312-abi3-win_amd64.whl
triangular-0.2.2-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.12 abi3 Linux glibc 2.17+ x86-64 Details for triangular-0.2.2-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
triangular-0.2.2-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.12 abi3 Linux glibc 2.17+ ARM64 Details for triangular-0.2.2-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
triangular-0.2.2-cp312-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl CPython 3.12 abi3 macOS 11.0+ ARM64, macOS 10.12+ universal2 (ARM64, x86-64), macOS 10.12+ x86-64 Details for triangular-0.2.2-cp312-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl

Total release size: 9.3 MB

Release files / triangular-0.2.2.tar.gz

Download URL triangular-0.2.2.tar.gz
Size 7.7 MB
Tags Source
SHA-256 checksum
How to use checksums
9282cd9e2c38961914592c4ec133112b2055e8433fd33039113ca0295ae45281
BLAKE2b-256 checksum
How to use checksums
509683ba53df2eb623930993d31fbb25a185c4197221d2a6cd99444ebb8744a8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Oct 21, 2026.

Transparency log

Release files / triangular-0.2.2-cp312-abi3-win_amd64.whl

Download URL triangular-0.2.2-cp312-abi3-win_amd64.whl
Size 228.5 kB
Tags CPython 3.12 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
cccc01c2e2b1b51b3924ac470c2dd8caf4f2622cd2c9ef8c58427f7feea75663
BLAKE2b-256 checksum
How to use checksums
7a0e27bf2231633c489889909bcb5756c2476045aeb323e4f3285575cad21239
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Oct 21, 2026.

Transparency log

Release files / triangular-0.2.2-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL triangular-0.2.2-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 349.9 kB
Tags CPython 3.12 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
61540680ff53032efe86936aa25f88c479f74662ab20f31ba9109da40c9082d2
BLAKE2b-256 checksum
How to use checksums
a5188f44a43efbd3fbd495f9c3a53ee052f914029e317ff6227bcd49ca6cddb9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Oct 21, 2026.

Transparency log

Release files / triangular-0.2.2-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL triangular-0.2.2-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 344.8 kB
Tags CPython 3.12 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
c6d756de63c42ca473e8df5b65386b52e0e0c986b750e2578c6530b93053b3e2
BLAKE2b-256 checksum
How to use checksums
4f30d8cb15cdfde65ea7a33f8492fc20544802cc6a631bb2a5b369430633c628
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Oct 21, 2026.

Transparency log

Release files / triangular-0.2.2-cp312-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl

Download URL triangular-0.2.2-cp312-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Size 625.8 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
d138962546431a1f96b01c907442ba5287f42199505ac9054a535aadae0dc850
BLAKE2b-256 checksum
How to use checksums
42fbcd9c940d0f978fa688a76652b44540537f0f15be7e0dd428cc66c47ac7e5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Oct 21, 2026.

Transparency log

Security for triangular 0.2.2

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.

Full provenance

All 5 files in this release have been uploaded with provenance metadata.

Select from 5 files

Attestation for triangular-0.2.2.tar.gz

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 Oct 21, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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