예제 #1
0
    def test_n_dimensional_closest_spectral_locus_wavelength(self):
        """
        Tests :func:`colour.colorimetry.dominant.\
closest_spectral_locus_wavelength` definition n-dimensional arrays support.
        """

        xy = np.array([0.54369557, 0.32107944])
        xy_n = D65
        i_wl, xy_wl = closest_spectral_locus_wavelength(xy, xy_n, self._xy_s)
        i_wl_r, xy_wl_r = np.array(256), np.array([0.68354746, 0.31628409])
        np.testing.assert_almost_equal(i_wl, i_wl_r)
        np.testing.assert_almost_equal(xy_wl, xy_wl_r, decimal=7)

        xy = np.tile(xy, (6, 1))
        xy_n = np.tile(xy_n, (6, 1))
        i_wl, xy_wl = closest_spectral_locus_wavelength(xy, xy_n, self._xy_s)
        i_wl_r = np.tile(i_wl_r, 6)
        xy_wl_r = np.tile(xy_wl_r, (6, 1))
        np.testing.assert_almost_equal(i_wl, i_wl_r)
        np.testing.assert_almost_equal(xy_wl, xy_wl_r, decimal=7)

        xy = np.reshape(xy, (2, 3, 2))
        xy_n = np.reshape(xy_n, (2, 3, 2))
        i_wl, xy_wl = closest_spectral_locus_wavelength(xy, xy_n, self._xy_s)
        i_wl_r = np.reshape(i_wl_r, (2, 3))
        xy_wl_r = np.reshape(xy_wl_r, (2, 3, 2))
        np.testing.assert_almost_equal(i_wl, i_wl_r)
        np.testing.assert_almost_equal(xy_wl, xy_wl_r, decimal=7)
예제 #2
0
    def test_n_dimensional_closest_spectral_locus_wavelength(self):
        """
        Test :func:`colour.colorimetry.dominant.\
closest_spectral_locus_wavelength` definition n-dimensional arrays support.
        """

        xy = np.array([0.54369557, 0.32107944])
        xy_n = self._xy_D65
        i_wl, xy_wl = closest_spectral_locus_wavelength(xy, xy_n, self._xy_s)
        i_wl_r, xy_wl_r = np.array(256), np.array([0.68354746, 0.31628409])
        np.testing.assert_almost_equal(i_wl, i_wl_r)
        np.testing.assert_almost_equal(xy_wl, xy_wl_r, decimal=7)

        xy = np.tile(xy, (6, 1))
        xy_n = np.tile(xy_n, (6, 1))
        i_wl, xy_wl = closest_spectral_locus_wavelength(xy, xy_n, self._xy_s)
        i_wl_r = np.tile(i_wl_r, 6)
        xy_wl_r = np.tile(xy_wl_r, (6, 1))
        np.testing.assert_almost_equal(i_wl, i_wl_r)
        np.testing.assert_almost_equal(xy_wl, xy_wl_r, decimal=7)

        xy = np.reshape(xy, (2, 3, 2))
        xy_n = np.reshape(xy_n, (2, 3, 2))
        i_wl, xy_wl = closest_spectral_locus_wavelength(xy, xy_n, self._xy_s)
        i_wl_r = np.reshape(i_wl_r, (2, 3))
        xy_wl_r = np.reshape(xy_wl_r, (2, 3, 2))
        np.testing.assert_almost_equal(i_wl, i_wl_r)
        np.testing.assert_almost_equal(xy_wl, xy_wl_r, decimal=7)
예제 #3
0
    def test_n_dimensional_closest_spectral_locus_wavelength(self):
        """
        Tests :func:`colour.colorimetry.dominant.\
closest_spectral_locus_wavelength` definition n-dimensional arrays support.
        """

        xy = np.array([0.26415, 0.37770])
        xy_n = D65
        i_wl, xy_wl = closest_spectral_locus_wavelength(xy, xy_n, self._xy_s)
        i_wl_r, xy_wl_r = 144, np.array([0.00369694, 0.63895775])
        np.testing.assert_almost_equal(
            i_wl, i_wl_r, decimal=7)
        np.testing.assert_almost_equal(xy_wl, xy_wl_r)

        xy = np.tile(xy, (6, 1))
        xy_n = np.tile(xy_n, (6, 1))
        i_wl, xy_wl = closest_spectral_locus_wavelength(xy, xy_n, self._xy_s)
        i_wl_r = np.tile(i_wl_r, 6)
        xy_wl_r = np.tile(xy_wl_r, (6, 1))
        np.testing.assert_almost_equal(
            i_wl, i_wl_r, decimal=7)
        np.testing.assert_almost_equal(xy_wl, xy_wl_r)

        xy = np.reshape(xy, (2, 3, 2))
        xy_n = np.reshape(xy_n, (2, 3, 2))
        i_wl, xy_wl = closest_spectral_locus_wavelength(xy, xy_n, self._xy_s)
        i_wl_r = np.reshape(i_wl_r, (2, 3))
        xy_wl_r = np.reshape(xy_wl_r, (2, 3, 2))
        np.testing.assert_almost_equal(
            i_wl, i_wl_r, decimal=7)
        np.testing.assert_almost_equal(xy_wl, xy_wl_r)
