Coverage for colour/models/tests/test_cie_ucs.py: 100%

209 statements  

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

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

2 

3from __future__ import annotations 

4 

5from itertools import product 

6 

7import numpy as np 

8 

9from colour.constants import TOLERANCE_ABSOLUTE_TESTS 

10from colour.models import ( 

11 CIE1960UCS_to_XYZ, 

12 UCS_to_uv, 

13 UCS_to_XYZ, 

14 UCS_uv_to_xy, 

15 XYZ_to_CIE1960UCS, 

16 XYZ_to_UCS, 

17 uv_to_UCS, 

18 xy_to_UCS_uv, 

19) 

20from colour.utilities import domain_range_scale, ignore_numpy_errors 

21 

22__author__ = "Colour Developers" 

23__copyright__ = "Copyright 2013 Colour Developers" 

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

25__maintainer__ = "Colour Developers" 

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

27__status__ = "Production" 

28 

29__all__ = [ 

30 "TestXYZ_to_UCS", 

31 "TestUCS_to_XYZ", 

32 "TestUCS_to_uv", 

33 "Testuv_to_UCS", 

34 "TestUCS_uv_to_xy", 

35 "TestXy_to_UCS_uv", 

36 "TestXYZ_to_CIE1960UCS", 

37 "TestCIE1960UCS_to_XYZ", 

38] 

39 

40 

41class TestXYZ_to_UCS: 

42 """ 

43 Define :func:`colour.models.cie_ucs.XYZ_to_UCS` definition unit tests 

44 methods. 

45 """ 

46 

47 def test_XYZ_to_UCS(self) -> None: 

48 """Test :func:`colour.models.cie_ucs.XYZ_to_UCS` definition.""" 

49 

50 np.testing.assert_allclose( 

51 XYZ_to_UCS(np.array([0.20654008, 0.12197225, 0.05136952])), 

52 np.array([0.13769339, 0.12197225, 0.10537310]), 

53 atol=TOLERANCE_ABSOLUTE_TESTS, 

54 ) 

55 

56 np.testing.assert_allclose( 

57 XYZ_to_UCS(np.array([0.14222010, 0.23042768, 0.10495772])), 

58 np.array([0.09481340, 0.23042768, 0.32701033]), 

59 atol=TOLERANCE_ABSOLUTE_TESTS, 

60 ) 

61 

62 np.testing.assert_allclose( 

63 XYZ_to_UCS(np.array([0.07818780, 0.06157201, 0.28099326])), 

64 np.array([0.05212520, 0.06157201, 0.19376075]), 

65 atol=TOLERANCE_ABSOLUTE_TESTS, 

66 ) 

67 

68 def test_n_dimensional_XYZ_to_UCS(self) -> None: 

69 """ 

70 Test :func:`colour.models.cie_ucs.XYZ_to_UCS` definition n-dimensional 

71 support. 

72 """ 

73 

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

75 UCS = XYZ_to_UCS(XYZ) 

76 

77 UCS = np.tile(UCS, (6, 1)) 

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

79 np.testing.assert_allclose(XYZ_to_UCS(XYZ), UCS, atol=TOLERANCE_ABSOLUTE_TESTS) 

80 

81 UCS = np.reshape(UCS, (2, 3, 3)) 

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

83 np.testing.assert_allclose(XYZ_to_UCS(XYZ), UCS, atol=TOLERANCE_ABSOLUTE_TESTS) 

84 

85 def test_domain_range_scale_XYZ_to_UCS(self) -> None: 

86 """ 

87 Test :func:`colour.models.cie_ucs.XYZ_to_UCS` definition domain and 

88 range scale support. 

89 """ 

90 

91 XYZ = np.array([0.0704953400, 0.1008000000, 0.0955831300]) 

92 UCS = XYZ_to_UCS(XYZ) 

93 

94 d_r = (("reference", 1), ("1", 1), ("100", 100)) 

95 for scale, factor in d_r: 

96 with domain_range_scale(scale): 

97 np.testing.assert_allclose( 

98 XYZ_to_UCS(XYZ * factor), 

99 UCS * factor, 

100 atol=TOLERANCE_ABSOLUTE_TESTS, 

101 ) 

102 

103 @ignore_numpy_errors 

104 def test_nan_XYZ_to_UCS(self) -> None: 

105 """Test :func:`colour.models.cie_ucs.XYZ_to_UCS` definition nan support.""" 

