Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

triangular-0.2.1.tar.gz (7.7 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

triangular-0.2.1-cp312-abi3-win_amd64.whl (226.9 kB view details)

Uploaded CPython 3.12+Windows x86-64

triangular-0.2.1-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (356.3 kB view details)

Uploaded CPython 3.12+manylinux: glibc 2.17+ x86-64

triangular-0.2.1-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (348.6 kB view details)

Uploaded CPython 3.12+manylinux: glibc 2.17+ ARM64

triangular-0.2.1-cp312-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (631.6 kB view details)

Uploaded CPython 3.12+macOS 10.12+ universal2 (ARM64, x86-64)macOS 10.12+ x86-64macOS 11.0+ ARM64

File details

Details for the file triangular-0.2.1.tar.gz.

File metadata

  • Download URL: triangular-0.2.1.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

Hashes for triangular-0.2.1.tar.gz
Algorithm Hash digest
SHA256 1f7a0ea56a106dd955c08c4259f32c627514f4671fc853ff6c6e59cccb356e7e
MD5 be184fb2855780be15e18092b0ee7c8f
BLAKE2b-256 e312fbdb03fe1822816463c8f4c28788e358a664a2b96d98b6a5f96a0cdf8dbc

See more details on using hashes here.

Provenance

The following attestation bundles were made for triangular-0.2.1.tar.gz:

Publisher: release.yml on earth-mover/triangular

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file triangular-0.2.1-cp312-abi3-win_amd64.whl.

File metadata

  • Download URL: triangular-0.2.1-cp312-abi3-win_amd64.whl
  • Upload date:
  • Size: 226.9 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

Hashes for triangular-0.2.1-cp312-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 943dcea0f6c5f2f0c58d7bb2ce43613710970c2e690b98544b253b424932c475
MD5 09824622a55a283cc49452716a5107d1
BLAKE2b-256 5195901377551404f2a6b5b92adf2f7655e0625e83d0ba974d2c51914dd759ca

See more details on using hashes here.

Provenance

The following attestation bundles were made for triangular-0.2.1-cp312-abi3-win_amd64.whl:

Publisher: release.yml on earth-mover/triangular

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file triangular-0.2.1-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for triangular-0.2.1-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1fa4c9455913a77e4f704de3d4f9837d29cb2bf5867402eb09945a0b02496f3f
MD5 2a7817fc2499278ad19d0d83d9855f34
BLAKE2b-256 e4d75d760c1f4f0a4eccb9427a5e62367230eb8b1a0769ea24b2b173da62fa3e

See more details on using hashes here.

Provenance

The following attestation bundles were made for triangular-0.2.1-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on earth-mover/triangular

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file triangular-0.2.1-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for triangular-0.2.1-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 9eedfff19a36088c8d92db243b6034a1d26d36d251dc87981ca7478d7c2395e0
MD5 e784bcb73d9b252b4a51176c0efc3d23
BLAKE2b-256 13fbf5484fd736ce94cd9327ad7aad7ccf9b8a437050fbc4813585a25a576721

See more details on using hashes here.

Provenance

The following attestation bundles were made for triangular-0.2.1-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on earth-mover/triangular

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file triangular-0.2.1-cp312-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl.

File metadata

File hashes

Hashes for triangular-0.2.1-cp312-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 e60eac59deadc240bc4aa08056cfb5986d89152dd3b54214070a9430c09b2851
MD5 d253728872f9166bb9600db16b6c121c
BLAKE2b-256 689c9cc77b594a0257c0bc96a75dc6898f30bb3e5d0882e5b0a405cfaa9f35fb

See more details on using hashes here.

Provenance

The following attestation bundles were made for triangular-0.2.1-cp312-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl:

Publisher: release.yml on earth-mover/triangular

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page