Coverage for models/tests/test_cam02_ucs.py: 100%

1"""Define the unit tests for the :mod:`colour.models.cam02_ucs` module."""

2

3 from __future__ import annotations

4

5 from itertools import product

6

7 import numpy as np

8

9 from colour.appearance import (

10 VIEWING_CONDITIONS_CIECAM02,

11 CAM_KWARGS_CIECAM02_sRGB,

12 XYZ_to_CIECAM02,

13)

14 from colour.constants import TOLERANCE_ABSOLUTE_TESTS

15 from colour.models import (

16 CAM02LCD_to_JMh_CIECAM02,

17 CAM02LCD_to_XYZ,

18 CAM02SCD_to_JMh_CIECAM02,

19 CAM02SCD_to_XYZ,

20 CAM02UCS_to_JMh_CIECAM02,

21 CAM02UCS_to_XYZ,

22 JMh_CIECAM02_to_CAM02LCD,

23 JMh_CIECAM02_to_CAM02SCD,

24 JMh_CIECAM02_to_CAM02UCS,

25 XYZ_to_CAM02LCD,

26 XYZ_to_CAM02SCD,

27 XYZ_to_CAM02UCS,

28)

29 from colour.models.cam02_ucs import (

30 COEFFICIENTS_UCS_LUO2006,

31 JMh_CIECAM02_to_UCS_Luo2006,

32 UCS_Luo2006_to_JMh_CIECAM02,

33 UCS_Luo2006_to_XYZ,

34 XYZ_to_UCS_Luo2006,

35)

36 from colour.utilities import attest, domain_range_scale, ignore_numpy_errors

37

38 __author__ = "Colour Developers"

39 __copyright__ = "Copyright 2013 Colour Developers"

40 __license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause"

41 __maintainer__ = "Colour Developers"

42 __email__ = "colour-developers@colour-science.org"

43 __status__ = "Production"

44

45 __all__ = [

46 "TestJMh_CIECAM02_to_UCS_Luo2006",

47 "TestUCS_Luo2006_to_JMh_CIECAM02",

48 "TestXYZ_to_UCS_Luo2006",

49 "TestUCS_Luo2006_to_XYZ",

50]

51

52

53 class TestJMh_CIECAM02_to_UCS_Luo2006:

54 """

55 Define :func:`colour.models.cam02_ucs.JMh_CIECAM02_to_UCS_Luo2006`

56 definition unit tests methods.

57 """

58

59 def setup_method(self) -> None:

60 """Initialise the common tests attributes."""

61

62 XYZ = np.array([19.01, 20.00, 21.78])

63 XYZ_w = np.array([95.05, 100.00, 108.88])

64 L_A = 318.31

65 Y_b = 20.0

66 surround = VIEWING_CONDITIONS_CIECAM02["Average"]

67 specification = XYZ_to_CIECAM02(XYZ, XYZ_w, L_A, Y_b, surround)

68

69 self._JMh = np.array([specification.J, specification.M, specification.h])

70

71 def test_JMh_CIECAM02_to_UCS_Luo2006(self) -> None:

72 """

73 Test :func:`colour.models.cam02_ucs.JMh_CIECAM02_to_UCS_Luo2006`

74 definition.

75 """

76

77 np.testing.assert_allclose(

78 JMh_CIECAM02_to_UCS_Luo2006(

79 self._JMh, COEFFICIENTS_UCS_LUO2006["CAM02-LCD"]

80 ),

81 np.array([54.90433134, -0.08450395, -0.06854831]),

82 atol=TOLERANCE_ABSOLUTE_TESTS,

83 )

84

85 np.testing.assert_allclose(

86 JMh_CIECAM02_to_UCS_Luo2006(

87 self._JMh, COEFFICIENTS_UCS_LUO2006["CAM02-LCD"]

88 ),

89 JMh_CIECAM02_to_CAM02LCD(self._JMh),

90 atol=TOLERANCE_ABSOLUTE_TESTS,

91 )

92

93 np.testing.assert_allclose(

94 JMh_CIECAM02_to_UCS_Luo2006(

95 self._JMh, COEFFICIENTS_UCS_LUO2006["CAM02-SCD"]

96 ),

97 np.array([54.90433134, -0.08436178, -0.06843298]),

98 atol=TOLERANCE_ABSOLUTE_TESTS,

99 )

100