106 

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

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

109 XYZ_to_UCS(cases) 

110 

111 

112class TestUCS_to_XYZ: 

113 """ 

114 Define :func:`colour.models.cie_ucs.UCS_to_XYZ` definition unit tests 

115 methods. 

116 """ 

117 

118 def test_UCS_to_XYZ(self) -> None: 

119 """Test :func:`colour.models.cie_ucs.UCS_to_XYZ` definition.""" 

120 

121 np.testing.assert_allclose( 

122 UCS_to_XYZ(np.array([0.13769339, 0.12197225, 0.10537310])), 

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

124 atol=TOLERANCE_ABSOLUTE_TESTS, 

125 ) 

126 

127 np.testing.assert_allclose( 

128 UCS_to_XYZ(np.array([0.09481340, 0.23042768, 0.32701033])), 

129 np.array([0.14222010, 0.23042768, 0.10495772]), 

130 atol=TOLERANCE_ABSOLUTE_TESTS, 

131 ) 

132 

133 np.testing.assert_allclose( 

134 UCS_to_XYZ(np.array([0.05212520, 0.06157201, 0.19376075])), 

135 np.array([0.07818780, 0.06157201, 0.28099326]), 

136 atol=TOLERANCE_ABSOLUTE_TESTS, 

137 ) 

138 

139 def test_n_dimensional_UCS_to_XYZ(self) -> None: 

140 """ 

141 Test :func:`colour.models.cie_ucs.UCS_to_XYZ` definition n-dimensional 

142 support. 

143 """ 

144 

145 UCS = np.array([0.13769339, 0.12197225, 0.10537310]) 

146 XYZ = UCS_to_XYZ(UCS) 

147 

148 UCS = np.tile(UCS, (6, 1)) 

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

150 np.testing.assert_allclose(UCS_to_XYZ(UCS), XYZ, atol=TOLERANCE_ABSOLUTE_TESTS) 

151 

152 UCS = np.reshape(UCS, (2, 3, 3)) 

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

154 np.testing.assert_allclose(UCS_to_XYZ(UCS), XYZ, atol=TOLERANCE_ABSOLUTE_TESTS) 

155 

156 def test_domain_range_scale_UCS_to_XYZ(self) -> None: 

157 """ 

158 Test :func:`colour.models.cie_ucs.UCS_to_XYZ` definition domain and 

159 range scale support. 

160 """ 

161 

162 UCS = np.array([0.0469968933, 0.1008000000, 0.1637438950]) 

163 XYZ = UCS_to_XYZ(UCS) 

164 

165 d_r = (("reference", 1), ("1", 1), ("100", 100)) 

166 for scale, factor in d_r: 

167 with domain_range_scale(scale): 

168 np.testing.assert_allclose( 

169 UCS_to_XYZ(UCS * factor), 

170 XYZ * factor, 

171 atol=TOLERANCE_ABSOLUTE_TESTS, 

172 ) 

173 

174 @ignore_numpy_errors 

175 def test_nan_UCS_to_XYZ(self) -> None: 

176 """Test :func:`colour.models.cie_ucs.UCS_to_XYZ` definition nan support.""" 

177 

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

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

180 UCS_to_XYZ(cases) 

181 

182 

183class TestUCS_to_uv: 

184 """ 

185 Define :func:`colour.models.cie_ucs.UCS_to_uv` definition unit tests 

186 methods. 

187 """ 

188 

189 def test_UCS_to_uv(self) -> None: 

190 """Test :func:`colour.models.cie_ucs.UCS_to_uv` definition.""" 

191 

192 np.testing.assert_allclose( 

193 UCS_to_uv(np.array([0.13769339, 0.12197225, 0.10537310])), 

194 np.array([0.37720213, 0.33413508]), 

195 atol=TOLERANCE_ABSOLUTE_TESTS, 

196 ) 

197 

198 np.testing.assert_allclose( 

199 UCS_to_uv(np.array([0.09481340, 0.23042768, 0.32701033])), 

200 np.array([0.14536327, 0.35328046]), 

201 atol=TOLERANCE_ABSOLUTE_TESTS, 

202 ) 

203 

204 np.testing.assert_allclose( 

205 UCS_to_uv(np.array([0.05212520, 0.06157201, 0.19376075])), 

206 np.array([0.16953602, 0.20026156]), 

207 atol=TOLERANCE_ABSOLUTE_TESTS, 

208 ) 

