Skip to content

Commit f0990c3

Browse files
committed
Merge branch 'feature/v0.2.3' into develop
2 parents 0a77148 + 6b252d7 commit f0990c3

File tree

9 files changed

+98
-3
lines changed

9 files changed

+98
-3
lines changed

colour_checker_detection/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
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

9090
try:

colour_checker_detection/detection/templated.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
from colour.utilities import (
3535
Structure,
3636
optional,
37+
required,
3738
usage_warning,
3839
)
3940
from colour.utilities.documentation import (
@@ -42,7 +43,6 @@
4243
)
4344
from scipy.optimize import linear_sum_assignment
4445
from scipy.spatial import distance_matrix
45-
from sklearn.cluster import DBSCAN
4646

4747
from 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
162163
def 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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from .requirements import is_sklearn_installed
2+
3+
__all__ = [
4+
"is_sklearn_installed",
5+
]
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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+
__email__ = "[email protected]"
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+
)

docs/colour_checker_detection.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ Colour - Checker Detection
55
:maxdepth: 3
66

77
colour_checker_detection.detection
8+
colour_checker_detection.utilities
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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

docs/requirements.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ fsspec==2025.12.0 ; python_full_version < '3.14'
4343
# via torch
4444
idna==3.11
4545
# via requests
46+
imageio==2.37.2
47+
# via colour-checker-detection
4648
imagesize==1.4.1
4749
# via sphinx
4850
jinja2==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
130133
pillow==12.0.0
131134
# via
135+
# imageio
132136
# matplotlib
133137
# torchvision
134138
# ultralytics

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "colour-checker-detection"
3-
version = "0.2.2"
3+
version = "0.2.3"
44
description = "Colour checker detection with Python"
55
readme = "README.rst"
66
requires-python = ">=3.11,<3.15"

requirements.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff 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
140142
imagesize==1.4.1
141143
# via sphinx
142144
importlib-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
389392
pillow==12.0.0
390393
# via
394+
# imageio
391395
# matplotlib
392396
# torchvision
393397
# ultralytics

0 commit comments

Comments
 (0)