def collect_blocks(d_blocks, ayear, n):
    """
    Collect a block of patents for a window of n years regarding a focus
    year.
    If n is possitive the patents are from the future.
    If n is possitive the patents are from the past.


    Parameters
    ----------
    d_blocks : A dictionary of patent blocks, the key is the year, and the
              value is a list of indexes of the patents belongin to that year.
    ayear: The focus year
    n: The window size

    Returns
    -------
    block : A list with all the patents in the window of n years (past or
            or future)

    """
    inc = int(n/abs(n))
    ayears = list(range(ayear+inc, ayear+n+inc, inc))
    block = []
    for i in ayears:
        if i in d_blocks:
            block.extend(d_blocks[i])
    return block