def test_is_documentation_building(self):
        """
        Tests :func:`colour.utilities.documentation.is_documentation_building`
        definition.
        """

        try:
            self.assertFalse(is_documentation_building())

            os.environ['READTHEDOCS'] = 'True'
            self.assertTrue(is_documentation_building())

            os.environ['READTHEDOCS'] = 'False'
            self.assertTrue(is_documentation_building())

            del os.environ['READTHEDOCS']
            self.assertFalse(is_documentation_building())

            os.environ['COLOUR_SCIENCE_DOCUMENTATION_BUILD'] = 'True'
            self.assertTrue(is_documentation_building())

            os.environ['COLOUR_SCIENCE_DOCUMENTATION_BUILD'] = 'False'
            self.assertTrue(is_documentation_building())

            del os.environ['COLOUR_SCIENCE_DOCUMENTATION_BUILD']
            self.assertFalse(is_documentation_building())

        finally:
            if os.environ.get('READTHEDOCS'):
                del os.environ['READTHEDOCS']

            if os.environ.get('COLOUR_SCIENCE_DOCUMENTATION_BUILD'):
                del os.environ['COLOUR_SCIENCE_DOCUMENTATION_BUILD']
示例#2
0
    def test_is_documentation_building(self):
        """
        Tests :func:`colour.utilities.documentation.is_documentation_building`
        definition.
        """

        try:
            self.assertFalse(is_documentation_building())

            os.environ['READTHEDOCS'] = 'True'
            self.assertTrue(is_documentation_building())

            os.environ['READTHEDOCS'] = 'False'
            self.assertTrue(is_documentation_building())

            del os.environ['READTHEDOCS']
            self.assertFalse(is_documentation_building())

            os.environ['COLOUR_SCIENCE_DOCUMENTATION_BUILD'] = 'True'
            self.assertTrue(is_documentation_building())

            os.environ['COLOUR_SCIENCE_DOCUMENTATION_BUILD'] = 'False'
            self.assertTrue(is_documentation_building())

            del os.environ['COLOUR_SCIENCE_DOCUMENTATION_BUILD']
            self.assertFalse(is_documentation_building())

        finally:
            if os.environ.get('READTHEDOCS'):
                del os.environ['READTHEDOCS']

            if os.environ.get('COLOUR_SCIENCE_DOCUMENTATION_BUILD'):
                del os.environ['COLOUR_SCIENCE_DOCUMENTATION_BUILD']
    def test_is_documentation_building(self):
        """
        Test :func:`colour.utilities.documentation.is_documentation_building`
        definition.
        """

        try:
            self.assertFalse(is_documentation_building())

            os.environ["READTHEDOCS"] = "True"
            self.assertTrue(is_documentation_building())

            os.environ["READTHEDOCS"] = "False"
            self.assertTrue(is_documentation_building())

            del os.environ["READTHEDOCS"]
            self.assertFalse(is_documentation_building())

            os.environ["COLOUR_SCIENCE__DOCUMENTATION_BUILD"] = "True"
            self.assertTrue(is_documentation_building())

            os.environ["COLOUR_SCIENCE__DOCUMENTATION_BUILD"] = "False"
            self.assertTrue(is_documentation_building())

            del os.environ["COLOUR_SCIENCE__DOCUMENTATION_BUILD"]
            self.assertFalse(is_documentation_building())

        finally:  # pragma: no cover
            if os.environ.get("READTHEDOCS"):
                del os.environ["READTHEDOCS"]

            if os.environ.get("COLOUR_SCIENCE__DOCUMENTATION_BUILD"):
                del os.environ["COLOUR_SCIENCE__DOCUMENTATION_BUILD"]
示例#4
0
    def __repr__(self) -> str:
        """
        Return an evaluable string representation of the continuous signal.

        Returns
        -------
        :class:`str`
            Evaluable string representation.

        Examples
        --------
        >>> range_ = np.linspace(10, 100, 10)
        >>> Signal(range_)  # doctest: +ELLIPSIS
        Signal([[   0.,   10.],
                [   1.,   20.],
                [   2.,   30.],
                [   3.,   40.],
                [   4.,   50.],
                [   5.,   60.],
                [   6.,   70.],
                [   7.,   80.],
                [   8.,   90.],
                [   9.,  100.]],
               interpolator=KernelInterpolator,
               interpolator_kwargs={},
               extrapolator=Extrapolator,
               extrapolator_kwargs={...})
        """

        if is_documentation_building():  # pragma: no cover
            return f"{self.__class__.__name__}(name='{self.name}', ...)"

        try:
            representation = repr(tstack([self.domain, self.range]))
            representation = representation.replace(
                "array", self.__class__.__name__
            )
            representation = representation.replace(
                "       [",
                f"{' ' * (len(self.__class__.__name__) + 2)}[",
            )
            indentation = " " * (len(self.__class__.__name__) + 1)
            representation = (
                f"{representation[:-1]},\n"
                f"{indentation}interpolator={self.interpolator.__name__},\n"
                f"{indentation}interpolator_kwargs="
                f"{repr(self.interpolator_kwargs)},\n"
                f"{indentation}extrapolator={self.extrapolator.__name__},\n"
                f"{indentation}extrapolator_kwargs="
                f"{repr(self.extrapolator_kwargs)})"
            )

            return representation
        except TypeError:
            return super().__repr__()
