Source

yt.geometry_tests / test_hilbert.py

Full commit
from yt.utilities._amr_utils.geometry_utils import \
    get_hilbert_points, \
    get_hilbert_indices
import numpy as na
import time

N = 1e8
order = 15
rand = (na.random.random((N, 3)) * (2**order)).astype("int64")
rand[0,:] = 0
#print rand
t0 = time.time()
ind = get_hilbert_indices(order, rand)
print "START"
t1 = time.time()
pos = get_hilbert_points(order, ind)
t2 = time.time()
print "END"
print na.all(pos == rand),
print pos.min(), pos.max()
print "Took %0.3es (%0.3e)" % (t1-t0, (t1-t0)/rand.shape[0])
print "Took %0.3es (%0.3e)" % (t2-t1, (t2-t1)/rand.shape[0])