def test_domain_range_scale_RGB_to_HEX(self): """ Tests :func:`colour.notation.triplet.RGB_to_HEX` definition domain and range scale support. """ RGB = np.array([0.45620519, 0.03081071, 0.04091952]) HEX = RGB_to_HEX(RGB) d_r = (('reference', 1), (1, 1), (100, 100)) for scale, factor in d_r: with domain_range_scale(scale): self.assertEqual(RGB_to_HEX(RGB * factor), HEX)
def test_RGB_to_HEX(self): """ Tests :func:`colour.notation.triplet.RGB_to_HEX` definition. """ self.assertEqual( RGB_to_HEX(np.array([0.45620519, 0.03081071, 0.04091952])), '#74070a') self.assertEqual( RGB_to_HEX(np.array([0.00000000, 0.00000000, 0.00000000])), '#000000') self.assertEqual( RGB_to_HEX(np.array([1.00000000, 1.00000000, 1.00000000])), '#ffffff')
def test_RGB_to_HEX(self): """ Tests :func:`colour.notation.triplet.RGB_to_HEX` definition. """ self.assertEqual( RGB_to_HEX(np.array([0.25000000, 0.60000000, 0.05000000])), '#3f990c') self.assertEqual( RGB_to_HEX(np.array([0.00000000, 0.00000000, 0.00000000])), '#000000') self.assertEqual( RGB_to_HEX(np.array([1.00000000, 1.00000000, 1.00000000])), '#ffffff')
def test_n_dimensional_RGB_to_HEX(self): """ Tests :func:`colour.notation.triplet.RGB_to_HEX` definition n-dimensional arrays support. """ RGB = np.array([0.45620519, 0.03081071, 0.04091952]) HEX = '#74070a' self.assertEqual(RGB_to_HEX(RGB), HEX) RGB = np.tile(RGB, (6, 1)) HEX = np.tile(HEX, 6) self.assertListEqual(RGB_to_HEX(RGB).tolist(), HEX.tolist()) RGB = np.reshape(RGB, (2, 3, 3)) HEX = np.reshape(HEX, (2, 3)) self.assertListEqual(RGB_to_HEX(RGB).tolist(), HEX.tolist())
def test_n_dimensional_RGB_to_HEX(self): """ Tests :func:`colour.notation.triplet.RGB_to_HEX` definition n-dimensional arrays support. """ RGB = np.array([0.25000000, 0.60000000, 0.05000000]) HEX = '#3f990c' self.assertEqual(RGB_to_HEX(RGB), HEX) RGB = np.tile(RGB, (6, 1)) HEX = np.tile(HEX, 6) self.assertListEqual(RGB_to_HEX(RGB).tolist(), HEX.tolist()) RGB = np.reshape(RGB, (2, 3, 3)) HEX = np.reshape(HEX, (2, 3)) self.assertListEqual(RGB_to_HEX(RGB).tolist(), HEX.tolist())
def test_nan_RGB_to_HEX(self): """ Tests :func:`colour.notation.triplet.RGB_to_HEX` definition nan support. """ cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] cases = set(permutations(cases * 3, r=3)) for case in cases: RGB = np.array(case) RGB_to_HEX(RGB)