Skip to main content

DioDe uses CGAL to generate alpha shapes filtrations in a format that Dionysus understands. DioDe is not integrated into Dionysus because of licensing restrictions (Dionysus is under BSD, DioDe is under GPL because of its dependence on CGAL). It supports both ordinary and weighted alpha shapes.

Dependencies:

Get, Build, Install

The simplest way to install Diode as a Python package:

pip install --verbose diode

or from this repository directly:

pip install --verbose git+https://github.com/mrzv/diode.git

Alternatively, you can clone and build everything by hand. To get Diode, either clone its repository:

git clone https://github.com/mrzv/diode.git

or download it as a Zip archive.

To build the project:

mkdir build
cd build
cmake ..
make

To use the Python bindings, either launch Python from .../build/bindings/python or add this directory to your PYTHONPATH variable, by adding:

export PYTHONPATH=.../build/bindings/python:$PYTHONPATH

to your ~/.bashrc or ~/.zshrc.

Usage

NB: a remark below about using exact computation. This issue is especially important when working with degenerate point sets (e.g., repeated copies of a fundamental domain in a periodic point set).

See examples/generate_alpha_shape.cpp and examples/generate_weighted_alpha_shape.cpp for C++ examples.

In Python, use diode.fill_alpha_shapes(...) and diode.fill_weighted_alpha_shapes(...) to fill a list of simplices, together with their alpha values:

>>> import diode
>>> import numpy as np

>>> points = np.random.random((100,3))
>>> simplices = diode.fill_alpha_shapes(points)

>>> print(simplices)
 [([13L], 0.0),
  ([18L], 0.0),
  ([59L], 0.0),
  ([10L], 0.0),
  ([72L], 0.0),
  ...,
  ([91L, 4L, 16L, 49L], 546.991052812204),
  ([49L, 62L], 1933.2257381777533),
  ([62L, 34L, 49L], 1933.2257381777533),
  ([62L, 91L, 49L], 1933.2257381777533),
  ([62L, 91L, 34L, 49L], 1933.2257381777533)]

>>> weighted_points = np.random.random((100,4))
>>> simplices2 = diode.fill_weighted_alpha_shapes(weighted_points)
>>> print(simplices2)
[([24L], -0.987214836816236),
 ([35L], -0.968749877102265),
 ([50L], -0.9673151804059413),
 ([47L], -0.9640549893422644),
 ([71L], -0.9639978806827709),
 ([24L, 50L], -0.9540965704765515),
 ...
 ([54L, 10L], 29223.611044169364),
 ([10L, 54L, 43L], 29223.611044169364),
 ([13L, 10L, 54L], 29223.611044169364),
 ([13L, 10L, 54L, 43L], 29223.611044169364)]

The list can be passed to Dionysus to initialize a filtration:

>>> import dionysus
>>> f = dionysus.Filtration(simplices)
>>> print(f)
Filtration with 2287 simplices

DioDe also includes diode.fill_periodic_alpha_shapes(...), which generates the alpha shape for a point set on a periodic cube, by default [0,0,0] - [1,1,1]. (In the periodic case, it may happen that CGAL reports each simplex multiple times. However, passing the result to dionysus.Filtration will take care of the duplicates.):

>>> simplices_periodic = diode.fill_periodic_alpha_shapes(points)
>>> f_periodic = dionysus.Filtration(simplices_periodic)
>>> print(f_periodic)
Filtration with 2912 simplices

>>> for s in f_periodic: print(s)
<0> 0
<1> 0
<2> 0
<3> 0
...
<77,94,97> 0.0704355
<46,77,94,97> 0.0708062
<30,77,94,97> 0.0708474
<18,65,79> 0.0715833
<18,64,65,79> 0.0715833
<18,65,79,99> 0.0725366

When using CGAL version at least 4.11, DioDe includes diode.fill_weighted_periodic_alpha_shapes(...), which generates the alpha shape for a weighted point set on a periodic cube:

>>> weighted_points[:,3] /= 64
>>> simplices_weighted_periodic = diode.fill_weighted_periodic_alpha_shapes(weighted_points)

