

def _value_lookup_table(values, size):
    '\n    Generate a lookup table for finding the closest item in values.\n    Lookup returns (index into values)+1\n    \n    values -- list of values in ascending order, all < size\n    size -- size of lookup table and maximum value\n    \n    >>> _value_lookup_table([0, 7, 9], 10)\n    [0, 0, 0, 0, 1, 1, 1, 1, 2, 2]\n    '
    middle_values = (([0] + [(((values[i] + values[(i + 1)]) + 1) // 2) for i in range((len(values) - 1))]) + [size])
    lookup_table = []
    for i in range((len(middle_values) - 1)):
        count = (middle_values[(i + 1)] - middle_values[i])
        lookup_table.extend(([i] * count))
    return lookup_table

dataset/ETHPy150Open AnyMesh/anyMesh-Python/example/urwid/display_common.py _value_lookup_table/original