Fast 2D Delaunay triangulation (Python port of mapbox/delaunator v5.x)
Project description
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)
- Publish
pyrobust-predicatesfirst (runtime dependency of this package). - 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).
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 Distribution
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 dylaunator-0.1.0.tar.gz.
File metadata
- Download URL: dylaunator-0.1.0.tar.gz
- Upload date:
- Size: 7.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
29452379de8405ba9dee8cf725217632982623846fc12de3bedbe402b757fa80
|
|
| MD5 |
91ab9129df5ab63f0b561a29b2a1daa1
|
|
| BLAKE2b-256 |
108b5b8d169ffb725d7a274a37cc3937393120e5e400b7f558c55afc016abacb
|
File details
Details for the file dylaunator-0.1.0-py3-none-any.whl.
File metadata
- Download URL: dylaunator-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
df87e87816da71c2f4ae4b50213ac7a7828fba07ee103da2cce593d962079585
|
|
| MD5 |
1727f417c31eef7b23293fd5addf9b16
|
|
| BLAKE2b-256 |
37ead147c228d73ae1e2d57aa6d4ca1e90e08a1911fe65ad0ec0d53eb0055572
|