101 np.testing.assert_allclose(

102 JMh_CIECAM02_to_UCS_Luo2006(

103 self._JMh, COEFFICIENTS_UCS_LUO2006["CAM02-SCD"]

104 ),

105 JMh_CIECAM02_to_CAM02SCD(self._JMh),

106 atol=TOLERANCE_ABSOLUTE_TESTS,

107 )

108

109 np.testing.assert_allclose(

110 JMh_CIECAM02_to_UCS_Luo2006(

111 self._JMh, COEFFICIENTS_UCS_LUO2006["CAM02-UCS"]

112 ),

113 np.array([54.90433134, -0.08442362, -0.06848314]),

114 atol=TOLERANCE_ABSOLUTE_TESTS,

115 )

116

117 np.testing.assert_allclose(

118 JMh_CIECAM02_to_UCS_Luo2006(

119 self._JMh, COEFFICIENTS_UCS_LUO2006["CAM02-UCS"]

120 ),

121 JMh_CIECAM02_to_CAM02UCS(self._JMh),

122 atol=TOLERANCE_ABSOLUTE_TESTS,

123 )

124

125 def test_n_dimensional_JMh_CIECAM02_to_UCS_Luo2006(self) -> None:

126 """

127 Test :func:`colour.models.cam02_ucs.JMh_CIECAM02_to_UCS_Luo2006`

128 definition n-dimensional support.

129 """

130

131 JMh = self._JMh

132 Jpapbp = JMh_CIECAM02_to_UCS_Luo2006(JMh, COEFFICIENTS_UCS_LUO2006["CAM02-LCD"])

133

134 JMh = np.tile(JMh, (6, 1))

135 Jpapbp = np.tile(Jpapbp, (6, 1))

136 np.testing.assert_allclose(

137 JMh_CIECAM02_to_UCS_Luo2006(JMh, COEFFICIENTS_UCS_LUO2006["CAM02-LCD"]),

138 Jpapbp,

139 atol=TOLERANCE_ABSOLUTE_TESTS,

140 )

141

142 JMh = np.reshape(JMh, (2, 3, 3))

143 Jpapbp = np.reshape(Jpapbp, (2, 3, 3))

144 np.testing.assert_allclose(

145 JMh_CIECAM02_to_UCS_Luo2006(JMh, COEFFICIENTS_UCS_LUO2006["CAM02-LCD"]),

146 Jpapbp,

147 atol=TOLERANCE_ABSOLUTE_TESTS,

148 )

149

150 def test_domain_range_scale_JMh_CIECAM02_to_UCS_Luo2006(self) -> None:

151 """

152 Test :func:`colour.models.cam02_ucs.JMh_CIECAM02_to_UCS_Luo2006`

153 definition domain and range scale support.

154 """

155

156 JMh = self._JMh

157 Jpapbp = JMh_CIECAM02_to_UCS_Luo2006(JMh, COEFFICIENTS_UCS_LUO2006["CAM02-LCD"])

158

159 d_r = (

160 ("reference", 1, 1),

161 ("1", np.array([0.01, 0.01, 1 / 360]), 0.01),

162 ("100", np.array([1, 1, 1 / 3.6]), 1),

163 )

164 for scale, factor_a, factor_b in d_r:

165 with domain_range_scale(scale):

166 np.testing.assert_allclose(

167 JMh_CIECAM02_to_UCS_Luo2006(

168 JMh * factor_a, COEFFICIENTS_UCS_LUO2006["CAM02-LCD"]

169 ),

170 Jpapbp * factor_b,

171 atol=TOLERANCE_ABSOLUTE_TESTS,

172 )

173

174 @ignore_numpy_errors

175 def test_nan_JMh_CIECAM02_to_UCS_Luo2006(self) -> None:

176 """

177 Test :func:`colour.models.cam02_ucs.JMh_CIECAM02_to_UCS_Luo2006`

178 definition nan support.

179 """

180

181 cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan]

182 cases = np.array(list(set(product(cases, repeat=3))))

183 JMh_CIECAM02_to_UCS_Luo2006(cases, COEFFICIENTS_UCS_LUO2006["CAM02-LCD"])

184

185

186 class TestUCS_Luo2006_to_JMh_CIECAM02:

187 """

188 Define :func:`colour.models.cam02_ucs.UCS_Luo2006_to_JMh_CIECAM02`

189 definition unit tests methods.

190 """

191

192 def test_UCS_Luo2006_to_JMh_CIECAM02(self) -> None:

193 """

194 Test :func:`colour.models.cam02_ucs.UCS_Luo2006_to_JMh_CIECAM02`

195 definition.

196 """

197

