Example #1
0
    def test_method(self):
        """
        Tests :func:`colour.algebra.extrapolation.Extrapolator.method`
        property.
        """

        extrapolator = Extrapolator(
            LinearInterpolator(np.array([5, 6, 7]), np.array([5, 6, 7])))
        self.assertEqual(extrapolator.method, 'linear')

        extrapolator = Extrapolator(
            LinearInterpolator(np.array([5, 6, 7]), np.array([5, 6, 7])),
            method='Constant')
        self.assertEqual(extrapolator.method, 'constant')
    def test_method(self):
        """
        Test :attr:`colour.algebra.extrapolation.Extrapolator.method`
        property.
        """

        extrapolator = Extrapolator(
            LinearInterpolator(np.array([5, 6, 7]), np.array([5, 6, 7])))
        self.assertEqual(extrapolator.method, "linear")

        extrapolator = Extrapolator(
            LinearInterpolator(np.array([5, 6, 7]), np.array([5, 6, 7])),
            method="Constant",
        )
        self.assertEqual(extrapolator.method, "constant")
Example #3
0
    def test_interpolator(self):
        """
        Tests :func:`colour.algebra.extrapolation.Extrapolator.interpolator`
        property.
        """

        extrapolator = Extrapolator(
            LinearInterpolator(np.array([5, 6, 7]), np.array([5, 6, 7])))
        self.assertIsInstance(extrapolator.interpolator, LinearInterpolator)
Example #4
0
    def test_right(self):
        """
        Tests :func:`colour.algebra.extrapolation.Extrapolator.right`
        property.
        """

        extrapolator = Extrapolator(
            LinearInterpolator(np.array([5, 6, 7]), np.array([5, 6, 7])),
            right=0)
        self.assertEqual(extrapolator.right, 0)
    def test_left(self):
        """
        Test :attr:`colour.algebra.extrapolation.Extrapolator.left`
        property.
        """

        extrapolator = Extrapolator(
            LinearInterpolator(np.array([5, 6, 7]), np.array([5, 6, 7])),
            left=0,
        )
        self.assertEqual(extrapolator.left, 0)
Example #6
0
    def test___call__(self):
        """
        Tests :func:`colour.algebra.extrapolation.Extrapolator.__call__`
        method.
        """

        extrapolator = Extrapolator(
            LinearInterpolator(
                np.array([5, 6, 7]),
                np.array([5, 6, 7])))
        np.testing.assert_almost_equal(extrapolator((4, 8)), (4, 8))
        self.assertEqual(extrapolator(4), 4)

        extrapolator = Extrapolator(
            LinearInterpolator(
                np.array([3, 4, 5]),
                np.array([1, 2, 3])),
            method='Constant')
        np.testing.assert_almost_equal(extrapolator((0.1, 0.2, 8, 9)),
                                       (1, 1, 3, 3))
        self.assertEqual(extrapolator(0.1), 1.)

        extrapolator = Extrapolator(
            LinearInterpolator(
                np.array([3, 4, 5]),
                np.array([1, 2, 3])),
            method='Constant',
            left=0)
        np.testing.assert_almost_equal(extrapolator((0.1, 0.2, 8, 9)),
                                       (0, 0, 3, 3))
        self.assertEqual(extrapolator(0.1), 0)

        extrapolator = Extrapolator(
            LinearInterpolator(
                np.array([3, 4, 5]),
                np.array([1, 2, 3])),
            method='Constant',
            right=0)
        np.testing.assert_almost_equal(extrapolator((0.1, 0.2, 8, 9)),
                                       (1, 1, 0, 0))
        self.assertEqual(extrapolator(9), 0)

        extrapolator = Extrapolator(
            CubicSplineInterpolator(
                np.array([3, 4, 5, 6]),
                np.array([1, 2, 3, 4])))
        np.testing.assert_almost_equal(extrapolator((0.1, 0.2, 8.0, 9.0)),
                                       (-1.9, -1.8, 6.0, 7.0))
        self.assertEqual(extrapolator(9), 7)

        extrapolator = Extrapolator(
            PchipInterpolator(
                np.array([3, 4, 5]),
                np.array([1, 2, 3])))
        np.testing.assert_almost_equal(extrapolator((0.1, 0.2, 8.0, 9.0)),
                                       (-1.9, -1.8, 6.0, 7.0))
        self.assertEqual(extrapolator(9), 7.)
Example #7
0
def _log_decoding_FilmicPro6_interpolator():
    """
    Returns the *FiLMiC Pro 6* log decoding curve / electro-optical transfer
    function interpolator and caches it if not existing.

    Returns
    -------
    Extrapolator
        *FiLMiC Pro 6* log decoding curve / electro-optical transfer
        function interpolator.
    """

    global _LOG_DECODING_FILMICPRO_INTERPOLATOR_CACHE

    t = np.arange(0, 1, 0.0001)
    if _LOG_DECODING_FILMICPRO_INTERPOLATOR_CACHE is None:
        _LOG_DECODING_FILMICPRO_INTERPOLATOR_CACHE = Extrapolator(
            LinearInterpolator(log_encoding_FilmicPro6(t), t))

    return _LOG_DECODING_FILMICPRO_INTERPOLATOR_CACHE