diode.circumcenter(...) can be used to compute the circumcenter of a tetrahedron in 3D:

>>> tet = np.random.random((4,3))
>>> center = diode.circumcenter(tet)
>>> print(center)
[-0.00752673  0.14213101  1.0060982 ]

Delaunay combinatorics (no alpha values)

Some consumers only need the simplicial complex (the Delaunay triangulation, which for full-dimensional input is the same simplex set as the alpha complex) and recompute their own filtration values – for example a differentiable Cech-Delaunay filtration that recomputes values as minimum-enclosing-ball radii. For those, diode.fill_delaunay_arrays(...) returns just the combinatorics, skipping all of CGAL’s per-simplex Gabriel/circumradius work (about 1.6x faster than the alpha path in 2D and 4x in 3D):

>>> verts_by_dim = diode.fill_delaunay_arrays(points)

The result is a list of per-dimension NumPy arrays, where verts_by_dim[d] is an (n_d, d+1) int64 array of vertex ids (dimension 0 = vertices, 1 = edges, and so on). diode.fill_delaunay(...) is the equivalent list-of-tuples form. diode.fill_periodic_delaunay_arrays(...) / diode.fill_periodic_delaunay(...) are the periodic counterparts (over the cube [from, to], default the unit cube). All four take the same exact argument as the alpha-shape functions.

Consumers that need periodic geometry as well as combinatorics can use diode.fill_periodic_delaunay_lifts_arrays(...):

>>> vertices, offsets = diode.fill_periodic_delaunay_lifts_arrays(
...     points, bbox_min=[0, 0, 0], bbox_max=[1, 1, 1])

offsets[d] is aligned with vertices[d] and has shape (n_d, d+1, ambient_dim). A lifted coordinate is points[vertices[d]] + offsets[d] * (bbox_max - bbox_min). Vertex ids are sorted within each simplex and the integer offsets are normalized by a common lattice translation so that the first offset is zero. Points must be inside the half-open domain [bbox_min, bbox_max). The exporter converts CGAL’s periodic triangulation to a one-sheet covering and raises rather than silently merging a repeated vertex-id tuple.

Exactness

All functions take an argument exact, set to False by default. The argument determines a choice of the kernel in CGAL (Exact_predicates_inexact_constructions_kernel vs Exact_predicates_exact_constructions_kernel). exact = True guarantees correctness of the output; exact = False is faster, but can sometimes fail (not even produce a simplicial complex). It’s possible to run the two versions adaptively by running the default exact = False version first, and if the result is not a simplicial complex, then run exact = True. This should be the best of both worlds.

Metadata

Release files for diode 1.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 diode 1.2.2
File Size Uploaded
diode-1.2.2.tar.gz 91.6 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for diode 1.2.2
File
diode-1.2.2-cp314-cp314-manylinux_2_39_x86_64.whl CPython 3.14 CPython 3.14 Linux glibc 2.39+ x86-64 Details
diode-1.2.2-cp314-cp314-macosx_15_0_arm64.whl CPython 3.14 CPython 3.14 macOS 15.0+ ARM64 Details
diode-1.2.2-cp313-cp313-manylinux_2_39_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.39+ x86-64 Details
diode-1.2.2-cp313-cp313-macosx_15_0_arm64.whl CPython 3.13 CPython 3.13 macOS 15.0+ ARM64 Details
diode-1.2.2-cp312-cp312-manylinux_2_39_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.39+ x86-64 Details
diode-1.2.2-cp312-cp312-macosx_15_0_arm64.whl CPython 3.12 CPython 3.12 macOS 15.0+ ARM64 Details
diode-1.2.2-cp311-cp311-manylinux_2_39_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.39+ x86-64 Details
diode-1.2.2-cp311-cp311-macosx_15_0_arm64.whl CPython 3.11 CPython 3.11 macOS 15.0+ ARM64 Details
diode-1.2.2-cp310-cp310-manylinux_2_39_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.39+ x86-64 Details
diode-1.2.2-cp310-cp310-macosx_15_0_arm64.whl CPython 3.10 CPython 3.10 macOS 15.0+ ARM64 Details
diode-1.2.2-cp39-cp39-manylinux_2_39_x86_64.whl CPython 3.9 CPython 3.9 Linux glibc 2.39+ x86-64 Details
diode-1.2.2-cp39-cp39-macosx_15_0_arm64.whl CPython 3.9 CPython 3.9 macOS 15.0+ ARM64 Details

