Example #1
0
    def test_write_LUT_Cinespace(self):
        """
        Test :func:`colour.io.luts.cinespace_csp.write_LUT_Cinespace`
        definition.
        """

        LUT_1_r = read_LUT_Cinespace(
            os.path.join(LUTS_DIRECTORY, "ACES_Proxy_10_to_ACES.csp")
        )
        write_LUT_Cinespace(
            LUT_1_r,
            os.path.join(
                self._temporary_directory, "ACES_Proxy_10_to_ACES.csp"
            ),
        )
        LUT_1_t = read_LUT_Cinespace(
            os.path.join(
                self._temporary_directory, "ACES_Proxy_10_to_ACES.csp"
            )
        )
        self.assertEqual(LUT_1_r, LUT_1_t)
        self.assertEqual(LUT_1_r, LUT_1_t)

        LUT_2_r = read_LUT_Cinespace(os.path.join(LUTS_DIRECTORY, "Demo.csp"))
        write_LUT_Cinespace(
            LUT_2_r, os.path.join(self._temporary_directory, "Demo.csp")
        )
        LUT_2_t = read_LUT_Cinespace(
            os.path.join(self._temporary_directory, "Demo.csp")
        )
        self.assertEqual(LUT_2_r, LUT_2_t)
        self.assertListEqual(LUT_2_r.comments, LUT_2_t.comments)

        LUT_3_r = read_LUT_Cinespace(
            os.path.join(LUTS_DIRECTORY, "Three_Dimensional_Table.csp")
        )
        write_LUT_Cinespace(
            LUT_3_r,
            os.path.join(
                self._temporary_directory, "Three_Dimensional_Table.csp"
            ),
        )
        LUT_3_t = read_LUT_Cinespace(
            os.path.join(
                self._temporary_directory, "Three_Dimensional_Table.csp"
            )
        )
        self.assertEqual(LUT_3_r, LUT_3_t)

        domain = tstack(
            (
                np.array([0.0, 0.1, 0.2, 0.4, 0.8, 1.2]),
                np.array([-0.1, 0.5, 1.0, np.nan, np.nan, np.nan]),
                np.array([-1.0, -0.5, 0.0, 0.5, 1.0, np.nan]),
            )
        )
        LUT_4_t = LUT3x1D(
            domain=domain, table=domain * 2, name="Ragged Domain"
        )
        write_LUT_Cinespace(
            LUT_4_t,
            os.path.join(self._temporary_directory, "Ragged_Domain.csp"),
        )
        LUT_4_r = read_LUT_Cinespace(
            os.path.join(LUTS_DIRECTORY, "Ragged_Domain.csp")
        )
        np.testing.assert_almost_equal(LUT_4_t.domain, LUT_4_r.domain)
        np.testing.assert_almost_equal(LUT_4_t.table, LUT_4_r.table, decimal=6)

        LUT_5_r = read_LUT_Cinespace(
            os.path.join(
                LUTS_DIRECTORY, "Three_Dimensional_Table_With_Shaper.csp"
            )
        )
        LUT_5_r.sequence[0] = LUT_5_r.sequence[0].as_LUT(
            LUT1D, force_conversion=True
        )
        write_LUT_Cinespace(
            LUT_5_r,
            os.path.join(
                self._temporary_directory,
                "Three_Dimensional_Table_With_Shaper.csp",
            ),
        )
        LUT_5_r = read_LUT_Cinespace(
            os.path.join(
                LUTS_DIRECTORY, "Three_Dimensional_Table_With_Shaper.csp"
            )
        )
        LUT_5_t = read_LUT_Cinespace(
            os.path.join(
                self._temporary_directory,
                "Three_Dimensional_Table_With_Shaper.csp",
            )
        )
        self.assertEqual(LUT_5_r, LUT_5_t)

        LUT_6_r = read_LUT_Cinespace(
            os.path.join(
                LUTS_DIRECTORY, "Three_Dimensional_Table_With_Shaper.csp"
            )
        )
        LUT_6_r.sequence[0] = LUT_6_r.sequence[0].as_LUT(
            LUT3x1D, force_conversion=True
        )
        write_LUT_Cinespace(
            LUT_6_r,
            os.path.join(
                self._temporary_directory,
                "Three_Dimensional_Table_With_Shaper.csp",
            ),
        )
        LUT_6_r = read_LUT_Cinespace(
            os.path.join(
                LUTS_DIRECTORY, "Three_Dimensional_Table_With_Shaper.csp"
            )
        )
        LUT_6_t = read_LUT_Cinespace(
            os.path.join(
                self._temporary_directory,
                "Three_Dimensional_Table_With_Shaper.csp",
            )
        )
        self.assertEqual(LUT_6_r, LUT_6_t)

        LUT_7_r = read_LUT_Cinespace(
            os.path.join(LUTS_DIRECTORY, "ACES_Proxy_10_to_ACES.csp")
        )
        write_LUT_Cinespace(
            LUT_7_r.as_LUT(LUT1D, force_conversion=True),
            os.path.join(
                self._temporary_directory, "ACES_Proxy_10_to_ACES.csp"
            ),
        )
        LUT_7_t = read_LUT_Cinespace(
            os.path.join(
                self._temporary_directory, "ACES_Proxy_10_to_ACES.csp"
            )
        )
        self.assertEqual(LUT_7_r, LUT_7_t)
