(n, distrib)
| 36 | print "py:hd_sd %.3f" % best_boost |
| 37 | |
| 38 | def compare_2d(n, distrib): |
| 39 | if distrib == 0: |
| 40 | r = np.random.rand(n) |
| 41 | else: |
| 42 | r = 0.5 + 0.3 * np.random.randn(n) |
| 43 | r = r.reshape(2, n/2) |
| 44 | |
| 45 | best_numpy = float("infinity") |
| 46 | best_boost = float("infinity") |
| 47 | for k in xrange(20): |
| 48 | t = timer() |
| 49 | w, xe, ye = np.histogram2d(r[0], r[1], bins=(100, 100), |
| 50 | range=((0.0, 1.0), (0.0, 1.0))) |
| 51 | t = timer() - t |
| 52 | best_numpy = min(t, best_numpy) |
| 53 | |
| 54 | h = histogram(regular(100, 0, 1), regular(100, 0, 1)) |
| 55 | t = timer() |
| 56 | h.fill(r[0], r[1]) |
| 57 | t = timer() - t |
| 58 | best_boost = min(t, best_boost) |
| 59 | assert(np.all(w == np.array(h)[:-2,:-2])) |
| 60 | |
| 61 | print "py:numpy %.3f" % best_numpy |
| 62 | print "py:hd_sd %.3f" % best_boost |
| 63 | |
| 64 | def compare_3d(n, distrib): |
| 65 | if distrib == 0: |
no test coverage detected