File tree Expand file tree Collapse file tree 9 files changed +98
-3
lines changed
Expand file tree Collapse file tree 9 files changed +98
-3
lines changed Original file line number Diff line number Diff line change 8484
8585__major_version__ = "0"
8686__minor_version__ = "2"
87- __change_version__ = "2 "
87+ __change_version__ = "3 "
8888__version__ = f"{ __major_version__ } .{ __minor_version__ } .{ __change_version__ } "
8989
9090try :
Original file line number Diff line number Diff line change 3434from colour .utilities import (
3535 Structure ,
3636 optional ,
37+ required ,
3738 usage_warning ,
3839)
3940from colour .utilities .documentation import (
4243)
4344from scipy .optimize import linear_sum_assignment
4445from scipy .spatial import distance_matrix
45- from sklearn .cluster import DBSCAN
4646
4747from colour_checker_detection .detection .common import (
4848 DTYPE_FLOAT_DEFAULT ,
@@ -159,6 +159,7 @@ def segmenter_templated(
159159) -> NDArrayInt : ...
160160
161161
162+ @required ("scikit-learn" ) # pyright: ignore
162163def segmenter_templated (
163164 image : ArrayLike ,
164165 cctf_encoding : Callable = eotf_inverse_sRGB ,
@@ -296,6 +297,9 @@ def segmenter_templated(
296297 [1086, 244],
297298 [1069, 715]]], dtype=int32)
298299 """
300+
301+ from sklearn .cluster import DBSCAN # noqa: PLC0415
302+
299303 settings = Structure (** SETTINGS_TEMPLATED_COLORCHECKER_CLASSIC )
300304 settings .update (** kwargs )
301305
Original file line number Diff line number Diff line change 1+ from .requirements import is_sklearn_installed
2+
3+ __all__ = [
4+ "is_sklearn_installed" ,
5+ ]
Original file line number Diff line number Diff line change 1+ """
2+ Requirements Utilities
3+ ======================
4+
5+ Define the requirements utilities objects.
6+ """
7+
8+ from __future__ import annotations
9+
10+ import colour .utilities
11+
12+ __author__ = "Colour Developers"
13+ __copyright__ = "Copyright 2018 Colour Developers"
14+ __license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause"
15+ __maintainer__ = "Colour Developers"
16+ 17+ __status__ = "Production"
18+
19+ __all__ = [
20+ "is_sklearn_installed" ,
21+ ]
22+
23+
24+ def is_sklearn_installed (raise_exception : bool = False ) -> bool :
25+ """
26+ Return whether *scikit-learn* is installed and available.
27+
28+ Parameters
29+ ----------
30+ raise_exception
31+ Whether to raise an exception if *scikit-learn* is unavailable.
32+
33+ Returns
34+ -------
35+ :class:`bool`
36+ Whether *scikit-learn* is installed.
37+
38+ Raises
39+ ------
40+ :class:`ImportError`
41+ If *scikit-learn* is not installed.
42+ """
43+
44+ try : # pragma: no cover
45+ import sklearn # noqa: F401, PLC0415
46+ except ImportError as exception : # pragma: no cover
47+ if raise_exception :
48+ error = (
49+ f'"scikit-learn" related API features are not available: "{ exception } ".'
50+ )
51+
52+ raise ImportError (error ) from exception
53+
54+ return False
55+ else :
56+ return True
57+
58+
59+ colour .utilities .requirements .REQUIREMENTS_TO_CALLABLE .update (
60+ {
61+ "scikit-learn" : is_sklearn_installed ,
62+ }
63+ )
Original file line number Diff line number Diff line change @@ -5,3 +5,4 @@ Colour - Checker Detection
55 :maxdepth: 3
66
77 colour_checker_detection.detection
8+ colour_checker_detection.utilities
Original file line number Diff line number Diff line change 1+ Utilities
2+ =========
3+
4+ Requirements
5+ ------------
6+
7+ ``colour_checker_detection.utilities ``
8+
9+ .. currentmodule :: colour_checker_detection.utilities
10+
11+ .. autosummary ::
12+ :toctree: generated/
13+
14+ is_sklearn_installed
Original file line number Diff line number Diff line change @@ -43,6 +43,8 @@ fsspec==2025.12.0 ; python_full_version < '3.14'
4343 # via torch
4444idna == 3.11
4545 # via requests
46+ imageio == 2.37.2
47+ # via colour-checker-detection
4648imagesize == 1.4.1
4749 # via sphinx
4850jinja2 == 3.1.6
@@ -70,6 +72,7 @@ numpy==2.3.5
7072 # colour-checker-detection
7173 # colour-science
7274 # contourpy
75+ # imageio
7376 # matplotlib
7477 # opencv-python
7578 # openimageio
@@ -129,6 +132,7 @@ packaging==25.0
129132 # sphinx
130133pillow == 12.0.0
131134 # via
135+ # imageio
132136 # matplotlib
133137 # torchvision
134138 # ultralytics
Original file line number Diff line number Diff line change 11[project ]
22name = " colour-checker-detection"
3- version = " 0.2.2 "
3+ version = " 0.2.3 "
44description = " Colour checker detection with Python"
55readme = " README.rst"
66requires-python = " >=3.11,<3.15"
Original file line number Diff line number Diff line change @@ -137,6 +137,8 @@ idna==3.11
137137 # hyperlink
138138 # jsonschema
139139 # requests
140+ imageio == 2.37.2
141+ # via colour-checker-detection
140142imagesize == 1.4.1
141143 # via sphinx
142144importlib-metadata == 8.7.0 ; python_full_version < '3.12'
@@ -301,6 +303,7 @@ numpy==2.3.5
301303 # colour-checker-detection
302304 # colour-science
303305 # contourpy
306+ # imageio
304307 # matplotlib
305308 # numpy-typing-compat
306309 # opencv-python
@@ -388,6 +391,7 @@ pexpect==4.9.0
388391 # ipython
389392pillow == 12.0.0
390393 # via
394+ # imageio
391395 # matplotlib
392396 # torchvision
393397 # ultralytics
You can’t perform that action at this time.
0 commit comments