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
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
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]
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.
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.
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]
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.
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.