Menu

[r7978]: / branches / mathtex / unit / inside_poly_profile.py  Maximize  Restore  History

Download this file

31 lines (23 with data), 768 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
"""
Broken.
"""
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
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.