Example #2
0
    def test_write_LUT_Cinespace(self):
        """
        Tests :func:`colour.io.luts.cinespace_csp.write_LUT_Cinespace`
        definition.
        """

        LUT_1_r = read_LUT_Cinespace(
            os.path.join(LUTS_DIRECTORY, 'ACES_Proxy_10_to_ACES.csp'))

        write_LUT_Cinespace(
            LUT_1_r,
            os.path.join(self._temporary_directory,
                         'ACES_Proxy_10_to_ACES.csp'))

        LUT_1_t = read_LUT_Cinespace(
            os.path.join(self._temporary_directory,
                         'ACES_Proxy_10_to_ACES.csp'))

        self.assertEqual(LUT_1_r, LUT_1_t)

        self.assertEqual(LUT_1_r, LUT_1_t)

        LUT_2_r = read_LUT_Cinespace(os.path.join(LUTS_DIRECTORY, 'Demo.csp'))

        write_LUT_Cinespace(
            LUT_2_r, os.path.join(self._temporary_directory, 'Demo.csp'))

        LUT_2_t = read_LUT_Cinespace(
            os.path.join(self._temporary_directory, 'Demo.csp'))

        self.assertEqual(LUT_2_r, LUT_2_t)
        self.assertListEqual(LUT_2_r.comments, LUT_2_t.comments)

        LUT_3_r = read_LUT_Cinespace(
            os.path.join(LUTS_DIRECTORY, 'ThreeDimensionalTable.csp'))

        write_LUT_Cinespace(
            LUT_3_r,
            os.path.join(self._temporary_directory,
                         'ThreeDimensionalTable.csp'))

        LUT_3_t = read_LUT_Cinespace(
            os.path.join(self._temporary_directory,
                         'ThreeDimensionalTable.csp'))

        self.assertEqual(LUT_3_r, LUT_3_t)

        write_LUT_Cinespace(
            LUTSequence(LUT_1_r, LUT_3_r),
            os.path.join(self._temporary_directory, 'test_sequence.csp'))

        r = np.array([0.0, 0.1, 0.2, 0.4, 0.8, 1.2])
        g = np.array([-0.1, 0.5, 1.0, np.nan, np.nan, np.nan])
        b = np.array([-1.0, -0.5, 0.0, 0.5, 1.0, np.nan])

        domain = tstack((r, g, b))

        LUT_4_t = LUT3x1D(domain=domain, table=domain * 2)

        write_LUT_Cinespace(
            LUT_4_t,
            os.path.join(self._temporary_directory, 'ragged_domain.csp'))

        LUT_4_r = read_LUT_Cinespace(
            os.path.join(self._temporary_directory, 'ragged_domain.csp'))

        np.testing.assert_almost_equal(LUT_4_t.domain, LUT_4_r.domain)

        np.testing.assert_almost_equal(LUT_4_t.table, LUT_4_r.table, decimal=6)