Total release size: 29.0 MB

Release files / diode-1.2.2.tar.gz

Download URL diode-1.2.2.tar.gz
Size 91.6 kB
Tags Source
SHA-256 checksum
How to use checksums
a87bf38e625e9d363ec7591cfa27cf894418b1a9e26f74c4239690ff03bd0b4f
BLAKE2b-256 checksum
How to use checksums
39dec52dfa468ecd5e3dd4aa9bbec28287784a8aa58e3915b55a61ab646b6f71
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.0

Release files / diode-1.2.2-cp314-cp314-manylinux_2_39_x86_64.whl

Download URL diode-1.2.2-cp314-cp314-manylinux_2_39_x86_64.whl
Size 2.7 MB
Tags CPython 3.14 Linux glibc 2.39+ x86-64
SHA-256 checksum
How to use checksums
5c5fcb043e5372a59dcef464c988ab57d2f3ad8633b5b42eea12816808252a0e
BLAKE2b-256 checksum
How to use checksums
61d35782e36b8229d1349cbb85715746a2e2cf789446f7770a2cbdfad1000d7f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.0

Release files / diode-1.2.2-cp314-cp314-macosx_15_0_arm64.whl

Download URL diode-1.2.2-cp314-cp314-macosx_15_0_arm64.whl
Size 2.1 MB
Tags CPython 3.14 macOS 15.0+ ARM64
SHA-256 checksum
How to use checksums
6d4b3de488c90099c303e29982da5197fa28af42c0bd32b30a5292758d4b11e6
BLAKE2b-256 checksum
How to use checksums
a108945585bcea71523c8edffa30568be6d0ea86963d3cf894ed80fdc4709fd2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.0

Release files / diode-1.2.2-cp313-cp313-manylinux_2_39_x86_64.whl

Download URL diode-1.2.2-cp313-cp313-manylinux_2_39_x86_64.whl
Size 2.7 MB
Tags CPython 3.13 Linux glibc 2.39+ x86-64
SHA-256 checksum
How to use checksums
38700d369841b831dd2957e659efc28249e88b57c50d6eef34a55c7f1a033287
BLAKE2b-256 checksum
How to use checksums
a97909f553d756a259493f4ba741394b20230af71cbb22ec44b0be3ce3a39b37
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.0

Release files / diode-1.2.2-cp313-cp313-macosx_15_0_arm64.whl

Download URL diode-1.2.2-cp313-cp313-macosx_15_0_arm64.whl
Size 2.1 MB
Tags CPython 3.13 macOS 15.0+ ARM64
SHA-256 checksum
How to use checksums
83267d57a9dcfb1f3413c4383b1817085e4c81fa2e45a3ecd306239d6033a739
BLAKE2b-256 checksum
How to use checksums
781470f842094eabd4c86cf61ead7b395cdb7c5fa6e5ed8559fc13addd6f81b2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.0

Release files / diode-1.2.2-cp312-cp312-manylinux_2_39_x86_64.whl

Download URL diode-1.2.2-cp312-cp312-manylinux_2_39_x86_64.whl
Size 2.7 MB
Tags CPython 3.12 Linux glibc 2.39+ x86-64
SHA-256 checksum
How to use checksums
b16b17511a6f0914b76adf938e0967e630d369e1a74705a95a94f3ae976c4930
BLAKE2b-256 checksum
How to use checksums
a52b726d776adcd84f2c708b35609093e54aee29c91f0564bc4b79aaab7d5551
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.0

Release files / diode-1.2.2-cp312-cp312-macosx_15_0_arm64.whl

Download URL diode-1.2.2-cp312-cp312-macosx_15_0_arm64.whl
Size 2.1 MB
Tags CPython 3.12 macOS 15.0+ ARM64
SHA-256 checksum
How to use checksums
8110febd4901a5d561390d6b2320dc26a08cb3f286d5c415dda79b9c185a70ab
BLAKE2b-256 checksum
How to use checksums
d4c4d47e1da88a58005b876c5e92364254036d0e34552f3bb1ad8a32464e64ac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.0

