Coverage for colour/utilities/__init__.py: 100%

29 statements  

« prev     ^ index     » next       coverage.py v7.11.0, created at 2025-11-15 19:01 +1300

1from __future__ import annotations 

2 

3import sys 

4import typing 

5 

6if typing.TYPE_CHECKING: 

7 from colour.hints import Any 

8 

9from .verbose import ( 

10 ANCILLARY_COLOUR_SCIENCE_PACKAGES, 

11 ANCILLARY_DEVELOPMENT_PACKAGES, 

12 ANCILLARY_EXTRAS_PACKAGES, 

13 ANCILLARY_RUNTIME_PACKAGES, 

14 ColourRuntimeWarning, 

15 ColourUsageWarning, 

16 ColourWarning, 

17 MixinLogging, 

18 as_bool, 

19 describe_environment, 

20 filter_warnings, 

21 message_box, 

22 multiline_repr, 

23 multiline_str, 

24 numpy_print_options, 

25 runtime_warning, 

26 show_warning, 

27 suppress_stdout, 

28 suppress_warnings, 

29 usage_warning, 

30 warning, 

31) 

32 

33# isort: split 

34 

35from .structures import ( 

36 CanonicalMapping, 

37 LazyCanonicalMapping, 

38 Lookup, 

39 Structure, 

40) 

41 

42# isort: split 

43 

44from .requirements import ( 

45 is_ctlrender_installed, 

46 is_imageio_installed, 

47 is_matplotlib_installed, 

48 is_networkx_installed, 

49 is_opencolorio_installed, 

50 is_openimageio_installed, 

51 is_pandas_installed, 

52 is_pydot_installed, 

53 is_scipy_installed, 

54 is_tqdm_installed, 

55 is_trimesh_installed, 

56 is_xxhash_installed, 

57 required, 

58) 

59 

60# isort: split 

61 

62from .callback import ( 

63 Callback, 

64 MixinCallback, 

65) 

66from .common import ( 

67 CACHE_REGISTRY, 

68 CacheRegistry, 

69 attest, 

70 batch, 

71 caching_enable, 

72 copy_definition, 

73 disable_multiprocessing, 

74 filter_kwargs, 

75 filter_mapping, 

76 first_item, 

77 handle_numpy_errors, 

78 ignore_numpy_errors, 

79 ignore_python_warnings, 

80 int_digest, 

81 is_caching_enabled, 

82 is_integer, 

83 is_iterable, 

84 is_numeric, 

85 is_sibling, 

86 multiprocessing_pool, 

87 optional, 

88 print_numpy_errors, 

89 raise_numpy_errors, 

90 set_caching_enable, 

91 slugify, 

92 validate_method, 

93 warn_numpy_errors, 

94) 

95 

96# isort: split 

97 

98from .array import ( 

99 MixinDataclassArithmetic, 

100 MixinDataclassArray, 

101 MixinDataclassFields, 

102 MixinDataclassIterable, 

103 as_array, 

104 as_complex_array, 

105 as_float, 

106 as_float_array, 

107 as_float_scalar, 

108 as_int, 

109 as_int_array, 

110 as_int_scalar, 

111 centroid, 

112 closest, 

113 closest_indexes, 

114 domain_range_scale, 

115 fill_nan, 

116 format_array_as_row, 

117 from_range_1, 

118 from_range_10, 

119 from_range_100, 

120 from_range_degrees, 

121 from_range_int, 

122 full, 

123 get_domain_range_scale, 

124 get_domain_range_scale_metadata, 

125 has_only_nan, 

126 in_array, 

127 index_along_last_axis, 

128 interval, 

129 is_ndarray_copy_enabled, 

130 is_uniform, 

131 ndarray_copy, 

132 ndarray_copy_enable, 

133 ndarray_write, 

134 ones, 

135 orient, 

136 row_as_diagonal, 

137 set_default_float_dtype, 

138 set_default_int_dtype, 

139 set_domain_range_scale, 

140 set_ndarray_copy_enable, 

141 to_domain_1, 

142 to_domain_10, 

143 to_domain_100, 

144 to_domain_degrees, 

145 to_domain_int, 

146 tsplit, 

147 tstack, 

148 zeros, 

149) 

150from .metrics import metric_mse, metric_psnr 

151from .network import ( 

152 ControlFlowNode, 

153 ExecutionNode, 

154 ExecutionPort, 

155 For, 

156 ParallelForMultiprocess, 

157 ParallelForThread, 

158 Port, 

159 PortGraph, 

160 PortNode, 

161 TreeNode, 

162) 

163 

164# isort: split 

165 

166from colour.utilities.deprecation import ModuleAPI, build_API_changes 

167from colour.utilities.documentation import is_documentation_building 

168 

