Пример #1
0
 def test_lin_interpolate(self):
     xs = [-1.5]
     curve = [(-2, -100), (2, 100)]
     self.assertEquals(
         interpolate.lin_interpolate(xs, curve),
         [(-1.5, -75.0)]
     )
Пример #2
0
def get_mapped_color(normalized_value, colormap, clip=True, cast=None):
    color_attrs = colormap.keys()
    mapped_color = {}
    for attr in color_attrs:
        mapped_color[attr] = interpolate.lin_interpolate(
            [normalized_value], colormap[attr], clip=clip)[0][1]
        if cast:
            mapped_color[attr] = cast(mapped_color[attr])
    return mapped_color