209 

210 def test_n_dimensional_UCS_to_uv(self) -> None: 

211 """ 

212 Test :func:`colour.models.cie_ucs.UCS_to_uv` definition n-dimensional 

213 support. 

214 """ 

215 

216 UCS = np.array([0.13769339, 0.12197225, 0.10537310]) 

217 uv = UCS_to_uv(UCS) 

218 

219 UCS = np.tile(UCS, (6, 1)) 

220 uv = np.tile(uv, (6, 1)) 

221 np.testing.assert_allclose(UCS_to_uv(UCS), uv, atol=TOLERANCE_ABSOLUTE_TESTS) 

222 

223 UCS = np.reshape(UCS, (2, 3, 3)) 

224 uv = np.reshape(uv, (2, 3, 2)) 

225 np.testing.assert_allclose(UCS_to_uv(UCS), uv, atol=TOLERANCE_ABSOLUTE_TESTS) 

226 

227 def test_domain_range_scale_UCS_to_uv(self) -> None: 

228 """ 

229 Test :func:`colour.models.cie_ucs.UCS_to_uv` definition domain and 

230 range scale support. 

231 """ 

232 

233 UCS = np.array([0.0469968933, 0.1008000000, 0.1637438950]) 

234 uv = UCS_to_uv(UCS) 

235 

236 d_r = (("reference", 1), ("1", 1), ("100", 100)) 

237 for scale, factor in d_r: 

238 with domain_range_scale(scale): 

239 np.testing.assert_allclose( 

240 UCS_to_uv(UCS * factor), uv, atol=TOLERANCE_ABSOLUTE_TESTS 

241 ) 

242 

243 @ignore_numpy_errors 

244 def test_nan_UCS_to_uv(self) -> None: 

245 """Test :func:`colour.models.cie_ucs.UCS_to_uv` definition nan support.""" 

246 

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

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

249 UCS_to_uv(cases) 

250 

251 

252class Testuv_to_UCS: 

253 """ 

254 Define :func:`colour.models.cie_ucs.uv_to_UCS` definition unit tests 

255 methods. 

256 """ 

257 

258 def test_uv_to_UCS(self) -> None: 

259 """Test :func:`colour.models.cie_ucs.uv_to_UCS` definition.""" 

260 

261 np.testing.assert_allclose( 

262 uv_to_UCS(np.array([0.37720213, 0.33413508])), 

263 np.array([1.12889114, 1.00000000, 0.86391046]), 

264 atol=TOLERANCE_ABSOLUTE_TESTS, 

265 ) 

266 

267 np.testing.assert_allclose( 

268 uv_to_UCS(np.array([0.14536327, 0.35328046])), 

269 np.array([0.41146705, 1.00000000, 1.41914520]), 

270 atol=TOLERANCE_ABSOLUTE_TESTS, 

271 ) 

272 

273 np.testing.assert_allclose( 

274 uv_to_UCS(np.array([0.16953602, 0.20026156])), 

275 np.array([0.84657295, 1.00000000, 3.14689659]), 

276 atol=TOLERANCE_ABSOLUTE_TESTS, 

277 ) 

278 

279 np.testing.assert_allclose( 

280 uv_to_UCS(np.array([0.37720213, 0.33413508]), V=0.18), 

281 np.array([0.20320040, 0.18000000, 0.15550388]), 

282 atol=TOLERANCE_ABSOLUTE_TESTS, 

283 ) 

284 

285 def test_n_dimensional_uv_to_UCS(self) -> None: 

286 """ 

287 Test :func:`colour.models.cie_ucs.uv_to_UCS` definition n-dimensional 

288 support. 

289 """ 

290 

291 uv = np.array([0.37720213, 0.33413508]) 

292 UCS = uv_to_UCS(uv) 

293 

294 uv = np.tile(uv, (6, 1)) 

295 UCS = np.tile(UCS, (6, 1)) 

296 np.testing.assert_allclose(uv_to_UCS(uv), UCS, atol=TOLERANCE_ABSOLUTE_TESTS) 

297 

298 uv = np.reshape(uv, (2, 3, 2)) 

299 UCS = np.reshape(UCS, (2, 3, 3)) 

300 np.testing.assert_allclose(uv_to_UCS(uv), UCS, atol=TOLERANCE_ABSOLUTE_TESTS) 

301 