169__all__ = [ 

170 "ANCILLARY_COLOUR_SCIENCE_PACKAGES", 

171 "ANCILLARY_DEVELOPMENT_PACKAGES", 

172 "ANCILLARY_EXTRAS_PACKAGES", 

173 "ANCILLARY_RUNTIME_PACKAGES", 

174 "ColourRuntimeWarning", 

175 "ColourUsageWarning", 

176 "ColourWarning", 

177 "MixinLogging", 

178 "as_bool", 

179 "describe_environment", 

180 "filter_warnings", 

181 "message_box", 

182 "multiline_repr", 

183 "multiline_str", 

184 "numpy_print_options", 

185 "runtime_warning", 

186 "show_warning", 

187 "suppress_stdout", 

188 "suppress_warnings", 

189 "usage_warning", 

190 "warning", 

191] 

192__all__ += [ 

193 "CanonicalMapping", 

194 "LazyCanonicalMapping", 

195 "Lookup", 

196 "Structure", 

197] 

198__all__ += [ 

199 "is_ctlrender_installed", 

200 "is_imageio_installed", 

201 "is_matplotlib_installed", 

202 "is_networkx_installed", 

203 "is_opencolorio_installed", 

204 "is_openimageio_installed", 

205 "is_pandas_installed", 

206 "is_pydot_installed", 

207 "is_scipy_installed", 

208 "is_tqdm_installed", 

209 "is_trimesh_installed", 

210 "is_xxhash_installed", 

211 "required", 

212] 

213__all__ += [ 

214 "Callback", 

215 "MixinCallback", 

216] 

217__all__ += [ 

218 "CACHE_REGISTRY", 

219 "CacheRegistry", 

220 "attest", 

221 "batch", 

222 "caching_enable", 

223 "copy_definition", 

224 "disable_multiprocessing", 

225 "filter_kwargs", 

226 "filter_mapping", 

227 "first_item", 

228 "handle_numpy_errors", 

229 "ignore_numpy_errors", 

230 "ignore_python_warnings", 

231 "int_digest", 

232 "is_caching_enabled", 

233 "is_integer", 

234 "is_iterable", 

235 "is_numeric", 

236 "is_sibling", 

237 "multiprocessing_pool", 

238 "optional", 

239 "print_numpy_errors", 

240 "raise_numpy_errors", 

241 "set_caching_enable", 

242 "slugify", 

243 "validate_method", 

244 "warn_numpy_errors", 

245] 

246__all__ += [ 

247 "MixinDataclassArithmetic", 

248 "MixinDataclassArray", 

249 "MixinDataclassFields", 

250 "MixinDataclassIterable", 

251 "as_array", 

252 "as_complex_array", 

253 "as_float", 

254 "as_float_array", 

255 "as_float_scalar", 

256 "as_int", 

257 "as_int_array", 

258 "as_int_scalar", 

259 "centroid", 

260 "closest", 

261 "closest_indexes", 

262 "domain_range_scale", 

263 "fill_nan", 

264 "format_array_as_row", 

265 "from_range_1", 

266 "from_range_10", 

267 "from_range_100", 

268 "from_range_degrees", 

269 "from_range_int", 

270 "full", 

271 "get_domain_range_scale", 

272 "get_domain_range_scale_metadata", 

273 "has_only_nan", 

274 "in_array", 

275 "index_along_last_axis", 

276 "interval", 

277 "is_ndarray_copy_enabled", 

278 "is_uniform", 

279 "ndarray_copy", 

280 "ndarray_copy_enable", 

281 "ndarray_write", 

282 "ones", 

283 "orient", 

284 "row_as_diagonal", 

285 "set_default_float_dtype", 

286 "set_default_int_dtype", 

287 "set_domain_range_scale", 

288 "set_ndarray_copy_enable", 

289 "to_domain_1", 

290 "to_domain_10", 

291 "to_domain_100", 

292 "to_domain_degrees", 

293 "to_domain_int", 

294 "tsplit", 

295 "tstack", 

296 "zeros", 

297] 

298__all__ += [ 

299 "metric_mse", 

300 "metric_psnr", 

301] 

302__all__ += [ 

303 "ControlFlowNode", 

304 "ExecutionNode", 

305 "ExecutionPort", 

306 "For", 

307 "ParallelForMultiprocess", 

308 "ParallelForThread", 

309 "Port", 

310 "PortGraph", 

311 "PortNode", 

312 "TreeNode", 

313] 

314 

315 

316# ----------------------------------------------------------------------------# 

317# --- API Changes and Deprecation Management ---# 

318# ----------------------------------------------------------------------------# 

319class utilities(ModuleAPI): 

320 """Define a class acting like the *utilities* module.""" 

321 

322 def __getattr__(self, attribute: str) -> Any: 

323 """Return the value from the specified attribute.""" 

324 

325 return super().__getattr__(attribute) 

326 

327 

328# v0.4.5 

329API_CHANGES: dict = { 

330 "ObjectRemoved": [ 

331 "colour.utilities.is_string", 

332 ] 

333} 

334""" 

335Define the *colour.utilities* sub-package API changes. 

336 

337API_CHANGES 

338""" 

339 

340if not is_documentation_building(): 

341 sys.modules["colour.utilities"] = utilities( # pyright: ignore 

342 sys.modules["colour.utilities"], build_API_changes(API_CHANGES) 

343 ) 

344 

345 del ModuleAPI, is_documentation_building, build_API_changes, sys