Esempio n. 1
0
    def test_fill_nan(self):
        """
        Tests :func:`colour.utilities.array.fill_nan` definition.
        """

        a = np.array([0.1, 0.2, np.nan, 0.4, 0.5])
        np.testing.assert_almost_equal(
            fill_nan(a), np.array([0.1, 0.2, 0.3, 0.4, 0.5]), decimal=7)

        np.testing.assert_almost_equal(
            fill_nan(a, method='Constant', default=8.0),
            np.array([0.1, 0.2, 8.0, 0.4, 0.5]),
            decimal=7)
Esempio n. 2
0
    def _fill_range_nan(
        self,
        method: Union[
            Literal["Constant", "Interpolation"], str
        ] = "Interpolation",
        default: Number = 0,
    ):
        """
        Fill NaNs in corresponding range variable :math:`y` using given method.

        Parameters
        ----------
        method
            *Interpolation* method linearly interpolates through the NaNs,
            *Constant* method replaces NaNs with ``default``.
        default
            Value to use with the *Constant* method.

        Returns
        -------
        :class:`colour.continuous.Signal`
            NaNs filled continuous signal i corresponding range :math:`y`
            variable.
        """

        self._range = fill_nan(self._range, method, default)
        self._create_function()
Esempio n. 3
0
    def _fill_range_nan(self, method='Interpolation', default=0):
        """
        Fill NaNs in corresponding range :math:`y` variable using given method.

        Parameters
        ----------
        method : unicode, optional
            **{'Interpolation', 'Constant'}**,
            *Interpolation* method linearly interpolates through the NaNs,
            *Constant* method replaces NaNs with ``default``.
        default : numeric, optional
            Value to use with the *Constant* method.

        Returns
        -------
        Signal
            NaNs filled continuous signal i corresponding range :math:`y`
            variable.
        """

        self._range = fill_nan(self._range, method, default)
        self._create_function()
Esempio n. 4
0
    def _fill_range_nan(self, method='Interpolation', default=0):
        """
        Fill NaNs in corresponding range :math:`y` variable using given method.

        Parameters
        ----------
        method : unicode, optional
            **{'Interpolation', 'Constant'}**,
            *Interpolation* method linearly interpolates through the NaNs,
            *Constant* method replaces NaNs with ``default``.
        default : numeric, optional
            Value to use with the *Constant* method.

        Returns
        -------
        Signal
            NaNs filled continuous signal i corresponding range :math:`y`
            variable.
        """

        self._range = fill_nan(self._range, method, default)
        self._create_function()