def test_uv_to_UCS(self):
        """Test :func:`colour.models.cie_ucs.uv_to_UCS` definition."""

        np.testing.assert_almost_equal(
            uv_to_UCS(np.array([0.37720213, 0.33413508])),
            np.array([1.12889114, 1.00000000, 0.86391046]),
            decimal=7,
        )

        np.testing.assert_almost_equal(
            uv_to_UCS(np.array([0.14536327, 0.35328046])),
            np.array([0.41146705, 1.00000000, 1.41914520]),
            decimal=7,
        )

        np.testing.assert_almost_equal(
            uv_to_UCS(np.array([0.16953602, 0.20026156])),
            np.array([0.84657295, 1.00000000, 3.14689659]),
            decimal=7,
        )

        np.testing.assert_almost_equal(
            uv_to_UCS(np.array([0.37720213, 0.33413508]), V=0.18),
            np.array([0.20320040, 0.18000000, 0.15550388]),
            decimal=7,
        )
    def test_nan_uv_to_UCS(self):
        """Test :func:`colour.models.cie_ucs.uv_to_UCS` definition nan support."""

        cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan]
        cases = set(permutations(cases * 3, r=2))
        for case in cases:
            uv = np.array(case)
            uv_to_UCS(uv)
Exemple #3
0
    def test_domain_range_scale_uv_to_UCS(self):
        """
        Tests :func:`colour.models.cie_ucs.uv_to_UCS` definition domain and
        range scale support.
        """

        uv = np.array([0.37720213, 0.33413508])
        UCS = uv_to_UCS(uv)

        d_r = (('reference', 1), (1, 1), (100, 100))
        for scale, factor in d_r:
            with domain_range_scale(scale):
                np.testing.assert_almost_equal(uv_to_UCS(uv),
                                               UCS * factor,
                                               decimal=7)
Exemple #4
0
    def test_n_dimensional_uv_to_UCS(self):
        """
        Tests :func:`colour.models.cie_ucs.uv_to_UCS` definition n-dimensional
        support.
        """

        uv = np.array([0.37720213, 0.33413508])
        UCS = uv_to_UCS(uv)

        uv = np.tile(uv, (6, 1))
        UCS = np.tile(UCS, (6, 1))
        np.testing.assert_almost_equal(uv_to_UCS(uv), UCS, decimal=7)

        uv = np.reshape(uv, (2, 3, 2))
        UCS = np.reshape(UCS, (2, 3, 3))
        np.testing.assert_almost_equal(uv_to_UCS(uv), UCS, decimal=7)