def multires_order(n):

    if isinstance(n, list) or isinstance(n, tuple):
       return n.__class__(n[i] for i in multires_order(len(n)))
    elif 'ndarray' in str(type(n)):
       return n[multires_order(len(n))]
    assert(isinstance(n, int))

    out = []
    # to speed up checks, we will consume some memory but mark
    # each index whenever we add it to out
    seen = [False] * n
    for i in xrange(1, n):
        # fp step so we could point to the 0th, middle, last
        # on the first run
        step = float(n-1)/(2*i)
        gotnew = False
        for k in xrange(int(ceil(float(n)/step))):
            idx = int(k*step)
            if not seen[idx]: # in seen:
               out.append(idx)
               seen[idx] = True
               gotnew = True
        if not gotnew:
            #print "D: exiting from loop with i=%d n=%d" % (i, n)
            break
    if len(out) != n:
        # Fill in the holes -- some might still be missing, so
        # add them at the end
        # print "D: %d are still missing" % (n-len(out))
        out.extend([i for i in range(n) if not seen[i]])
    assert(set(out) == set(range(n)))
    return out
Moved from nova.utils
dataset/ETHPy150Open pydata/vbench/vbench/utils.py/multires_order--crossover with--dataset/ETHPy150Open BU-NU-CLOUD-SP16/Trusted-Platform-Module-nova/nova/servicegroup/drivers/db.py/DbDriver.is_up