198 np.testing.assert_allclose(

199 UCS_Luo2006_to_JMh_CIECAM02(

200 np.array([54.90433134, -0.08442362, -0.06848314]),

201 COEFFICIENTS_UCS_LUO2006["CAM02-LCD"],

202 ),

203 np.array([41.73109113, 0.10873867, 219.04843202]),

204 atol=TOLERANCE_ABSOLUTE_TESTS,

205 )

206

207 np.testing.assert_allclose(

208 UCS_Luo2006_to_JMh_CIECAM02(

209 np.array([54.90433134, -0.08442362, -0.06848314]),

210 COEFFICIENTS_UCS_LUO2006["CAM02-LCD"],

211 ),

212 CAM02LCD_to_JMh_CIECAM02(np.array([54.90433134, -0.08442362, -0.06848314])),

213 atol=TOLERANCE_ABSOLUTE_TESTS,

214 )

215

216 np.testing.assert_allclose(

217 UCS_Luo2006_to_JMh_CIECAM02(

218 np.array([54.90433134, -0.08442362, -0.06848314]),

219 COEFFICIENTS_UCS_LUO2006["CAM02-SCD"],

220 ),

221 np.array([41.73109113, 0.10892212, 219.04843202]),

222 atol=TOLERANCE_ABSOLUTE_TESTS,

223 )

224

225 np.testing.assert_allclose(

226 UCS_Luo2006_to_JMh_CIECAM02(

227 np.array([54.90433134, -0.08442362, -0.06848314]),

228 COEFFICIENTS_UCS_LUO2006["CAM02-SCD"],

229 ),

230 CAM02SCD_to_JMh_CIECAM02(np.array([54.90433134, -0.08442362, -0.06848314])),

231 atol=TOLERANCE_ABSOLUTE_TESTS,

232 )

233

234 np.testing.assert_allclose(

235 UCS_Luo2006_to_JMh_CIECAM02(

236 np.array([54.90433134, -0.08442362, -0.06848314]),

237 COEFFICIENTS_UCS_LUO2006["CAM02-UCS"],

238 ),

239 np.array([41.73109113, 0.10884218, 219.04843202]),

240 atol=TOLERANCE_ABSOLUTE_TESTS,

241 )

242

243 np.testing.assert_allclose(

244 UCS_Luo2006_to_JMh_CIECAM02(

245 np.array([54.90433134, -0.08442362, -0.06848314]),

246 COEFFICIENTS_UCS_LUO2006["CAM02-UCS"],

247 ),

248 CAM02UCS_to_JMh_CIECAM02(np.array([54.90433134, -0.08442362, -0.06848314])),

249 atol=TOLERANCE_ABSOLUTE_TESTS,

250 )

251

252 def test_n_dimensional_UCS_Luo2006_to_JMh_CIECAM02(self) -> None:

253 """

254 Test :func:`colour.models.cam02_ucs.UCS_Luo2006_to_JMh_CIECAM02`

255 definition n-dimensional support.

256 """

257

258 Jpapbp = np.array([54.90433134, -0.08442362, -0.06848314])

259 JMh = UCS_Luo2006_to_JMh_CIECAM02(Jpapbp, COEFFICIENTS_UCS_LUO2006["CAM02-LCD"])

260

261 Jpapbp = np.tile(Jpapbp, (6, 1))

262 JMh = np.tile(JMh, (6, 1))

263 np.testing.assert_allclose(

264 UCS_Luo2006_to_JMh_CIECAM02(Jpapbp, COEFFICIENTS_UCS_LUO2006["CAM02-LCD"]),

265 JMh,

266 atol=TOLERANCE_ABSOLUTE_TESTS,

267 )

268

269 Jpapbp = np.reshape(Jpapbp, (2, 3, 3))

270 JMh = np.reshape(JMh, (2, 3, 3))

271 np.testing.assert_allclose(

272 UCS_Luo2006_to_JMh_CIECAM02(Jpapbp, COEFFICIENTS_UCS_LUO2006["CAM02-LCD"]),

273 JMh,

274 atol=TOLERANCE_ABSOLUTE_TESTS,

275 )

276

277 def test_domain_range_scale_UCS_Luo2006_to_JMh_CIECAM02(self) -> None:

278 """

279 Test :func:`colour.models.cam02_ucs.UCS_Luo2006_to_JMh_CIECAM02`

280 definition domain and range scale support.

281 """

282

283 Jpapbp = np.array([54.90433134, -0.08442362, -0.06848314])

