import colorsys
import numpy as np
import matplotlib as mpl

import nose.tools as nt
import numpy.testing as npt

from .. import palettes, utils, rcmod, husl
from ..xkcd_rgb import xkcd_rgb
from ..crayons import crayons


class TestColorPalettes(object):

    def test_current_palette(self):

        pal = palettes.color_palette(["red", "blue", "green"], 3)
        rcmod.set_palette(pal, 3)
        nt.assert_equal(pal, mpl.rcParams["axes.color_cycle"])
        rcmod.set()

    def test_palette_context(self):

        default_pal = palettes.color_palette()
        context_pal = palettes.color_palette("muted")

        with palettes.color_palette(context_pal):
            nt.assert_equal(mpl.rcParams["axes.color_cycle"], context_pal)

        nt.assert_equal(mpl.rcParams["axes.color_cycle"], default_pal)

    def test_big_palette_context(self):

        default_pal = palettes.color_palette()