def nextpow2(i):
    """
    Calculates the next even power of 2 which is greater than or equal to i.

    Parameters
    -----------
    i : integer
        The number which we want a power of 2 that is greater.

    Returns
    -------
    n : integer
        The next power of 2 such that n >= i.
    """
    n = 2
    while n < i:
        n *= 2
    return n