def bitceil(N):
    """
    Find the bit (i.e. power of 2) immediately greater than or equal to N
    Note: this works for numbers up to 2 ** 64.

    Roughly equivalent to int(2 ** np.ceil(np.log2(N)))
    """
    # Note: for Python 2.7 and 3.x, this is faster:
    # return 1 << int(N - 1).bit_length()
    N = 1 - int(N)
    for i in [1, 2, 4, 8, 16, 32]:
        N |= N >> i
    return N + 1
dataset/ETHPy150Open astroML/gatspy/gatspy/periodic/lomb_scargle_fast.py/bitceil/swapped operands of `-`