302 def test_domain_range_scale_uv_to_UCS(self) -> None: 

303 """ 

304 Test :func:`colour.models.cie_ucs.uv_to_UCS` definition domain and 

305 range scale support. 

306 """ 

307 

308 uv = np.array([0.37720213, 0.33413508]) 

309 V = 1 

310 UCS = uv_to_UCS(uv, V) 

311 

312 d_r = (("reference", 1), ("1", 1), ("100", 100)) 

313 for scale, factor in d_r: 

314 with domain_range_scale(scale): 

315 np.testing.assert_allclose( 

316 uv_to_UCS(uv, V * factor), 

317 UCS * factor, 

318 atol=TOLERANCE_ABSOLUTE_TESTS, 

319 ) 

320 

321 @ignore_numpy_errors 

322 def test_nan_uv_to_UCS(self) -> None: 

323 """Test :func:`colour.models.cie_ucs.uv_to_UCS` definition nan support.""" 

324 

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

326 cases = np.array(list(set(product(cases, repeat=2)))) 

327 uv_to_UCS(cases) 

328 

329 

330class TestUCS_uv_to_xy: 

331 """ 

332 Define :func:`colour.models.cie_ucs.UCS_uv_to_xy` definition unit tests 

333 methods. 

334 """ 

335 

336 def test_UCS_uv_to_xy(self) -> None: 

337 """Test :func:`colour.models.cie_ucs.UCS_uv_to_xy` definition.""" 

338 

339 np.testing.assert_allclose( 

340 UCS_uv_to_xy(np.array([0.37720213, 0.33413508])), 

341 np.array([0.54369555, 0.32107941]), 

342 atol=TOLERANCE_ABSOLUTE_TESTS, 

343 ) 

344 

345 np.testing.assert_allclose( 

346 UCS_uv_to_xy(np.array([0.14536327, 0.35328046])), 

347 np.array([0.29777734, 0.48246445]), 

348 atol=TOLERANCE_ABSOLUTE_TESTS, 

349 ) 

350 

351 np.testing.assert_allclose( 

352 UCS_uv_to_xy(np.array([0.16953602, 0.20026156])), 

353 np.array([0.18582823, 0.14633764]), 

354 atol=TOLERANCE_ABSOLUTE_TESTS, 

355 ) 

356 

357 def test_n_dimensional_UCS_uv_to_xy(self) -> None: 

358 """ 

359 Test :func:`colour.models.cie_ucs.UCS_uv_to_xy` definition 

360 n-dimensional arrays support. 

361 """ 

362 

363 uv = np.array([0.37720213, 0.33413508]) 

364 xy = UCS_uv_to_xy(uv) 

365 

366 uv = np.tile(uv, (6, 1)) 

367 xy = np.tile(xy, (6, 1)) 

368 np.testing.assert_allclose(UCS_uv_to_xy(uv), xy, atol=TOLERANCE_ABSOLUTE_TESTS) 

369 

370 uv = np.reshape(uv, (2, 3, 2)) 

371 xy = np.reshape(xy, (2, 3, 2)) 

372 np.testing.assert_allclose(UCS_uv_to_xy(uv), xy, atol=TOLERANCE_ABSOLUTE_TESTS) 

373 

374 @ignore_numpy_errors 

375 def test_nan_UCS_uv_to_xy(self) -> None: 

376 """ 

377 Test :func:`colour.models.cie_ucs.UCS_uv_to_xy` definition nan 

378 support. 

379 """ 

380 

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

382 cases = np.array(list(set(product(cases, repeat=2)))) 

383 UCS_uv_to_xy(cases) 

384 

385 

386class TestXy_to_UCS_uv: 

387 """ 

388 Define :func:`colour.models.cie_ucs.xy_to_UCS_uv` definition unit tests 

389 methods. 

390 """ 

391 

392 def test_xy_to_UCS_uv(self) -> None: 

393 """Test :func:`colour.models.cie_ucs.xy_to_UCS_uv` definition.""" 

394 

395 np.testing.assert_allclose( 

396 xy_to_UCS_uv(np.array([0.54369555, 0.32107941])), 

397 np.array([0.37720213, 0.33413508]), 

398 atol=TOLERANCE_ABSOLUTE_TESTS, 

399 ) 

400 

401 np.testing.assert_allclose( 

402 xy_to_UCS_uv(np.array([0.29777734, 0.48246445])), 

403 np.array([0.14536327, 0.35328046]), 

404 atol=TOLERANCE_ABSOLUTE_TESTS, 

405 ) 

