def test_cmap_d_pal(): palette = cmap_d_pal('viridis') result = palette(6) assert all(s[0] == '#' and len(s) == 7 for s in result) assert len(result) == 6 # More colors than palette palette = cmap_d_pal('Accent') result = palette(5) assert all(s[0] == '#' and len(s) == 7 for s in result) with pytest.raises(ValueError): result = palette(10) # Bad palette with pytest.raises(ValueError): palette = cmap_d_pal('Greens')
def __init__(self, name='viridis', lut=None, **kwargs): self.palette = cmap_d_pal(name, lut) super(scale_color_cmap_d, self).__init__(**kwargs)