(n, distrib)
| 12 | from histogram.axis import regular |
| 13 | |
| 14 | def compare_1d(n, distrib): |
| 15 | if distrib == 0: |
| 16 | r = np.random.rand(n) |
| 17 | else: |
| 18 | r = 0.5 + 0.3 * np.random.randn(n) |
| 19 | |
| 20 | best_numpy = float("infinity") |
| 21 | best_boost = float("infinity") |
| 22 | for k in xrange(20): |
| 23 | t = timer() |
| 24 | w, xe = np.histogram(r, bins=100, range=(0.0, 1.0)) |
| 25 | t = timer() - t |
| 26 | best_numpy = min(t, best_numpy) |
| 27 | |
| 28 | h = histogram(regular(100, 0, 1)) |
| 29 | t = timer() |
| 30 | h.fill(r) |
| 31 | t = timer() - t |
| 32 | best_boost = min(t, best_boost) |
| 33 | assert(np.all(w == np.array(h)[:-2])) |
| 34 | |
| 35 | print "py:numpy %.3f" % best_numpy |
| 36 | print "py:hd_sd %.3f" % best_boost |
| 37 | |
| 38 | def compare_2d(n, distrib): |
| 39 | if distrib == 0: |
no test coverage detected