def test_cctf_decoding_ROMMRGB(self):
        """
        Test :func:`colour.models.rgb.transfer_functions.rimm_romm_rgb.\
cctf_decoding_ROMMRGB` definition.
        """

        self.assertAlmostEqual(cctf_decoding_ROMMRGB(0.0), 0.0, places=7)

        self.assertAlmostEqual(
            cctf_decoding_ROMMRGB(0.385711424751138), 0.18, places=7
        )

        self.assertAlmostEqual(cctf_decoding_ROMMRGB(1.0), 1.0, places=7)

        np.testing.assert_allclose(
            cctf_decoding_ROMMRGB(98, in_int=True),
            0.18,
            atol=0.001,
            rtol=0.001,
        )

        np.testing.assert_allclose(
            cctf_decoding_ROMMRGB(1579, bit_depth=12, in_int=True),
            0.18,
            atol=0.001,
            rtol=0.001,
        )
    def test_n_dimensional_cctf_decoding_ROMMRGB(self):
        """
        Test :func:`colour.models.rgb.transfer_functions.rimm_romm_rgb.\
cctf_decoding_ROMMRGB` definition n-dimensional arrays support.
        """

        X_p = 0.385711424751138
        X = cctf_decoding_ROMMRGB(X_p)

        X_p = np.tile(X_p, 6)
        X = np.tile(X, 6)
        np.testing.assert_almost_equal(
            cctf_decoding_ROMMRGB(X_p), X, decimal=7
        )

        X_p = np.reshape(X_p, (2, 3))
        X = np.reshape(X, (2, 3))
        np.testing.assert_almost_equal(
            cctf_decoding_ROMMRGB(X_p), X, decimal=7
        )

        X_p = np.reshape(X_p, (2, 3, 1))
        X = np.reshape(X, (2, 3, 1))
        np.testing.assert_almost_equal(
            cctf_decoding_ROMMRGB(X_p), X, decimal=7
        )
Esempio n. 3
0
    def test_nan_cctf_decoding_ROMMRGB(self):
        """
        Tests :func:`colour.models.rgb.transfer_functions.rimm_romm_rgb.\
cctf_decoding_ROMMRGB` definition nan support.
        """

        cctf_decoding_ROMMRGB(
            np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan]))
    def test_domain_range_scale_cctf_decoding_ROMMRGB(self):
        """
        Test :func:`colour.models.rgb.transfer_functions.rimm_romm_rgb.\
cctf_decoding_ROMMRGB` definition domain and range scale support.
        """

        X_p = 0.385711424751138
        X = cctf_decoding_ROMMRGB(X_p)

        d_r = (("reference", 1), ("1", 1), ("100", 100))
        for scale, factor in d_r:
            with domain_range_scale(scale):
                np.testing.assert_almost_equal(
                    cctf_decoding_ROMMRGB(X_p * factor), X * factor, decimal=7
                )