def _value_lookup_table(values, size):

    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
Generate a lookup table for finding the closest item in values.
dataset/ETHPy150Open AnyMesh/anyMesh-Python/example/urwid/display_common.py/_value_lookup_table