Skip to main content

dylaunator

Python port of mapbox/delaunator (v5.0.x API): fast Delaunay triangulation of 2D points using half-edge connectivity.

Upstream pin: logic and tests are aligned with mapbox/delaunator@v5.0.1. See docs/UPSTREAM_TESTS.md for fixture provenance and how tests map to test/test.js.

Robust orientation uses pyrobust-predicates (Python port of mourner/robust-predicates), matching the JavaScript chain (delaunator → robust-predicates) used by d3-delaunay.

Requirements

  • Python 3.10+
  • Runtime dependency: pyrobust-predicates

Install

uv add dylaunator

Usage

from dylaunator import Delaunator

coords = [377, 479, 453, 434, 326, 387]
d = Delaunator(coords)
print(list(d.triangles))

Flat coordinates may be a Python array("d", ...) or any sequence of floats; use Delaunator.from_points for nested point lists or custom {x, y} objects.

JS API mapping (mapbox/delaunator v5.0.x)

The public npm API is a default-export class; Python exposes the same surface with idiomatic naming where the language requires it.

JavaScript Python
new Delaunator(coords) Delaunator(coords)
Delaunator.from(points, getX?, getY?) Delaunator.from_points(points, fx?, fy?, that?) — from is a Python keyword, so the static factory is from_points.
d.trianglesLen d.triangles_len or d.trianglesLen (same value; both supported).
d.coords, d.triangles, d.halfedges, d.hull Same attribute names (coords is array("d")).
d.update() d.update()

Also exported (not separate npm exports, but mirror helpers inside upstream index.js): flat_array, flat_iterable, default_get_x, default_get_y.

Constructor validation mirrors upstream where possible (e.g. flat coords must be numeric; array-like objects with negative length raise ValueError with message Invalid typed array length).

Testing and coverage

From the repo root (uv workspace):

uv run pytest packages/dylaunator -q
uv run pytest packages/dylaunator --cov=dylaunator --cov-report=term-missing

The suite includes a full port of upstream test/test.js plus small internal coverage tests. Package source is kept at 100% line coverage under that configuration.

Upstream test fixtures

JSON under tests/fixtures/ matches upstream test/fixtures/*.json at v5.0.1 (byte-for-byte). Details: docs/UPSTREAM_TESTS.md.

Releasing (PyPI)

  1. Publish pyrobust-predicates first (runtime dependency of this package).
  2. From this directory:
uv build
uv publish  # or upload dist/* with twine

Built artifacts land in the workspace dist/ when using uv from a package subfolder. Bump version in pyproject.toml and add a section to docs/CHANGELOG.md before each release.

License

ISC (same as upstream delaunator).

Metadata

Release files for dylaunator 0.1.0

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

Source distribution (sdist)

Source distribution for dylaunator 0.1.0
File Size Uploaded
dylaunator-0.1.0.tar.gz 7.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dylaunator 0.1.0
File Interpreter ABI Platform
dylaunator-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 15.5 kB

Release files / dylaunator-0.1.0.tar.gz

Download URL dylaunator-0.1.0.tar.gz
Size 7.7 kB
Tags Source
SHA-256 checksum
How to use checksums
29452379de8405ba9dee8cf725217632982623846fc12de3bedbe402b757fa80
BLAKE2b-256 checksum
How to use checksums
108b5b8d169ffb725d7a274a37cc3937393120e5e400b7f558c55afc016abacb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.11.14

Release files / dylaunator-0.1.0-py3-none-any.whl

Download URL dylaunator-0.1.0-py3-none-any.whl
Size 7.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
df87e87816da71c2f4ae4b50213ac7a7828fba07ee103da2cce593d962079585
BLAKE2b-256 checksum
How to use checksums
37ead147c228d73ae1e2d57aa6d4ca1e90e08a1911fe65ad0ec0d53eb0055572
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.11.14

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

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