406 

407 np.testing.assert_allclose( 

408 xy_to_UCS_uv(np.array([0.18582823, 0.14633764])), 

409 np.array([0.16953602, 0.20026156]), 

410 atol=TOLERANCE_ABSOLUTE_TESTS, 

411 ) 

412 

413 def test_n_dimensional_xy_to_UCS_uv(self) -> None: 

414 """ 

415 Test :func:`colour.models.cie_ucs.xy_to_UCS_uv` definition 

416 n-dimensional arrays support. 

417 """ 

418 

419 xy = np.array([0.54369555, 0.32107941]) 

420 uv = xy_to_UCS_uv(xy) 

421 

422 xy = np.tile(xy, (6, 1)) 

423 uv = np.tile(uv, (6, 1)) 

424 np.testing.assert_allclose(xy_to_UCS_uv(xy), uv, atol=TOLERANCE_ABSOLUTE_TESTS) 

425 

426 xy = np.reshape(xy, (2, 3, 2)) 

427 uv = np.reshape(uv, (2, 3, 2)) 

428 np.testing.assert_allclose(xy_to_UCS_uv(xy), uv, atol=TOLERANCE_ABSOLUTE_TESTS) 

429 

430 @ignore_numpy_errors 

431 def test_nan_xy_to_UCS_uv(self) -> None: 

432 """ 

433 Test :func:`colour.models.cie_ucs.xy_to_UCS_uv` definition nan 

434 support. 

435 """ 

436 

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

438 cases = np.array(list(set(product(cases, repeat=2)))) 

439 xy_to_UCS_uv(cases) 

440 

441 

442class TestXYZ_to_CIE1960UCS: 

443 """ 

444 Define :func:`colour.models.cie_ucs.XYZ_to_CIE1960UCS` definition unit tests 

445 methods. 

446 """ 

447 

448 def test_XYZ_to_CIE1960UCS(self) -> None: 

449 """Test :func:`colour.models.cie_ucs.XYZ_to_CIE1960UCS` definition.""" 

450 

451 np.testing.assert_allclose( 

452 XYZ_to_CIE1960UCS(np.array([0.20654008, 0.12197225, 0.05136952])), 

453 np.array([0.37720213, 0.33413509, 0.12197225]), 

454 atol=TOLERANCE_ABSOLUTE_TESTS, 

455 ) 

456 

457 np.testing.assert_allclose( 

458 XYZ_to_CIE1960UCS(np.array([0.14222010, 0.23042768, 0.10495772])), 

459 np.array([0.14536327, 0.35328046, 0.23042768]), 

460 atol=TOLERANCE_ABSOLUTE_TESTS, 

461 ) 

462 

463 np.testing.assert_allclose( 

464 XYZ_to_CIE1960UCS(np.array([0.07818780, 0.06157201, 0.28099326])), 

465 np.array([0.16953603, 0.20026156, 0.06157201]), 

466 atol=TOLERANCE_ABSOLUTE_TESTS, 

467 ) 

468 

469 def test_n_dimensional_XYZ_to_CIE1960UCS(self) -> None: 

470 """ 

471 Test :func:`colour.models.cie_ucs.XYZ_to_CIE1960UCS` definition n-dimensional 

472 support. 

473 """ 

474 

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

476 uvV = XYZ_to_CIE1960UCS(XYZ) 

477 

478 uvV = np.tile(uvV, (6, 1)) 

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

480 np.testing.assert_allclose( 

481 XYZ_to_CIE1960UCS(XYZ), uvV, atol=TOLERANCE_ABSOLUTE_TESTS 

482 ) 

483 

484 uvV = np.reshape(uvV, (2, 3, 3)) 

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

486 np.testing.assert_allclose( 

487 XYZ_to_CIE1960UCS(XYZ), uvV, atol=TOLERANCE_ABSOLUTE_TESTS 

488 ) 

489 

490 def test_domain_range_scale_XYZ_to_CIE1960UCS(self) -> None: 

491 """ 

492 Test :func:`colour.models.cie_ucs.XYZ_to_CIE1960UCS` definition domain and 

493 range scale support. 

494 """ 

495 

496 XYZ = np.array([0.0704953400, 0.1008000000, 0.0955831300]) 