示例#5
0
    def __repr__(self) -> str:
        """
        Return an evaluable string representation of the case-insensitive
        :class:`dict`-like object.

        Returns
        -------
        :class:`str`
            Evaluable string representation.
        """

        if is_documentation_building():  # pragma: no cover
            representation = repr(
                dict(zip(self.keys(), ["..."] * len(self)))
            ).replace("'...'", "...")
            return f"{self.__class__.__name__}({representation})"
        else:
            return f"{self.__class__.__name__}({dict(self.items())})"
示例#6
0
        'colour.models.oetf_BT2020',
        'colour.models.eotf_inverse_BT2020',
    ],
    [
        'colour.models.POINTER_GAMUT_BOUNDARIES',
        'colour.models.CCS_POINTER_GAMUT_BOUNDARY',
    ],
    [
        'colour.models.POINTER_GAMUT_DATA',
        'colour.models.DATA_POINTER_GAMUT_VOLUME',
    ],
    [
        'colour.models.POINTER_GAMUT_ILLUMINANT',
        'colour.models.CCS_ILLUMINANT_POINTER_GAMUT',
    ],
    [
        'colour.models.YCBCR_WEIGHTS',
        'colour.models.WEIGHTS_YCBCR',
    ],
    [
        'colour.models.RGB_to_RGB_matrix',
        'colour.models.matrix_RGB_to_RGB',
    ],
]

if not is_documentation_building():
    sys.modules['colour.models'] = models(sys.modules['colour.models'],
                                          build_API_changes(API_CHANGES))

    del ModuleAPI, is_documentation_building, build_API_changes, sys
示例#7
0
    "CIE UCS",
    "CIE UVW",
    "DIN99",
    "Hunter Lab",
    "Hunter Rdab",
    "ICaCb",
    "ICtCp",
    "IPT",
    "IgPgTg",
    "Jzazbz",
    "OSA UCS",
    "Oklab",
    "hdr-CIELAB",
    "hdr-IPT",
)
if is_documentation_building():  # pragma: no cover
    COLOURSPACE_MODELS = DocstringTuple(COLOURSPACE_MODELS)
    COLOURSPACE_MODELS.__doc__ = """
Colourspace models supporting a direct conversion to *CIE XYZ* tristimulus
values.
"""

COLOURSPACE_MODELS_AXIS_LABELS: CaseInsensitiveMapping = (
    CaseInsensitiveMapping({
        "CAM02LCD": ("$J^\\prime$", "$a^\\prime$", "$b^\\prime$"),
        "CAM02SCD": ("$J^\\prime$", "$a^\\prime$", "$b^\\prime$"),
        "CAM02UCS": ("$J^\\prime$", "$a^\\prime$", "$b^\\prime$"),
        "CAM16LCD": ("$J^\\prime$", "$a^\\prime$", "$b^\\prime$"),
        "CAM16SCD": ("$J^\\prime$", "$a^\\prime$", "$b^\\prime$"),
        "CAM16UCS": ("$J^\\prime$", "$a^\\prime$", "$b^\\prime$"),
        "CIE XYZ": ("X", "Y", "Z"),
示例#8
0
        'colour.plotting.plot_visible_spectrum'
    ],
]


def _setup_api_changes():
    """
    Setups *Colour* API changes.
    """

    global API_CHANGES

    for renamed in API_CHANGES['Renamed']:
        name, access = renamed
        API_CHANGES[name.split('.')[-1]] = Renamed(name, access)  # noqa
    API_CHANGES.pop('Renamed')


if not is_documentation_building():
    _setup_api_changes()

    del ModuleAPI
    del Renamed
    del is_documentation_building
    del _setup_api_changes

    sys.modules['colour.plotting'] = plotting(sys.modules['colour.plotting'],
                                              API_CHANGES)

    del sys