Beispiel #1
0
    def test_n_dimensional_whiteness_Berger1959(self):
        """
        Tests :func:`colour.colorimetry.whiteness.whiteness_Berger1959`
        definition n_dimensional arrays support.
        """

        XYZ = np.array([95.00000000, 100.00000000, 105.00000000])
        XYZ_0 = np.array([94.80966767, 100.00000000, 107.30513595])
        W = 30.36380179
        np.testing.assert_almost_equal(whiteness_Berger1959(XYZ, XYZ_0),
                                       W,
                                       decimal=7)

        XYZ = np.tile(XYZ, (6, 1))
        XYZ_0 = np.tile(XYZ_0, (6, 1))
        W = np.tile(W, 6)
        np.testing.assert_almost_equal(whiteness_Berger1959(XYZ, XYZ_0),
                                       W,
                                       decimal=7)

        XYZ = np.reshape(XYZ, (2, 3, 3))
        XYZ_0 = np.reshape(XYZ_0, (2, 3, 3))
        W = np.reshape(W, (2, 3))
        np.testing.assert_almost_equal(whiteness_Berger1959(XYZ, XYZ_0),
                                       W,
                                       decimal=7)
Beispiel #2
0
    def test_whiteness_Berger1959(self):
        """
        Tests :func:`colour.colorimetry.whiteness.whiteness_Berger1959`
        definition.
        """

        self.assertAlmostEqual(
            whiteness_Berger1959(
                np.array([95.00000000, 100.00000000, 105.00000000]),
                np.array([94.80966767, 100.00000000, 107.30513595])),
            30.36380179,
            places=7)

        self.assertAlmostEqual(
            whiteness_Berger1959(
                np.array([105.00000000, 100.00000000, 95.00000000]),
                np.array([94.80966767, 100.00000000, 107.30513595])),
            5.530469280673941,
            places=7)

        self.assertAlmostEqual(
            whiteness_Berger1959(
                np.array([100.00000000, 100.00000000, 100.00000000]),
                np.array([100.00000000, 100.00000000, 100.00000000])),
            33.300000000000011,
            places=7)
Beispiel #3
0
    def test_n_dimensional_whiteness_Berger1959(self):
        """
        Tests :func:`colour.colorimetry.whiteness.whiteness_Berger1959`
        definition n_dimensional arrays support.
        """

        XYZ = np.array([95.00000000, 100.00000000, 105.00000000])
        XYZ_0 = np.array([94.80966767, 100.00000000, 107.30513595])
        W = 30.36380179
        np.testing.assert_almost_equal(
            whiteness_Berger1959(XYZ, XYZ_0),
            W,
            decimal=7)

        XYZ = np.tile(XYZ, (6, 1))
        XYZ_0 = np.tile(XYZ_0, (6, 1))
        W = np.tile(W, 6)
        np.testing.assert_almost_equal(
            whiteness_Berger1959(XYZ, XYZ_0),
            W,
            decimal=7)

        XYZ = np.reshape(XYZ, (2, 3, 3))
        XYZ_0 = np.reshape(XYZ_0, (2, 3, 3))
        W = np.reshape(W, (2, 3))
        np.testing.assert_almost_equal(
            whiteness_Berger1959(XYZ, XYZ_0),
            W,
            decimal=7)
Beispiel #4
0
    def test_whiteness_Berger1959(self):
        """
        Tests :func:`colour.colorimetry.whiteness.whiteness_Berger1959`
        definition.
        """

        self.assertAlmostEqual(
            whiteness_Berger1959(
                np.array([95.00000000, 100.00000000, 105.00000000]),
                np.array([94.80966767, 100.00000000, 107.30513595])),
            30.36380179,
            places=7)

        self.assertAlmostEqual(
            whiteness_Berger1959(
                np.array([105.00000000, 100.00000000, 95.00000000]),
                np.array([94.80966767, 100.00000000, 107.30513595])),
            5.530469280673941,
            places=7)

        self.assertAlmostEqual(
            whiteness_Berger1959(
                np.array([100.00000000, 100.00000000, 100.00000000]),
                np.array([100.00000000, 100.00000000, 100.00000000])),
            33.300000000000011,
            places=7)
Beispiel #5
0
    def test_nan_whiteness_Berger1959(self):
        """
        Tests :func:`colour.colorimetry.whiteness.whiteness_Berger1959`
        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:
            XYZ = np.array(case)
            XYZ_0 = np.array(case)
            whiteness_Berger1959(XYZ, XYZ_0)
Beispiel #6
0
    def test_nan_whiteness_Berger1959(self):
        """
        Tests :func:`colour.colorimetry.whiteness.whiteness_Berger1959`
        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:
            XYZ = np.array(case)
            XYZ_0 = np.array(case)
            whiteness_Berger1959(XYZ, XYZ_0)
Beispiel #7
0
    def test_domain_range_scale_whiteness_Berger1959(self):
        """
        Tests :func:`colour.colorimetry.whiteness.whiteness_Berger1959`
        definition domain and range scale support.
        """

        XYZ = np.array([95.00000000, 100.00000000, 105.00000000])
        XYZ_0 = np.array([94.80966767, 100.00000000, 107.30513595])
        W = whiteness_Berger1959(XYZ, XYZ_0)

        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(whiteness_Berger1959(
                    XYZ * factor, XYZ_0 * factor),
                                               W * factor,
                                               decimal=7)