Пример #1
0
    def test_n_dimensional_UVW_to_XYZ(self):
        """
        Tests :func:`colour.models.cie_uvw.UVW_to_XYZ` definition n-dimensional
        support.
        """

        UVW = np.array([94.55035725, 11.55536523, 40.54757405])
        illuminant = np.array([0.31270, 0.32900])
        XYZ = UVW_to_XYZ(UVW, illuminant)

        XYZ = np.tile(XYZ, (6, 1))
        UVW = np.tile(UVW, (6, 1))
        np.testing.assert_almost_equal(UVW_to_XYZ(UVW, illuminant),
                                       XYZ,
                                       decimal=7)

        illuminant = np.tile(illuminant, (6, 1))
        np.testing.assert_almost_equal(UVW_to_XYZ(UVW, illuminant),
                                       XYZ,
                                       decimal=7)

        XYZ = np.reshape(XYZ, (2, 3, 3))
        illuminant = np.reshape(illuminant, (2, 3, 2))
        UVW = np.reshape(UVW, (2, 3, 3))
        np.testing.assert_almost_equal(UVW_to_XYZ(UVW, illuminant),
                                       XYZ,
                                       decimal=7)
Пример #2
0
    def test_domain_range_scale_UVW_to_XYZ(self):
        """
        Tests :func:`colour.models.cie_uvw.UVW_to_XYZ` definition domain and
        range scale support.
        """

        UVW = np.array([94.55035725, 11.55536523, 40.54757405])
        illuminant = np.array([0.31270, 0.32900])
        XYZ = UVW_to_XYZ(UVW, illuminant)

        d_r = (('reference', 1), (1, 0.01), (100, 1))
        for scale, factor in d_r:
            with domain_range_scale(scale):
                np.testing.assert_almost_equal(UVW_to_XYZ(
                    UVW * factor, illuminant),
                                               XYZ * factor,
                                               decimal=7)
Пример #3
0
    def test_nan_UVW_to_XYZ(self):
        """
        Tests :func:`colour.models.cie_uvw.UVW_to_XYZ` 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:
            UVW = np.array(case)
            illuminant = np.array(case[0:2])
            UVW_to_XYZ(UVW, illuminant)
Пример #4
0
    def test_UVW_to_XYZ(self):
        """
        Tests :func:`colour.models.cie_uvw.UVW_to_XYZ` definition.
        """

        np.testing.assert_almost_equal(
            UVW_to_XYZ(np.array([94.55035725, 11.55536523, 40.54757405])),
            np.array([0.20654008, 0.12197225, 0.05136952]) * 100,
            decimal=7)

        np.testing.assert_almost_equal(
            UVW_to_XYZ(np.array([-36.92762376, 28.90425105, 54.14071478])),
            np.array([0.14222010, 0.23042768, 0.10495772]) * 100,
            decimal=7)

        np.testing.assert_almost_equal(
            UVW_to_XYZ(np.array([-10.60111550, -41.94580000, 28.82134002])),
            np.array([0.07818780, 0.06157201, 0.28099326]) * 100,
            decimal=7)

        np.testing.assert_almost_equal(
            UVW_to_XYZ(
                np.array([63.90676310, -8.11466183, 40.54757405]),
                np.array([0.44757, 0.40745])),
            np.array([0.20654008, 0.12197225, 0.05136952]) * 100,
            decimal=7)

        np.testing.assert_almost_equal(
            UVW_to_XYZ(
                np.array([88.56798946, 4.61154385, 40.54757405]),
                np.array([0.34570, 0.35850])),
            np.array([0.20654008, 0.12197225, 0.05136952]) * 100,
            decimal=7)

        np.testing.assert_almost_equal(
            UVW_to_XYZ(
                np.array([88.56798946, 4.61154385, 40.54757405]),
                np.array([0.34570, 0.35850, 1.00000])),
            np.array([0.20654008, 0.12197225, 0.05136952]) * 100,
            decimal=7)