Пример #1
0
    def test_is_uniform(self):
        """
        Tests :func:`colour.algebra.common.is_uniform` definition.
        """

        self.assertTrue(is_uniform(range(0, 10, 2)))
        self.assertFalse(is_uniform([1, 2, 3, 4, 6]))
Пример #2
0
    def test_is_uniform(self):
        """
        Tests :func:`colour.algebra.common.is_uniform` definition.
        """

        self.assertTrue(is_uniform(range(0, 10, 2)))
        self.assertFalse(is_uniform([1, 2, 3, 4, 6]))
Пример #3
0
    def x(self, value):
        """
        Setter for **self.__x** private attribute.

        Parameters
        ----------
        value : array_like
            Attribute value.
        """

        if value is not None:
            value = to_ndarray(value)

            assert value.ndim == 1, (
                '"x" independent variable must have exactly one dimension!')

            assert is_uniform(value), (
                '"x" independent variable is not uniform!')

            if not issubclass(value.dtype.type, np.inexact):
                value = value.astype(np.float_)

            value_steps = steps(value)[0]

            xp1 = value[0] - value_steps * 2
            xp2 = value[0] - value_steps
            xp3 = value[-1] + value_steps
            xp4 = value[-1] + value_steps * 2

            self.__xp = np.concatenate(((xp1, xp2), value, (xp3, xp4)))

        self.__x = value
Пример #4
0
    def x(self, value):
        """
        Setter for **self.__x** private attribute.

        Parameters
        ----------
        value : array_like
            Attribute value.
        """

        if value is not None:
            value = to_ndarray(value)

            assert value.ndim == 1, (
                '"x" independent variable must have exactly one dimension!')

            assert is_uniform(value), (
                '"x" independent variable is not uniform!')

            if not issubclass(value.dtype.type, np.inexact):
                value = value.astype(np.float_)

            value_steps = steps(value)[0]

            xp1 = value[0] - value_steps * 2
            xp2 = value[0] - value_steps
            xp3 = value[-1] + value_steps
            xp4 = value[-1] + value_steps * 2

            self.__xp = np.concatenate(((xp1, xp2), value, (xp3, xp4)))

        self.__x = value