284 JMh = UCS_Luo2006_to_JMh_CIECAM02(Jpapbp, COEFFICIENTS_UCS_LUO2006["CAM02-LCD"])

285

286 d_r = (

287 ("reference", 1, 1),

288 ("1", 0.01, np.array([0.01, 0.01, 1 / 360])),

289 ("100", 1, np.array([1, 1, 1 / 3.6])),

290 )

291 for scale, factor_a, factor_b in d_r:

292 with domain_range_scale(scale):

293 np.testing.assert_allclose(

294 UCS_Luo2006_to_JMh_CIECAM02(

295 Jpapbp * factor_a,

296 COEFFICIENTS_UCS_LUO2006["CAM02-LCD"],

297 ),

298 JMh * factor_b,

299 atol=TOLERANCE_ABSOLUTE_TESTS,

300 )

301

302 @ignore_numpy_errors

303 def test_nan_UCS_Luo2006_to_JMh_CIECAM02(self) -> None:

304 """

305 Test :func:`colour.models.cam02_ucs.UCS_Luo2006_to_JMh_CIECAM02`

306 definition nan support.

307 """

308

309 cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan]

310 cases = np.array(list(set(product(cases, repeat=3))))

311 UCS_Luo2006_to_JMh_CIECAM02(cases, COEFFICIENTS_UCS_LUO2006["CAM02-LCD"])

312

313

314 class TestXYZ_to_UCS_Luo2006:

315 """

316 Define :func:`colour.models.cam02_ucs.XYZ_to_UCS_Luo2006` definition

317 unit tests methods.

318 """

319

320 def test_XYZ_to_UCS_Luo2006(self) -> None:

321 """Test :func:`colour.models.cam02_ucs.XYZ_to_UCS_Luo2006` definition."""

322

323 np.testing.assert_allclose(

324 XYZ_to_UCS_Luo2006(

325 np.array([0.20654008, 0.12197225, 0.05136952]),

326 COEFFICIENTS_UCS_LUO2006["CAM02-LCD"],

327 ),

328 np.array([46.61386154, 39.35760236, 15.96730435]),

329 atol=TOLERANCE_ABSOLUTE_TESTS,

330 )

331

332 np.testing.assert_allclose(

333 XYZ_to_UCS_Luo2006(

334 np.array([0.20654008, 0.12197225, 0.05136952]),

335 COEFFICIENTS_UCS_LUO2006["CAM02-LCD"],

336 ),

337 XYZ_to_CAM02LCD(np.array([0.20654008, 0.12197225, 0.05136952])),

338 atol=TOLERANCE_ABSOLUTE_TESTS,

339 )

340

341 np.testing.assert_allclose(

342 XYZ_to_UCS_Luo2006(

343 np.array([0.20654008, 0.12197225, 0.05136952]),

344 COEFFICIENTS_UCS_LUO2006["CAM02-SCD"],

345 ),

346 np.array([46.61386154, 25.62879882, 10.39755489]),

347 atol=TOLERANCE_ABSOLUTE_TESTS,

348 )

349

350 np.testing.assert_allclose(

351 XYZ_to_UCS_Luo2006(

352 np.array([0.20654008, 0.12197225, 0.05136952]),

353 COEFFICIENTS_UCS_LUO2006["CAM02-SCD"],

354 ),

355 XYZ_to_CAM02SCD(np.array([0.20654008, 0.12197225, 0.05136952])),

356 atol=TOLERANCE_ABSOLUTE_TESTS,

357 )

358

359 np.testing.assert_allclose(

360 XYZ_to_UCS_Luo2006(

361 np.array([0.20654008, 0.12197225, 0.05136952]),

362 COEFFICIENTS_UCS_LUO2006["CAM02-UCS"],

363 ),

364 np.array([46.61386154, 29.88310013, 12.12351683]),

365 atol=TOLERANCE_ABSOLUTE_TESTS,

366 )

367

368 np.testing.assert_allclose(

369 XYZ_to_UCS_Luo2006(

370 np.array([0.20654008, 0.12197225, 0.05136952]),

371 COEFFICIENTS_UCS_LUO2006["CAM02-UCS"],

372 ),

373 XYZ_to_CAM02UCS(np.array([0.20654008, 0.12197225, 0.05136952])),

374 atol=TOLERANCE_ABSOLUTE_TESTS,

375 )

376

377 def test_n_dimensional_XYZ_to_UCS_Luo2006(self) -> None:

378 """

379 Test :func:`colour.models.cam02_ucs.XYZ_to_UCS_Luo2006` definition

380 n-dimensional support.

381 """

