Ejemplo n.º 1
0
def test_desaturate_pal():
    x = [0, .25, .5, .75, 1]
    # When desaturating pure red, green and blue
    # the other 2 colors get matching values,
    # we test that.
    result = desaturate_pal('red', .1)(x)
    assert all(s[3:5] == s[5:] for s in result)

    result = desaturate_pal('green', .2)(x)
    assert all(s[1:3] == s[-2:] for s in result)

    result = desaturate_pal('blue', .3)(x)
    assert all(s[1:3] == s[3:5] for s in result)

    result = desaturate_pal('blue', .3, reverse=True)(x)
    assert all(s[1:3] == s[3:5] for s in result)

    with pytest.raises(ValueError):
        desaturate_pal('green', 2.3)
Ejemplo n.º 2
0
def test_desaturate_pal():
    x = [0, .25, .5, .75, 1]
    # When desaturating pure red, green and blue
    # the other 2 colors get matching values,
    # we test that.
    result = desaturate_pal('red', .1)(x)
    assert all(s[3:5] == s[5:] for s in result)

    result = desaturate_pal('green', .2)(x)
    assert all(s[1:3] == s[-2:] for s in result)

    result = desaturate_pal('blue', .3)(x)
    assert all(s[1:3] == s[3:5] for s in result)

    result = desaturate_pal('blue', .3, reverse=True)(x)
    assert all(s[1:3] == s[3:5] for s in result)

    with pytest.raises(ValueError):
        desaturate_pal('green', 2.3)
Ejemplo n.º 3
0
 def __init__(self, color='red', prop=0, reverse=False,
              **kwargs):
     self.palette = desaturate_pal(color, prop, reverse)
     scale_continuous.__init__(self, **kwargs)
Ejemplo n.º 4
0
 def __init__(self, color='red', prop=0, reverse=False,
              **kwargs):
     self.palette = desaturate_pal(color, prop, reverse)
     scale_continuous.__init__(self, **kwargs)