MCPcopy Create free account
hub / github.com/boostorg/histogram / compare_3d

Function compare_3d

test/speed_numpy.py:64–92  ·  view source on GitHub ↗
(n, distrib)

Source from the content-addressed store, hash-verified

62 print "py:hd_sd %.3f" % best_boost
63
64def compare_3d(n, distrib):
65 if distrib == 0:
66 r = np.random.rand(n)
67 else:
68 r = 0.3 * np.random.randn(n)
69 r = r.reshape(3, n/3)
70
71 best_numpy = float("infinity")
72 best_boost = float("infinity")
73 for k in xrange(20):
74 t = timer()
75 w, xe = np.histogramdd(r.T, bins=(100, 100, 100),
76 range=((0.0, 1.0),
77 (0.0, 1.0),
78 (0.0, 1.0)))
79 t = timer() - t
80 best_numpy = min(t, best_numpy)
81
82 h = histogram(regular(100, 0, 1),
83 regular(100, 0, 1),
84 regular(100, 0, 1))
85 t = timer()
86 h.fill(r[0], r[1], r[2])
87 t = timer() - t
88 best_boost = min(t, best_boost)
89 assert(np.all(w == np.array(h)[:-2,:-2,:-2]))
90
91 print "py:numpy %.3f" % best_numpy
92 print "py:hd_sd %.3f" % best_boost
93
94def compare_6d(n, distrib):
95 if distrib == 0:

Callers 1

speed_numpy.pyFile · 0.70

Calls 2

regularClass · 0.90
histogramClass · 0.50

Tested by

no test coverage detected