Exemple #1
0
    def test_steps(self):
        """
        Tests :func:`colour.algebra.common.steps` definition.
        """

        self.assertTupleEqual(steps(range(0, 10, 2)), (2, ))
        self.assertTupleEqual(tuple(sorted(steps([1, 2, 3, 4, 6, 6.5]))),
                              (0.5, 1, 2))
Exemple #2
0
    def test_steps(self):
        """
        Tests :func:`colour.algebra.common.steps` definition.
        """

        self.assertTupleEqual(steps(range(0, 10, 2)), (2,))
        self.assertTupleEqual(
            tuple(sorted(steps([1, 2, 3, 4, 6, 6.5]))),
            (0.5, 1, 2))
Exemple #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
Exemple #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