コード例 #1
0
def test_check_param_in_list():
    tools.check_param_in_list(1, [0, 1, 5], "test")
    try:
        tools.check_param_in_list(10, [0, 1, 5])
        assert False
    except:
        assert True
    try:
        tools.check_param_in_list(10, [0, 1, 5], 'testt')
        assert False
    except:
        assert True
コード例 #2
0
ファイル: test_tools.py プロジェクト: cokelaer/easydev
def test_check_param_in_list():
    tools.check_param_in_list(1, [0,1,5], "test")
    try:
        tools.check_param_in_list(10, [0,1,5])
        assert False
    except:
        assert True
    try:
        tools.check_param_in_list(10, [0,1,5], 'testt')
        assert False
    except:
        assert True
コード例 #3
0
 def _set_name(self, name):
     check_param_in_list(name, self.color_names)
     name = self.aliases[name]
     self._name = name
     # set hex and rgb at the same time based on the name
     self.hex = self.colors[name]
コード例 #4
0
def _normalise(r, g, b, mode="rgb"):
    check_param_in_list(mode, ["rgb", "hls", "hsv"])
    if mode == "rgb":
        return r / 255., g / 255., b / 255.
    elif mode in ["hls", "hsv"]:
        return r / 360., g / 100., b / 100.
コード例 #5
0
def _denormalise(r, g, b, mode="rgb"):
    check_param_in_list(mode, ["rgb", "hls", "hsv"])
    if mode == "rgb":
        return r * 255., g * 255., b * 255.
    elif mode in ["hls", "hsv"]:
        return r * 360., g * 100., b * 100.
コード例 #6
0
ファイル: colors.py プロジェクト: cokelaer/colormap
 def _set_name(self, name):
     check_param_in_list(name, self.color_names)
     name = self.aliases[name]
     self._name = name
     # set hex and rgb at the same time based on the name
     self.hex = self.colors[name]
コード例 #7
0
ファイル: colors.py プロジェクト: cokelaer/colormap
def _normalise(r, g, b, mode="rgb"):
    check_param_in_list(mode, ["rgb", "hls", "hsv"])
    if mode == "rgb":
        return r/255., g/255., b/255.
    elif mode in ["hls", "hsv"]:
        return r/360., g/100., b/100.
コード例 #8
0
ファイル: colors.py プロジェクト: cokelaer/colormap
def _denormalise(r, g, b, mode="rgb"):
    check_param_in_list(mode, ["rgb", "hls", "hsv"])
    if mode == "rgb":
        return r*255., g*255., b*255.
    elif mode in ["hls", "hsv"]:
        return r*360., g*100., b*100.