0
0
SciPydata~10 mins

Voronoi diagrams in SciPy - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the Voronoi class from scipy.spatial.

SciPy
from scipy.spatial import [1]

points = [[1, 2], [3, 4], [5, 6]]
vor = Voronoi(points)
Drag options to blanks, or click blank then click option'
AConvexHull
BVoronoi
CDelaunay
DKDTree
Attempts:
3 left
💡 Hint
Common Mistakes
Importing Delaunay instead of Voronoi
Using ConvexHull which is for a different geometry
Trying to import from the wrong module
2fill in blank
medium

Complete the code to create a Voronoi diagram from the points list.

SciPy
points = [[0, 0], [1, 0], [0, 1], [1, 1]]
vor = [1](points)
Drag options to blanks, or click blank then click option'
ADelaunay
BKDTree
CConvexHull
DVoronoi
Attempts:
3 left
💡 Hint
Common Mistakes
Using Delaunay instead of Voronoi
Calling a function that does not exist
Passing points to the wrong class
3fill in blank
hard

Fix the error in accessing the Voronoi vertices attribute.

SciPy
import numpy as np
from scipy.spatial import Voronoi
points = np.array([[2, 3], [5, 4], [3, 7]])
vor = Voronoi(points)
vertices = vor.[1]
Drag options to blanks, or click blank then click option'
Avertices
Bridge_points
Cpoints
Dregions
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'points' which are the input points
Using 'regions' which are indices of vertices
Using 'ridge_points' which are pairs of points
4fill in blank
hard

Fill both blanks to create a dictionary of region indices to their vertex coordinates.

SciPy
regions = {i: [vor.[1][v] for v in region] for i, region in enumerate(vor.[2]) if -1 not in region}
Drag options to blanks, or click blank then click option'
Avertices
Bregions
Cridge_vertices
Dridge_points
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up ridge_vertices and regions
Using ridge_points which are pairs of input points
Using vertices where indices are expected
5fill in blank
hard

Fill all three blanks to create a list of ridge vertex pairs for edges between points.

SciPy
ridge_list = [[vor.[1][0], vor.[1][1]] for vor.[2] in vor.[3] if -1 not in vor.[1]]
Drag options to blanks, or click blank then click option'
Aridge_vertices
Bridge_points
Cregions
Dvertices
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing ridge_vertices with regions
Using vertices instead of ridge_vertices for edges
Using regions which are not pairs