(n, distrib)
| 92 | print "py:hd_sd %.3f" % best_boost |
| 93 | |
| 94 | def compare_6d(n, distrib): |
| 95 | if distrib == 0: |
| 96 | r = np.random.rand(n) |
| 97 | else: |
| 98 | r = 0.3 * np.random.randn(n) |
| 99 | r = r.reshape(6, n/6) |
| 100 | |
| 101 | best_numpy = float("infinity") |
| 102 | best_boost = float("infinity") |
| 103 | for k in xrange(20): |
| 104 | t = timer() |
| 105 | w, xe = np.histogramdd(r.T, bins=(10, 10, 10, |
| 106 | 10, 10, 10), |
| 107 | range=((0.0, 1.0), |
| 108 | (0.0, 1.0), |
| 109 | (0.0, 1.0), |
| 110 | (0.0, 1.0), |
| 111 | (0.0, 1.0), |
| 112 | (0.0, 1.0))) |
| 113 | t = timer() - t |
| 114 | best_numpy = min(t, best_numpy) |
| 115 | |
| 116 | h = histogram(regular(10, 0, 1), |
| 117 | regular(10, 0, 1), |
| 118 | regular(10, 0, 1), |
| 119 | regular(10, 0, 1), |
| 120 | regular(10, 0, 1), |
| 121 | regular(10, 0, 1)) |
| 122 | t = timer() |
| 123 | h.fill(r[0], r[1], r[2], r[3], r[4], r[5]) |
| 124 | t = timer() - t |
| 125 | best_boost = min(t, best_boost) |
| 126 | assert(np.all(w == np.array(h)[:-2,:-2,:-2,:-2,:-2,:-2])) |
| 127 | |
| 128 | print "py:numpy %.3f" % best_numpy |
| 129 | print "py:hd_sd %.3f" % best_boost |
| 130 | |
| 131 | nfill = 6000000 |
| 132 |
no test coverage detected