def normalizeValuesByWindows(data, window_size=None):
    """normalize to constant window size.

    If no window size is given, the smallest window is used. Windows
    smaller than windows-size are ignored.
    """

    if not options.window_size:
        window_size = min(map(lambda x: x[1] - x[0], data))

    new_values = []

    for start, end, value in data:
        if start - end < window_size:
            continue
        start = start - start % window_size
        for z in range(start, end, window_size):
            new_values.append((z, value))

    new_values.sort()

    # interpolate values for the same windows with average
    xvals = []
    yvals = []
    last_x = None
    values = []
    for x, value in new_values:

        if last_x != x:
            if last_x is not None:
                xvals.append(last_x)
                yvals.append(numpy.mean(values))
            values = []

        last_x = x
        values.append(value)

    return xvals, yvals

#-------------------------------------------------------------------
#-------------------------------------------------------------------
#-------------------------------------------------------------------
dataset/ETHPy150Open CGATOxford/cgat/scripts/gff2plot.py/normalizeValuesByWindows/swapped operands of `-`