497 uvV = XYZ_to_CIE1960UCS(XYZ) 

498 

499 d_r = (("reference", 1, 1), ("1", 1, 1), ("100", 100, np.array([1, 1, 100]))) 

500 for scale, factor_a, factor_b in d_r: 

501 with domain_range_scale(scale): 

502 np.testing.assert_allclose( 

503 XYZ_to_CIE1960UCS(XYZ * factor_a), 

504 uvV * factor_b, 

505 atol=TOLERANCE_ABSOLUTE_TESTS, 

506 ) 

507 

508 @ignore_numpy_errors 

509 def test_nan_XYZ_to_CIE1960UCS(self) -> None: 

510 """ 

511 Test :func:`colour.models.cie_ucs.XYZ_to_CIE1960UCS` definition nan 

512 support. 

513 """ 

514 

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

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

517 XYZ_to_CIE1960UCS(cases) 

518 

519 

520class TestCIE1960UCS_to_XYZ: 

521 """ 

522 Define :func:`colour.models.cie_ucs.CIE1960UCS_to_XYZ` definition unit tests 

523 methods. 

524 """ 

525 

526 def test_CIE1960UCS_to_XYZ(self) -> None: 

527 """Test :func:`colour.models.cie_ucs.CIE1960UCS_to_XYZ` definition.""" 

528 

529 np.testing.assert_allclose( 

530 CIE1960UCS_to_XYZ(np.array([0.37720213, 0.33413509, 0.12197225])), 

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

532 atol=TOLERANCE_ABSOLUTE_TESTS, 

533 ) 

534 

535 np.testing.assert_allclose( 

536 CIE1960UCS_to_XYZ(np.array([0.14536327, 0.35328046, 0.23042768])), 

537 np.array([0.14222010, 0.23042768, 0.10495772]), 

538 atol=TOLERANCE_ABSOLUTE_TESTS, 

539 ) 

540 

541 np.testing.assert_allclose( 

542 CIE1960UCS_to_XYZ(np.array([0.16953603, 0.20026156, 0.06157201])), 

543 np.array([0.07818780, 0.06157201, 0.28099326]), 

544 atol=TOLERANCE_ABSOLUTE_TESTS, 

545 ) 

546 

547 def test_n_dimensional_CIE1960UCS_to_XYZ(self) -> None: 

548 """ 

549 Test :func:`colour.models.cie_ucs.CIE1960UCS_to_XYZ` definition n-dimensional 

550 support. 

551 """ 

552 

553 uvV = np.array([0.37720213, 0.33413509, 0.12197225]) 

554 XYZ = CIE1960UCS_to_XYZ(uvV) 

555 

556 uvV = np.tile(uvV, (6, 1)) 

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

558 np.testing.assert_allclose( 

559 CIE1960UCS_to_XYZ(uvV), XYZ, atol=TOLERANCE_ABSOLUTE_TESTS 

560 ) 

561 

562 uvV = np.reshape(uvV, (2, 3, 3)) 

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

564 np.testing.assert_allclose( 

565 CIE1960UCS_to_XYZ(uvV), XYZ, atol=TOLERANCE_ABSOLUTE_TESTS 

566 ) 

567 

568 def test_domain_range_scale_CIE1960UCS_to_XYZ(self) -> None: 

569 """ 

570 Test :func:`colour.models.cie_ucs.CIE1960UCS_to_XYZ` definition domain and 

571 range scale support. 

572 """ 

573 

574 uvV = np.array([0.0469968933, 0.1008000000, 0.1637438950]) 

575 XYZ = CIE1960UCS_to_XYZ(uvV) 

576 

577 d_r = (("reference", 1, 1), ("1", 1, 1), ("100", np.array([1, 1, 100]), 100)) 

578 for scale, factor_a, factor_b in d_r: 

579 with domain_range_scale(scale): 

580 np.testing.assert_allclose( 

581 CIE1960UCS_to_XYZ(uvV * factor_a), 

582 XYZ * factor_b, 

583 atol=TOLERANCE_ABSOLUTE_TESTS, 

584 ) 

585 

586 @ignore_numpy_errors 

587 def test_nan_CIE1960UCS_to_XYZ(self) -> None: 

588 """ 

589 Test :func:`colour.models.cie_ucs.CIE1960UCS_to_XYZ` definition nan 

590 support. 

591 """ 

592 

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

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

595 CIE1960UCS_to_XYZ(cases)