Release files / diode-1.2.2-cp311-cp311-manylinux_2_39_x86_64.whl

Download URL diode-1.2.2-cp311-cp311-manylinux_2_39_x86_64.whl
Size 2.7 MB
Tags CPython 3.11 Linux glibc 2.39+ x86-64
SHA-256 checksum
How to use checksums
bbe54c37bedbabf615d86a5d7bbba88737635ec4be77f35fab4f1e2f94bca277
BLAKE2b-256 checksum
How to use checksums
b48ecc933f00bff83628bcc06049c35291171670d5ab950debee4cfb7a4176b4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.0

Release files / diode-1.2.2-cp311-cp311-macosx_15_0_arm64.whl

Download URL diode-1.2.2-cp311-cp311-macosx_15_0_arm64.whl
Size 2.1 MB
Tags CPython 3.11 macOS 15.0+ ARM64
SHA-256 checksum
How to use checksums
12b2c80ba514a0c05face4a1d2ac008da3ee60e0b9a0dac0c29c63b3dc563ffc
BLAKE2b-256 checksum
How to use checksums
014ad12beec4272f7e2d5bc7876b5ba598005590bfbebf7b766359261b3db094
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.0

Release files / diode-1.2.2-cp310-cp310-manylinux_2_39_x86_64.whl

Download URL diode-1.2.2-cp310-cp310-manylinux_2_39_x86_64.whl
Size 2.7 MB
Tags CPython 3.10 Linux glibc 2.39+ x86-64
SHA-256 checksum
How to use checksums
fbe6eb58d2ecc0cbb6c9e8e2793714836fad69527d3e4b606a9b20b81d9c0e1f
BLAKE2b-256 checksum
How to use checksums
6be154e6a06c04337374c285f857575aec2e467234fd65e34bb9c8c51b45cd70
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.0

Release files / diode-1.2.2-cp310-cp310-macosx_15_0_arm64.whl

Download URL diode-1.2.2-cp310-cp310-macosx_15_0_arm64.whl
Size 2.1 MB
Tags CPython 3.10 macOS 15.0+ ARM64
SHA-256 checksum
How to use checksums
05ac4cd377d2ad7696fcaed04113b6b7d1fd5cb0976ec091deeaef31855271d6
BLAKE2b-256 checksum
How to use checksums
d5e9e4091ce91ef850bd7ea13e0f9abefa59d16df7ea6719d611cdb43efc6148
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.0

Release files / diode-1.2.2-cp39-cp39-manylinux_2_39_x86_64.whl

Download URL diode-1.2.2-cp39-cp39-manylinux_2_39_x86_64.whl
Size 2.7 MB
Tags CPython 3.9 Linux glibc 2.39+ x86-64
SHA-256 checksum
How to use checksums
6d04a3b0a96ee4628002cd9a13c6739c6f867810570e19faefaf777e1c22b2bd
BLAKE2b-256 checksum
How to use checksums
24cbcdc62001b3d262a7bf0329fa85007ce00bdd693123e2dab7502b105190f9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.0

Release files / diode-1.2.2-cp39-cp39-macosx_15_0_arm64.whl

Download URL diode-1.2.2-cp39-cp39-macosx_15_0_arm64.whl
Size 2.1 MB
Tags CPython 3.9 macOS 15.0+ ARM64
SHA-256 checksum
How to use checksums
d9ac2e0ef77c6420359091c262c9a11a4af1ab24b52efabddbeb677247a0f099
BLAKE2b-256 checksum
How to use checksums
e1e06a63fa8c405b196ab69d7ff5545ce106c65ee2f1de0c699e226b31818207
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.0

Release history Release notifications | RSS feed

This release

1.2.2 This release

13 release files

1.2.1

19 release files

1.1.4

13 release files

1.1.3

13 release files

1.1.2

8 release files

1.1.1

7 release files

1.0.3

7 release files

1.0.2

4 release files

1.0.1

2 release files

1.0

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