Skip to content

Commit

Permalink
Merge branch 'feature/v0.4.4' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
KelSolaar committed Oct 29, 2023
2 parents 8981236 + b04ed33 commit 00ff2ba
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 255 deletions.
20 changes: 1 addition & 19 deletions colour/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@

import numpy as np

from colour.utilities import is_matplotlib_installed
from colour import plotting # noqa: F401

from .adaptation import (
CHROMATIC_ADAPTATION_METHODS,
Expand Down Expand Up @@ -453,24 +453,6 @@
is_within_visible_spectrum,
)

# Exposing "colour.plotting" sub-package if "Matplotlib" is available.
if is_matplotlib_installed():
import colour.plotting as plotting # noqa: F401, PLR0402
else:

class MockPlotting: # pragma: no cover
"""
Mock object for :mod:`colour.plotting` sub-package raising an exception
if the sub-package is accessed but *Matplotlib* is not installed.
"""

def __getattr__(self, attribute) -> Any:
"""Return the value from the attribute with given name."""

is_matplotlib_installed(raise_exception=True)

globals()["plotting"] = MockPlotting() # pragma: no cover

__author__ = "Colour Developers"
__copyright__ = "Copyright 2013 Colour Developers"
__license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause"
Expand Down
62 changes: 44 additions & 18 deletions colour/plotting/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,36 @@
from colour.utilities import is_matplotlib_installed

is_matplotlib_installed(raise_exception=True)
if not is_matplotlib_installed():
import sys
from unittest.mock import MagicMock
from colour.utilities import usage_warning

from .datasets import * # noqa: E402, F403
from . import datasets # noqa: E402
from .common import ( # noqa: E402
try:
is_matplotlib_installed(raise_exception=True)
except ImportError as error:
usage_warning(str(error))

for module in (
"matplotlib",
"matplotlib.axes",
"matplotlib.cm",
"matplotlib.collections",
"matplotlib.colors",
"matplotlib.figure",
"matplotlib.patches",
"matplotlib.path",
"matplotlib.pyplot",
"matplotlib.ticker",
"mpl_toolkits",
"mpl_toolkits.mplot3d",
"mpl_toolkits.mplot3d.art3d",
"mpl_toolkits.mplot3d.axes3d",
):
sys.modules[module] = MagicMock()

from .datasets import * # noqa: F403
from . import datasets
from .common import (
CONSTANTS_COLOUR_STYLE,
CONSTANTS_ARROW_STYLE,
colour_style,
Expand All @@ -29,8 +55,8 @@
plot_multi_functions,
plot_image,
)
from .blindness import plot_cvd_simulation_Machado2009 # noqa: E402
from .colorimetry import ( # noqa: E402
from .blindness import plot_cvd_simulation_Machado2009
from .colorimetry import (
plot_single_sd,
plot_multi_sds,
plot_single_cmfs,
Expand All @@ -45,11 +71,11 @@
plot_blackbody_spectral_radiance,
plot_blackbody_colours,
)
from .characterisation import ( # noqa: E402
from .characterisation import (
plot_single_colour_checker,
plot_multi_colour_checkers,
)
from .diagrams import ( # noqa: E402
from .diagrams import (
METHODS_CHROMATICITY_DIAGRAM,
LABELS_CHROMATICITY_DIAGRAM_DEFAULT,
lines_spectral_locus,
Expand All @@ -60,11 +86,11 @@
plot_sds_in_chromaticity_diagram_CIE1960UCS,
plot_sds_in_chromaticity_diagram_CIE1976UCS,
)
from .corresponding import ( # noqa: E402
from .corresponding import (
plot_corresponding_chromaticities_prediction,
) # noqa: RUF100
from .graph import plot_automatic_colour_conversion_graph # noqa: E402
from .models import ( # noqa: E402
from .graph import plot_automatic_colour_conversion_graph
from .models import (
colourspace_model_axis_reorder,
lines_pointer_gamut,
plot_pointer_gamut,
Expand All @@ -81,31 +107,31 @@
plot_multi_cctfs,
plot_constant_hue_loci,
)
from .notation import ( # noqa: E402
from .notation import (
plot_single_munsell_value_function,
plot_multi_munsell_value_functions,
)
from .phenomena import ( # noqa: E402
from .phenomena import (
plot_single_sd_rayleigh_scattering,
plot_the_blue_sky,
)
from .quality import ( # noqa: E402
from .quality import (
plot_single_sd_colour_rendering_index_bars,
plot_multi_sds_colour_rendering_indexes_bars,
plot_single_sd_colour_quality_scale_bars,
plot_multi_sds_colour_quality_scales_bars,
)
from .section import ( # noqa: E402
from .section import (
plot_visible_spectrum_section,
plot_RGB_colourspace_section,
)
from .temperature import ( # noqa: E402
from .temperature import (
plot_planckian_locus_in_chromaticity_diagram_CIE1931,
plot_planckian_locus_in_chromaticity_diagram_CIE1960UCS,
plot_planckian_locus_in_chromaticity_diagram_CIE1976UCS,
)
from .tm3018 import plot_single_sd_colour_rendition_report # noqa: E402
from .volume import ( # noqa: E402
from .tm3018 import plot_single_sd_colour_rendition_report
from .volume import (
plot_RGB_colourspaces_gamuts,
plot_RGB_scatter,
) # noqa: RUF100
Expand Down
Loading

0 comments on commit 00ff2ba

Please sign in to comment.