Skip to content

Instantly share code, notes, and snippets.

@duhaime
duhaime / example.py
Created September 25, 2018 16:27
lloyd's algorithm
import numpy as np
import umap
# generate some points in 4D
points = np.random.random((2000, 4))
# project the points to 2D to get points proximate to one another
points = umap.UMAP().fit_transform(points)
from lloyd.lloyd import Field
@Sklavit
Sklavit / colorized_voronoi_with_clipping.py
Created March 26, 2017 00:36 — forked from pv/colorized_voronoi.py
Colorized Voronoi diagram with Scipy, in 2D, including infinite regions which are clipped to given box.
# coding=utf-8
import numpy as np
import matplotlib.pyplot as plt
from scipy.spatial import Voronoi
from shapely.geometry import Polygon
def voronoi_finite_polygons_2d(vor, radius=None):
"""
Reconstruct infinite voronoi regions in a 2D diagram to finite
regions.