382

383 XYZ = np.array([0.20654008, 0.12197225, 0.05136952])

384 Jpapbp = XYZ_to_UCS_Luo2006(XYZ, COEFFICIENTS_UCS_LUO2006["CAM02-LCD"])

385

386 XYZ = np.tile(XYZ, (6, 1))

387 Jpapbp = np.tile(Jpapbp, (6, 1))

388 np.testing.assert_allclose(

389 XYZ_to_UCS_Luo2006(XYZ, COEFFICIENTS_UCS_LUO2006["CAM02-LCD"]),

390 Jpapbp,

391 atol=TOLERANCE_ABSOLUTE_TESTS,

392 )

393

394 XYZ = np.reshape(XYZ, (2, 3, 3))

395 Jpapbp = np.reshape(Jpapbp, (2, 3, 3))

396 np.testing.assert_allclose(

397 XYZ_to_UCS_Luo2006(XYZ, COEFFICIENTS_UCS_LUO2006["CAM02-LCD"]),

398 Jpapbp,

399 atol=TOLERANCE_ABSOLUTE_TESTS,

400 )

401

402 def test_domain_range_scale_XYZ_to_UCS_Luo2006(self) -> None:

403 """

404 Test :func:`colour.models.cam02_ucs.XYZ_to_UCS_Luo2006` definition

405 domain and range scale support.

406 """

407

408 XYZ = np.array([0.20654008, 0.12197225, 0.05136952])

409 XYZ_w = CAM_KWARGS_CIECAM02_sRGB["XYZ_w"] / 100

410 Jpapbp = XYZ_to_UCS_Luo2006(XYZ, COEFFICIENTS_UCS_LUO2006["CAM02-LCD"])

411

412 d_r = (("reference", 1, 1), ("1", 1, 0.01), ("100", 100, 1))

413 for scale, factor_a, factor_b in d_r:

414 with domain_range_scale(scale):

415 np.testing.assert_allclose(

416 XYZ_to_UCS_Luo2006(

417 XYZ * factor_a,

418 COEFFICIENTS_UCS_LUO2006["CAM02-LCD"],

419 XYZ_w=XYZ_w * factor_a,

420 ),

421 Jpapbp * factor_b,

422 atol=TOLERANCE_ABSOLUTE_TESTS,

423 )

424

425 @ignore_numpy_errors

426 def test_nan_XYZ_to_UCS_Luo2006(self) -> None:

427 """

428 Test :func:`colour.models.cam02_ucs.XYZ_to_UCS_Luo2006` definition nan

429 support.

430 """

431

432 cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan]

433 cases = np.array(list(set(product(cases, repeat=3))))

434 XYZ_to_UCS_Luo2006(cases, COEFFICIENTS_UCS_LUO2006["CAM02-LCD"])

435

436

437 class TestUCS_Luo2006_to_XYZ:

438 """

439 Define :func:`colour.models.cam02_ucs.UCS_Luo2006_to_XYZ` definition

440 unit tests methods.

441 """

442

443 def test_UCS_Luo2006_to_XYZ(self) -> None:

444 """Test :func:`colour.models.cam02_ucs.UCS_Luo2006_to_XYZ` definition."""

445

446 np.testing.assert_allclose(

447 UCS_Luo2006_to_XYZ(

448 np.array([46.61386154, 39.35760236, 15.96730435]),

449 COEFFICIENTS_UCS_LUO2006["CAM02-LCD"],

450 ),

451 np.array([0.20654008, 0.12197225, 0.05136952]),

452 atol=TOLERANCE_ABSOLUTE_TESTS,

453 )

454

455 np.testing.assert_allclose(

456 UCS_Luo2006_to_XYZ(

457 np.array([46.61386154, 39.35760236, 15.96730435]),

458 COEFFICIENTS_UCS_LUO2006["CAM02-LCD"],

459 ),

460 CAM02LCD_to_XYZ(np.array([46.61386154, 39.35760236, 15.96730435])),

461 atol=TOLERANCE_ABSOLUTE_TESTS,

462 )

463

464 np.testing.assert_allclose(

465 UCS_Luo2006_to_XYZ(

466 np.array([46.61386154, 39.35760236, 15.96730435]),

467 COEFFICIENTS_UCS_LUO2006["CAM02-SCD"],

468 ),

469 np.array([0.28264475, 0.11036927, 0.00824593]),

470 atol=TOLERANCE_ABSOLUTE_TESTS,

471 )

472

