pyd3js-delaunay
Python port of d3-delaunay for Delaunay triangulation and Voronoi diagrams, aligned with the other pyd3js packages.
Tracked upstream: d3-delaunay@6.0.4 — see upstream_lock.json.
Requirements: Python 3.10+.
What is d3-delaunay?
d3-delaunay builds a Delaunay triangulation from planar points and derives a Voronoi diagram (clipped to a viewport). It is the standard geometric core D3 uses for mesh and Voronoi layouts.
This package gives you the same workflow in Python: construct a Delaunay, optionally call voronoi(bounds), and use render helpers that return SVG path strings (like upstream).
What you get
DelaunayandVoronoimatching the pinned upstream API (see compatibility matrix below).- Pure Python tests: upstream Mocha suites are ported to pytest (no Node.js /
npmgate). py.typedand type-checked public surface (see Development).
Quickstart (verified)
Flat coordinates match upstream new Delaunay(points):
from array import array
from pyd3js_delaunay import Delaunay
coords = array("d", [0, 0, 1, 0, 0, 1])
d = Delaunay(coords)
v = d.voronoi([0, 0, 1, 1])
print(list(d.hull), v.render_bounds())
[0, 2, 1] M0,0h1v1h-1Z
Point lists use Delaunay.from_points (same idea as JS Delaunay.from):
from pyd3js_delaunay import Delaunay
d = Delaunay.from_points([[0, 0], [1, 0], [0, 1]])
print(list(d.triangles))
[0, 2, 1]
If bounds is omitted, d.voronoi() uses the upstream default [0, 0, 960, 500].
Install
From PyPI:
pip install pyd3js-delaunay
This repo is a uv workspace. For local development:
uv sync --group dev
Dependencies
Triangulation topology (triangles, halfedges, hull) comes from dylaunator ==0.1.0 (Python port of mapbox/delaunator), which uses pyrobust-predicates for adaptive-precision orient2d — the same dependency chain as JavaScript (delaunator → robust-predicates).
Compatibility matrix
Symbols match upstream exports listed in docs/UPSTREAM_API.md.
Delaunay— [implemented]Voronoi— [implemented]
The Python package also exports __version__.
JavaScript naming
Methods are snake_case in Python. Voronoi additionally exposes camelCase aliases (renderCell, renderBounds, cellPolygon, cellPolygons). Internal Path / Polygon helpers use canvas-style names (moveTo, lineTo, closePath).
No Node / npm
Runtime and tests do not require Node.js, npm, or a JavaScript oracle.
Documentation
- User guide:
docs/USER_GUIDE.md - Upstream inventory & ported tests:
docs/UPSTREAM_API.md - Changelog:
docs/CHANGELOG.md - Roadmap:
docs/ROADMAP.md - Updating the upstream pin:
docs/UPSTREAM_UPDATE.md
Development
uv run pytest packages/pyd3js-delaunay/package_tests -q
uv run ruff format packages/pyd3js-delaunay
uv run ruff check packages/pyd3js-delaunay
uv run ty check packages/pyd3js-delaunay
Coverage (optional)
uv run pytest packages/pyd3js-delaunay/package_tests --cov=pyd3js_delaunay --cov-report=term-missing
Build
uv build packages/pyd3js-delaunay
README and user guide Python snippets are checked by package_tests/test_delaunay_docs_examples.py.
Releasing (PyPI)
- Ensure dylaunator 0.1.0 is published (this package pins it exactly).
- From the monorepo root:
uv build packages/pyd3js-delaunay
Upload dist/pyd3js_delaunay-*.whl and dist/pyd3js_delaunay-*.tar.gz (for example with twine upload or uv publish). Bump version in pyproject.toml and add a section here before each new release.
License
ISC — see LICENSE.
Metadata
Release files for pyd3js-delaunay 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pyd3js_delaunay-0.1.0.tar.gz | 3.8 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pyd3js_delaunay-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 3.8 MB
Release files / pyd3js_delaunay-0.1.0.tar.gz
| Download URL | pyd3js_delaunay-0.1.0.tar.gz |
|---|---|
| Size | 3.8 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b934811ce8682ca7b100d86c5a54ac9a3617ea33bf35fb81e435fb6aa8917553
|
|
BLAKE2b-256 checksum How to use checksums |
fd3ef6c5b0e77cc58f0fe615948884461246502ec8df03008776bf43c2b0fc72
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.13
|
Release files / pyd3js_delaunay-0.1.0-py3-none-any.whl
| Download URL | pyd3js_delaunay-0.1.0-py3-none-any.whl |
|---|---|
| Size | 13.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0c3926fe1e4e8f37d774392e055a2b7d73885f219cf8d90ad50ede05e5f98a15
|
|
BLAKE2b-256 checksum How to use checksums |
69c30bd9dba5b9b34af220e93c1d3dcee183f5386e8b51203ba5bb0b6270a99e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.13
|