forked from matplotlib/matplotlib
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinside_poly_profile.py
More file actions
31 lines (24 loc) · 807 Bytes
/
inside_poly_profile.py
File metadata and controls
31 lines (24 loc) · 807 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
"""
Broken.
"""
from __future__ import print_function
import os, sys, time
import matplotlib.nxutils as nxutils
from numpy.random import rand
import matplotlib.mlab
import matplotlib.patches as patches
if 1:
numtrials, numverts, numpoints = 50, 1000, 1000
verts = patches.CirclePolygon((0.5, 0.5), radius=0.5, resolution=numverts).get_verts()
t0 = time.time()
for i in range(numtrials):
points = rand(numpoints,2)
mask = matplotlib.mlab._inside_poly_deprecated(points, verts)
### no such thing
told = time.time() - t0
t0 = time.time()
for i in range(numtrials):
points = rand(numpoints,2)
mask = nxutils.points_inside_poly(points, verts)
tnew = time.time() - t0
print(numverts, numpoints, told, tnew, told/tnew)