473 np.testing.assert_allclose(

474 UCS_Luo2006_to_XYZ(

475 np.array([46.61386154, 39.35760236, 15.96730435]),

476 COEFFICIENTS_UCS_LUO2006["CAM02-SCD"],

477 ),

478 CAM02SCD_to_XYZ(np.array([46.61386154, 39.35760236, 15.96730435])),

479 atol=TOLERANCE_ABSOLUTE_TESTS,

480 )

481

482 np.testing.assert_allclose(

483 UCS_Luo2006_to_XYZ(

484 np.array([46.61386154, 39.35760236, 15.96730435]),

485 COEFFICIENTS_UCS_LUO2006["CAM02-UCS"],

486 ),

487 np.array([0.24229809, 0.11573005, 0.02517649]),

488 atol=TOLERANCE_ABSOLUTE_TESTS,

489 )

490

491 np.testing.assert_allclose(

492 UCS_Luo2006_to_XYZ(

493 np.array([46.61386154, 39.35760236, 15.96730435]),

494 COEFFICIENTS_UCS_LUO2006["CAM02-UCS"],

495 ),

496 CAM02UCS_to_XYZ(np.array([46.61386154, 39.35760236, 15.96730435])),

497 atol=TOLERANCE_ABSOLUTE_TESTS,

498 )

499

500 def test_n_dimensional_UCS_Luo2006_to_XYZ(self) -> None:

501 """

502 Test :func:`colour.models.cam02_ucs.UCS_Luo2006_to_XYZ` definition

503 n-dimensional support.

504 """

505

506 Jpapbp = np.array([46.61386154, 39.35760236, 15.96730435])

507 XYZ = UCS_Luo2006_to_XYZ(Jpapbp, COEFFICIENTS_UCS_LUO2006["CAM02-LCD"])

508

509 Jpapbp = np.tile(Jpapbp, (6, 1))

510 XYZ = np.tile(XYZ, (6, 1))

511 np.testing.assert_allclose(

512 UCS_Luo2006_to_XYZ(Jpapbp, COEFFICIENTS_UCS_LUO2006["CAM02-LCD"]),

513 XYZ,

514 atol=TOLERANCE_ABSOLUTE_TESTS,

515 )

516

517 Jpapbp = np.reshape(Jpapbp, (2, 3, 3))

518 XYZ = np.reshape(XYZ, (2, 3, 3))

519 np.testing.assert_allclose(

520 UCS_Luo2006_to_XYZ(Jpapbp, COEFFICIENTS_UCS_LUO2006["CAM02-LCD"]),

521 XYZ,

522 atol=TOLERANCE_ABSOLUTE_TESTS,

523 )

524

525 def test_domain_range_scale_UCS_Luo2006_to_XYZ(self) -> None:

526 """

527 Test :func:`colour.models.cam02_ucs.UCS_Luo2006_to_XYZ` definition

528 domain and range scale support.

529 """

530

531 Jpapbp = np.array([46.61386154, 39.35760236, 15.96730435])

532 XYZ = UCS_Luo2006_to_XYZ(Jpapbp, COEFFICIENTS_UCS_LUO2006["CAM02-LCD"])

533 XYZ_w = CAM_KWARGS_CIECAM02_sRGB["XYZ_w"] / 100

534

535 d_r = (("reference", 1, 1, 1), ("1", 0.01, 1, 1), ("100", 1, 100, 100))

536 for scale, factor_a, factor_b, factor_c in d_r:

537 with domain_range_scale(scale):

538 np.testing.assert_allclose(

539 UCS_Luo2006_to_XYZ(

540 Jpapbp * factor_a,

541 COEFFICIENTS_UCS_LUO2006["CAM02-LCD"],

542 XYZ_w=XYZ_w * factor_c,

543 ),

544 XYZ * factor_b,

545 atol=TOLERANCE_ABSOLUTE_TESTS,

546 )

547

548 @ignore_numpy_errors

549 def test_nan_UCS_Luo2006_to_XYZ(self) -> None:

550 """

551 Test :func:`colour.models.cam02_ucs.UCS_Luo2006_to_XYZ` definition nan

552 support.

553 """

554

555 cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan]

556 cases = np.array(list(set(product(cases, repeat=3))))

557 for case in cases:

558 try:

559 UCS_Luo2006_to_XYZ(case, COEFFICIENTS_UCS_LUO2006["CAM02-LCD"])

560 except ValueError as error: # noqa: PERF203

561 attest("CAM_Specification_CIECAM02" in str(error))