예제 #4
0
    def test_n_dimensional_closest_spectral_locus_wavelength(self):
        """
        Tests :func:`colour.colorimetry.dominant.\
closest_spectral_locus_wavelength` definition n-dimensional arrays support.
        """

        xy = np.array([0.26415, 0.37770])
        xy_n = D65
        i_wl, xy_wl = closest_spectral_locus_wavelength(xy, xy_n, self._xy_s)
        i_wl_r, xy_wl_r = 144, np.array([0.00369694, 0.63895775])
        np.testing.assert_almost_equal(i_wl, i_wl_r, decimal=7)
        np.testing.assert_almost_equal(xy_wl, xy_wl_r)

        xy = np.tile(xy, (6, 1))
        xy_n = np.tile(xy_n, (6, 1))
        i_wl, xy_wl = closest_spectral_locus_wavelength(xy, xy_n, self._xy_s)
        i_wl_r = np.tile(i_wl_r, 6)
        xy_wl_r = np.tile(xy_wl_r, (6, 1))
        np.testing.assert_almost_equal(i_wl, i_wl_r, decimal=7)
        np.testing.assert_almost_equal(xy_wl, xy_wl_r)

        xy = np.reshape(xy, (2, 3, 2))
        xy_n = np.reshape(xy_n, (2, 3, 2))
        i_wl, xy_wl = closest_spectral_locus_wavelength(xy, xy_n, self._xy_s)
        i_wl_r = np.reshape(i_wl_r, (2, 3))
        xy_wl_r = np.reshape(xy_wl_r, (2, 3, 2))
        np.testing.assert_almost_equal(i_wl, i_wl_r, decimal=7)
        np.testing.assert_almost_equal(xy_wl, xy_wl_r)
예제 #5
0
    def test_nan_closest_spectral_locus_wavelength(self):
        """
        Tests :func:`colour.colorimetry.dominant.\
    closest_spectral_locus_wavelength` 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:
            try:
                closest_spectral_locus_wavelength(case, case, self._xy_s)
            except ValueError:
                pass
예제 #6
0
    def test_closest_spectral_locus_wavelength(self):
        """
        Tests :func:`colour.colorimetry.dominant.\
closest_spectral_locus_wavelength` definition.
        """

        xy = np.array([0.54369557, 0.32107944])
        xy_n = D65
        i_wl, xy_wl = closest_spectral_locus_wavelength(xy, xy_n, self._xy_s)

        self.assertEqual(i_wl, np.array(256))
        np.testing.assert_almost_equal(
            xy_wl, np.array([0.68354746, 0.31628409]), decimal=7)

        xy = np.array([0.37605506, 0.24452225])
        i_wl, xy_wl = closest_spectral_locus_wavelength(xy, xy_n, self._xy_s)

        self.assertEqual(i_wl, np.array(248))
        np.testing.assert_almost_equal(
            xy_wl, np.array([0.45723147, 0.13628148]), decimal=7)
예제 #7
0
    def test_closest_spectral_locus_wavelength(self):
        """
        Tests :func:`colour.colorimetry.dominant.\
closest_spectral_locus_wavelength` definition.
        """

        xy = np.array([0.26415, 0.37770])
        xy_n = D65
        i_wl, xy_wl = closest_spectral_locus_wavelength(xy, xy_n, self._xy_s)

        self.assertEqual(i_wl, 144)
        np.testing.assert_almost_equal(
            xy_wl, np.array([0.00369694, 0.63895775]), decimal=7)

        xy = np.array([0.35000, 0.25000])
        i_wl, xy_wl = closest_spectral_locus_wavelength(xy, xy_n, self._xy_s)

        self.assertEqual(i_wl, 0)
        np.testing.assert_almost_equal(
            xy_wl, np.array([0.41333146, 0.11586634]), decimal=7)
예제 #8
0
    def test_closest_spectral_locus_wavelength(self):
        """
        Tests :func:`colour.colorimetry.dominant.\
closest_spectral_locus_wavelength` definition.
        """

        xy = np.array([0.54369557, 0.32107944])
        xy_n = D65
        i_wl, xy_wl = closest_spectral_locus_wavelength(xy, xy_n, self._xy_s)

        self.assertEqual(i_wl, np.array(256))
        np.testing.assert_almost_equal(
            xy_wl, np.array([0.68354746, 0.31628409]), decimal=7)

        xy = np.array([0.37605506, 0.24452225])
        i_wl, xy_wl = closest_spectral_locus_wavelength(xy, xy_n, self._xy_s)

        self.assertEqual(i_wl, np.array(248))
        np.testing.assert_almost_equal(
            xy_wl, np.array([0.45723147, 0.13628148]), decimal=7)
예제 #9
0
    def test_closest_spectral_locus_wavelength(self):
        """
        Tests :func:`colour.colorimetry.dominant.\
closest_spectral_locus_wavelength` definition.
        """

        xy = np.array([0.26415, 0.37770])
        xy_n = D65
        i_wl, xy_wl = closest_spectral_locus_wavelength(xy, xy_n, self._xy_s)

        self.assertEqual(i_wl, 144)
        np.testing.assert_almost_equal(
            xy_wl, np.array([0.00369694, 0.63895775]), decimal=7)

        xy = np.array([0.35000, 0.25000])
        i_wl, xy_wl = closest_spectral_locus_wavelength(xy, xy_n, self._xy_s)

        self.assertEqual(i_wl, 0)
        np.testing.assert_almost_equal(
            xy_wl, np.array([0.41333146, 0.11586634]), decimal=7)