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

190 statements  

« prev     ^ index     » next       coverage.py v7.11.0, created at 2025-11-16 22:49 +1300

1"""Define the unit tests for the :mod:`colour.models.cie_xyy` 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 XYZ_to_xy, 

12 XYZ_to_xyY, 

13 xy_to_xyY, 

14 xy_to_XYZ, 

15 xyY_to_xy, 

16 xyY_to_XYZ, 

17) 

18from colour.utilities import domain_range_scale, ignore_numpy_errors 

19 

20__author__ = "Colour Developers" 

21__copyright__ = "Copyright 2013 Colour Developers" 

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

23__maintainer__ = "Colour Developers" 

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

25__status__ = "Production" 

26 

27__all__ = [ 

28 "TestXYZ_to_xyY", 

29 "TestxyY_to_XYZ", 

30 "TestxyY_to_xy", 

31 "Testxy_to_xyY", 

32 "TestXYZ_to_xy", 

33 "Testxy_to_XYZ", 

34] 

35 

36 

37class TestXYZ_to_xyY: 

38 """ 

39 Define :func:`colour.models.cie_xyy.XYZ_to_xyY` definition unit tests 

40 methods. 

41 """ 

42 

43 def test_XYZ_to_xyY(self) -> None: 

44 """Test :func:`colour.models.cie_xyy.XYZ_to_xyY` definition.""" 

45 

46 np.testing.assert_allclose( 

47 XYZ_to_xyY(np.array([0.20654008, 0.12197225, 0.05136952])), 

48 np.array([0.54369557, 0.32107944, 0.12197225]), 

49 atol=TOLERANCE_ABSOLUTE_TESTS, 

50 ) 

51 

52 np.testing.assert_allclose( 

53 XYZ_to_xyY(np.array([0.14222010, 0.23042768, 0.10495772])), 

54 np.array([0.29777735, 0.48246446, 0.23042768]), 

55 atol=TOLERANCE_ABSOLUTE_TESTS, 

56 ) 

57 

58 np.testing.assert_allclose( 

59 XYZ_to_xyY(np.array([0.07818780, 0.06157201, 0.28099326])), 

60 np.array([0.18582823, 0.14633764, 0.06157201]), 

61 atol=TOLERANCE_ABSOLUTE_TESTS, 

62 ) 

63 

64 np.testing.assert_allclose( 

65 XYZ_to_xyY(np.array([0.00000000, 0.00000000, 1.00000000])), 

66 np.array([0.00000000, 0.00000000, 0.00000000]), 

67 atol=TOLERANCE_ABSOLUTE_TESTS, 

68 ) 

69 

70 np.testing.assert_allclose( 

71 XYZ_to_xyY( 

72 np.array( 

73 [ 

74 [0.20654008, 0.12197225, 0.05136952], 

75 [0.00000000, 0.00000000, 0.00000000], 

76 [0.00000000, 1.00000000, 0.00000000], 

77 ] 

78 ) 

79 ), 

80 np.array( 

81 [ 

82 [0.54369557, 0.32107944, 0.12197225], 

83 [0.00000000, 0.00000000, 0.00000000], 

84 [0.00000000, 1.00000000, 1.00000000], 

85 ] 

86 ), 

87 atol=TOLERANCE_ABSOLUTE_TESTS, 

88 ) 

89 

90 def test_n_dimensional_XYZ_to_xyY(self) -> None: 

91 """ 

92 Test :func:`colour.models.cie_xyy.XYZ_to_xyY` definition n-dimensional 

93 support. 

94 """ 

95 

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

97 xyY = XYZ_to_xyY(XYZ) 

98 

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

100 xyY = np.tile(xyY, (6, 1)) 

101 np.testing.assert_allclose(XYZ_to_xyY(XYZ), xyY, atol=TOLERANCE_ABSOLUTE_TESTS) 

102 

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

104 xyY = np.reshape(xyY, (2, 3, 3)) 

105 np.testing.assert_allclose(XYZ_to_xyY(XYZ), xyY, atol=TOLERANCE_ABSOLUTE_TESTS) 

106 

107 def test_domain_range_scale_XYZ_to_xyY(self) -> None: 

108 """ 

109 Test :func:`colour.models.cie_xyy.XYZ_to_xyY` definition domain and 

110 range scale support. 

111 """ 

112 

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

114 xyY = XYZ_to_xyY(XYZ) 

115 XYZ = np.reshape(np.tile(XYZ, (6, 1)), (2, 3, 3)) 

116 xyY = np.reshape(np.tile(xyY, (6, 1)), (2, 3, 3)) 

117 

118 d_r = ( 

119 ("reference", 1, 1), 

120 ("1", 1, 1), 

121 ("100", 100, np.array([1, 1, 100])), 

122 ) 

123 for scale, factor_a, factor_b in d_r: 

124 with domain_range_scale(scale): 

125 np.testing.assert_allclose( 

126 XYZ_to_xyY(XYZ * factor_a), 

127 xyY * factor_b, 

128 atol=TOLERANCE_ABSOLUTE_TESTS, 

129 ) 

130 

131 @ignore_numpy_errors 

132 def test_nan_XYZ_to_xyY(self) -> None: 

133 """Test :func:`colour.models.cie_xyy.XYZ_to_xyY` definition nan support.""" 

134 

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

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

137 XYZ_to_xyY(cases) 

138 

139 

140class TestxyY_to_XYZ: 

141 """ 

142 Define :func:`colour.models.cie_xyy.xyY_to_XYZ` definition unit tests 

143 methods. 

144 """ 

145 

146 def test_xyY_to_XYZ(self) -> None: 

147 """Test :func:`colour.models.cie_xyy.xyY_to_XYZ` definition.""" 

148 

149 np.testing.assert_allclose( 

150 xyY_to_XYZ(np.array([0.54369557, 0.32107944, 0.12197225])), 

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

152 atol=TOLERANCE_ABSOLUTE_TESTS, 

153 ) 

154 

155 np.testing.assert_allclose( 

156 xyY_to_XYZ(np.array([0.29777735, 0.48246446, 0.23042768])), 

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

158 atol=TOLERANCE_ABSOLUTE_TESTS, 

159 ) 

160 

161 np.testing.assert_allclose( 

162 xyY_to_XYZ(np.array([0.18582823, 0.14633764, 0.06157201])), 

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

164 atol=TOLERANCE_ABSOLUTE_TESTS, 

165 ) 

166 

167 np.testing.assert_allclose( 

168 xyY_to_XYZ(np.array([0.34567, 0.3585, 0.00000000])), 

169 np.array([0.00000000, 0.00000000, 0.00000000]), 

170 atol=TOLERANCE_ABSOLUTE_TESTS, 

171 ) 

172 

173 np.testing.assert_allclose( 

174 xyY_to_XYZ( 

175 np.array( 

176 [ 

177 [0.54369557, 0.32107944, 0.12197225], 

178 [0.31270000, 0.32900000, 0.00000000], 

179 [0.00000000, 1.00000000, 1.00000000], 

180 ] 

181 ) 

182 ), 

183 np.array( 

184 [ 

185 [0.20654008, 0.12197225, 0.05136952], 

186 [0.00000000, 0.00000000, 0.00000000], 

187 [0.00000000, 1.00000000, 0.00000000], 

188 ] 

189 ), 

190 atol=TOLERANCE_ABSOLUTE_TESTS, 

191 ) 

192 

193 def test_n_dimensional_xyY_to_XYZ(self) -> None: 

194 """ 

195 Test :func:`colour.models.cie_xyy.xyY_to_XYZ` definition n-dimensional 

196 support. 

197 """ 

198 

199 xyY = np.array([0.54369557, 0.32107944, 0.12197225]) 

200 XYZ = xyY_to_XYZ(xyY) 

201 

202 xyY = np.tile(xyY, (6, 1)) 

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

204 np.testing.assert_allclose(xyY_to_XYZ(xyY), XYZ, atol=TOLERANCE_ABSOLUTE_TESTS) 

205 

206 xyY = np.reshape(xyY, (2, 3, 3)) 

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

208 np.testing.assert_allclose(xyY_to_XYZ(xyY), XYZ, atol=TOLERANCE_ABSOLUTE_TESTS) 

209 

210 def test_domain_range_scale_xyY_to_XYZ(self) -> None: 

211 """ 

212 Test :func:`colour.models.cie_xyy.xyY_to_XYZ` definition domain and 

213 range scale support. 

214 """ 

215 

216 xyY = np.array([0.54369557, 0.32107944, 0.12197225]) 

217 XYZ = xyY_to_XYZ(xyY) 

218 xyY = np.reshape(np.tile(xyY, (6, 1)), (2, 3, 3)) 

219 XYZ = np.reshape(np.tile(XYZ, (6, 1)), (2, 3, 3)) 

220 

221 d_r = ( 

222 ("reference", 1, 1), 

223 ("1", 1, 1), 

224 ("100", np.array([1, 1, 100]), 100), 

225 ) 

226 for scale, factor_a, factor_b in d_r: 

227 with domain_range_scale(scale): 

228 np.testing.assert_allclose( 

229 xyY_to_XYZ(xyY * factor_a), 

230 XYZ * factor_b, 

231 atol=TOLERANCE_ABSOLUTE_TESTS, 

232 ) 

233 

234 @ignore_numpy_errors 

235 def test_nan_xyY_to_XYZ(self) -> None: 

236 """Test :func:`colour.models.cie_xyy.xyY_to_XYZ` definition nan support.""" 

237 

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

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

240 xyY_to_XYZ(cases) 

241 

242 

243class TestxyY_to_xy: 

244 """ 

245 Define :func:`colour.models.cie_xyy.xyY_to_xy` definition unit tests 

246 methods. 

247 """ 

248 

249 def test_xyY_to_xy(self) -> None: 

250 """Test :func:`colour.models.cie_xyy.xyY_to_xy` definition.""" 

251 

252 np.testing.assert_allclose( 

253 xyY_to_xy(np.array([0.54369557, 0.32107944, 0.12197225])), 

254 np.array([0.54369557, 0.32107944]), 

255 atol=TOLERANCE_ABSOLUTE_TESTS, 

256 ) 

257 

258 np.testing.assert_allclose( 

259 xyY_to_xy(np.array([0.29777735, 0.48246446, 0.23042768])), 

260 np.array([0.29777735, 0.48246446]), 

261 atol=TOLERANCE_ABSOLUTE_TESTS, 

262 ) 

263 

264 np.testing.assert_allclose( 

265 xyY_to_xy(np.array([0.18582823, 0.14633764, 0.06157201])), 

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

267 atol=TOLERANCE_ABSOLUTE_TESTS, 

268 ) 

269 

270 np.testing.assert_allclose( 

271 xyY_to_xy(np.array([0.31270, 0.32900])), 

272 np.array([0.31270000, 0.32900000]), 

273 atol=TOLERANCE_ABSOLUTE_TESTS, 

274 ) 

275 

276 def test_n_dimensional_xyY_to_xy(self) -> None: 

277 """ 

278 Test :func:`colour.models.cie_xyy.xyY_to_xy` definition n-dimensional 

279 support. 

280 """ 

281 

282 xyY = np.array([0.54369557, 0.32107944, 0.12197225]) 

283 xy = xyY_to_xy(xyY) 

284 

285 xyY = np.tile(xyY, (6, 1)) 

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

287 np.testing.assert_allclose(xyY_to_xy(xyY), xy, atol=TOLERANCE_ABSOLUTE_TESTS) 

288 

289 xyY = np.reshape(xyY, (2, 3, 3)) 

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

291 np.testing.assert_allclose(xyY_to_xy(xyY), xy, atol=TOLERANCE_ABSOLUTE_TESTS) 

292 

293 def test_domain_range_scale_xyY_to_xy(self) -> None: 

294 """ 

295 Test :func:`colour.models.cie_xyy.xyY_to_xy` definition domain and 

296 range scale support. 

297 """ 

298 

299 xyY = np.array([0.54369557, 0.32107944, 0.12197225]) 

300 xy = xyY_to_xy(xyY) 

301 xyY = np.reshape(np.tile(xyY, (6, 1)), (2, 3, 3)) 

302 xy = np.reshape(np.tile(xy, (6, 1)), (2, 3, 2)) 

303 

304 d_r = ( 

305 ("reference", 1, 1), 

306 ("1", 1, 1), 

307 ("100", np.array([1, 1, 100]), 1), 

308 ) 

309 for scale, factor_a, factor_b in d_r: 

310 with domain_range_scale(scale): 

311 np.testing.assert_allclose( 

312 xyY_to_xy(xyY * factor_a), 

313 xy * factor_b, 

314 atol=TOLERANCE_ABSOLUTE_TESTS, 

315 ) 

316 

317 @ignore_numpy_errors 

318 def test_nan_xyY_to_xy(self) -> None: 

319 """Test :func:`colour.models.cie_xyy.xyY_to_xy` definition nan support.""" 

320 

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

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

323 xyY_to_xy(cases) 

324 

325 

326class Testxy_to_xyY: 

327 """ 

328 Define :func:`colour.models.cie_xyy.xy_to_xyY` definition unit tests 

329 methods. 

330 """ 

331 

332 def test_xy_to_xyY(self) -> None: 

333 """Test :func:`colour.models.cie_xyy.xy_to_xyY` definition.""" 

334 

335 np.testing.assert_allclose( 

336 xy_to_xyY(np.array([0.54369557, 0.32107944])), 

337 np.array([0.54369557, 0.32107944, 1.00000000]), 

338 atol=TOLERANCE_ABSOLUTE_TESTS, 

339 ) 

340 

341 np.testing.assert_allclose( 

342 xy_to_xyY(np.array([0.29777735, 0.48246446])), 

343 np.array([0.29777735, 0.48246446, 1.00000000]), 

344 atol=TOLERANCE_ABSOLUTE_TESTS, 

345 ) 

346 

347 np.testing.assert_allclose( 

348 xy_to_xyY(np.array([0.18582823, 0.14633764])), 

349 np.array([0.18582823, 0.14633764, 1.00000000]), 

350 atol=TOLERANCE_ABSOLUTE_TESTS, 

351 ) 

352 

353 np.testing.assert_allclose( 

354 xy_to_xyY(np.array([0.31270000, 0.32900000, 1.00000000])), 

355 np.array([0.31270000, 0.32900000, 1.00000000]), 

356 atol=TOLERANCE_ABSOLUTE_TESTS, 

357 ) 

358 

359 np.testing.assert_allclose( 

360 xy_to_xyY(np.array([0.31270000, 0.32900000]), 100), 

361 np.array([0.31270000, 0.32900000, 100.00000000]), 

362 atol=TOLERANCE_ABSOLUTE_TESTS, 

363 ) 

364 

365 def test_n_dimensional_xy_to_xyY(self) -> None: 

366 """ 

367 Test :func:`colour.models.cie_xyy.xy_to_xyY` definition n-dimensional 

368 support. 

369 """ 

370 

371 xy = np.array([0.54369557, 0.32107944]) 

372 xyY = xy_to_xyY(xy) 

373 

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

375 xyY = np.tile(xyY, (6, 1)) 

376 np.testing.assert_allclose(xy_to_xyY(xy), xyY, atol=TOLERANCE_ABSOLUTE_TESTS) 

377 

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

379 xyY = np.reshape(xyY, (2, 3, 3)) 

380 np.testing.assert_allclose(xy_to_xyY(xy), xyY, atol=TOLERANCE_ABSOLUTE_TESTS) 

381 

382 def test_domain_range_scale_xy_to_xyY(self) -> None: 

383 """ 

384 Test :func:`colour.models.cie_xyy.xy_to_xyY` definition domain and 

385 range scale support. 

386 """ 

387 

388 xy = np.array([0.54369557, 0.32107944, 0.12197225]) 

389 xyY = xy_to_xyY(xy) 

390 xy = np.reshape(np.tile(xy, (6, 1)), (2, 3, 3)) 

391 xyY = np.reshape(np.tile(xyY, (6, 1)), (2, 3, 3)) 

392 

393 d_r = ( 

394 ("reference", 1, 1), 

395 ("1", 1, 1), 

396 ( 

397 "100", 

398 np.array([1, 1, 100]), 

399 np.array([1, 1, 100]), 

400 ), 

401 ) 

402 for scale, factor_a, factor_b in d_r: 

403 with domain_range_scale(scale): 

404 np.testing.assert_allclose( 

405 xy_to_xyY(xy * factor_a), 

406 xyY * factor_b, 

407 atol=TOLERANCE_ABSOLUTE_TESTS, 

408 ) 

409 

410 @ignore_numpy_errors 

411 def test_nan_xy_to_xyY(self) -> None: 

412 """Test :func:`colour.models.cie_xyy.xy_to_xyY` definition nan support.""" 

413 

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

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

416 xy_to_xyY(cases) 

417 

418 

419class TestXYZ_to_xy: 

420 """ 

421 Define :func:`colour.models.cie_xyy.XYZ_to_xy` definition unit tests 

422 methods. 

423 """ 

424 

425 def test_XYZ_to_xy(self) -> None: 

426 """Test :func:`colour.models.cie_xyy.XYZ_to_xy` definition.""" 

427 

428 np.testing.assert_allclose( 

429 XYZ_to_xy(np.array([0.20654008, 0.12197225, 0.05136952])), 

430 np.array([0.54369557, 0.32107944]), 

431 atol=TOLERANCE_ABSOLUTE_TESTS, 

432 ) 

433 

434 np.testing.assert_allclose( 

435 XYZ_to_xy(np.array([0.14222010, 0.23042768, 0.10495772])), 

436 np.array([0.29777735, 0.48246446]), 

437 atol=TOLERANCE_ABSOLUTE_TESTS, 

438 ) 

439 

440 np.testing.assert_allclose( 

441 XYZ_to_xy(np.array([0.07818780, 0.06157201, 0.28099326])), 

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

443 atol=TOLERANCE_ABSOLUTE_TESTS, 

444 ) 

445 

446 np.testing.assert_allclose( 

447 XYZ_to_xy(np.array([0.00000000, 0.00000000, 0.00000000])), 

448 np.array([0.00000000, 0.00000000]), 

449 atol=TOLERANCE_ABSOLUTE_TESTS, 

450 ) 

451 

452 def test_n_dimensional_XYZ_to_xy(self) -> None: 

453 """ 

454 Test :func:`colour.models.cie_xyy.XYZ_to_xy` definition n-dimensional 

455 support. 

456 """ 

457 

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

459 xy = XYZ_to_xy(XYZ) 

460 

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

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

463 np.testing.assert_allclose(XYZ_to_xy(XYZ), xy, atol=TOLERANCE_ABSOLUTE_TESTS) 

464 

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

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

467 np.testing.assert_allclose(XYZ_to_xy(XYZ), xy, atol=TOLERANCE_ABSOLUTE_TESTS) 

468 

469 def test_domain_range_scale_XYZ_to_xy(self) -> None: 

470 """ 

471 Test :func:`colour.models.cie_xyy.XYZ_to_xy` definition domain and 

472 range scale support. 

473 """ 

474 

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

476 xy = XYZ_to_xy(XYZ) 

477 XYZ = np.reshape(np.tile(XYZ, (6, 1)), (2, 3, 3)) 

478 xy = np.reshape(np.tile(xy, (6, 1)), (2, 3, 2)) 

479 

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

481 for scale, factor in d_r: 

482 with domain_range_scale(scale): 

483 np.testing.assert_allclose( 

484 XYZ_to_xy(XYZ * factor), xy, atol=TOLERANCE_ABSOLUTE_TESTS 

485 ) 

486 

487 @ignore_numpy_errors 

488 def test_nan_XYZ_to_xy(self) -> None: 

489 """Test :func:`colour.models.cie_xyy.XYZ_to_xy` definition nan support.""" 

490 

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

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

493 XYZ_to_xy(cases) 

494 

495 

496class Testxy_to_XYZ: 

497 """ 

498 Define :func:`colour.models.cie_xyy.xy_to_XYZ` definition unit tests 

499 methods. 

500 """ 

501 

502 def test_xy_to_XYZ(self) -> None: 

503 """Test :func:`colour.models.cie_xyy.xy_to_XYZ` definition.""" 

504 

505 np.testing.assert_allclose( 

506 xy_to_XYZ(np.array([0.54369557, 0.32107944])), 

507 np.array([1.69333661, 1.00000000, 0.42115742]), 

508 atol=TOLERANCE_ABSOLUTE_TESTS, 

509 ) 

510 

511 np.testing.assert_allclose( 

512 xy_to_XYZ(np.array([0.29777735, 0.48246446])), 

513 np.array([0.61720059, 1.00000000, 0.45549094]), 

514 atol=TOLERANCE_ABSOLUTE_TESTS, 

515 ) 

516 

517 np.testing.assert_allclose( 

518 xy_to_XYZ(np.array([0.18582823, 0.14633764])), 

519 np.array([1.26985942, 1.00000000, 4.56365245]), 

520 atol=TOLERANCE_ABSOLUTE_TESTS, 

521 ) 

522 

523 np.testing.assert_allclose( 

524 xy_to_XYZ(np.array([0.31270000, 0.32900000])), 

525 np.array([0.95045593, 1.00000000, 1.08905775]), 

526 atol=TOLERANCE_ABSOLUTE_TESTS, 

527 ) 

528 

529 def test_n_dimensional_xy_to_XYZ(self) -> None: 

530 """ 

531 Test :func:`colour.models.cie_xyy.xy_to_XYZ` definition n-dimensional 

532 support. 

533 """ 

534 

535 xy = np.array([0.54369557, 0.32107944]) 

536 XYZ = xy_to_XYZ(xy) 

537 

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

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

540 np.testing.assert_allclose(xy_to_XYZ(xy), XYZ, atol=TOLERANCE_ABSOLUTE_TESTS) 

541 

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

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

544 np.testing.assert_allclose(xy_to_XYZ(xy), XYZ, atol=TOLERANCE_ABSOLUTE_TESTS) 

545 

546 def test_domain_range_scale_xy_to_XYZ(self) -> None: 

547 """ 

548 Test :func:`colour.models.cie_xyy.xy_to_XYZ` definition domain and 

549 range scale support. 

550 """ 

551 

552 xy = np.array([0.54369557, 0.32107944, 0.12197225]) 

553 XYZ = xy_to_XYZ(xy) 

554 xy = np.reshape(np.tile(xy, (6, 1)), (2, 3, 3)) 

555 XYZ = np.reshape(np.tile(XYZ, (6, 1)), (2, 3, 3)) 

556 

557 d_r = ( 

558 ("reference", 1, 1), 

559 ("1", 1, 1), 

560 ("100", np.array([1, 1, 100]), 100), 

561 ) 

562 for scale, factor_a, factor_b in d_r: 

563 with domain_range_scale(scale): 

564 np.testing.assert_allclose( 

565 xy_to_XYZ(xy * factor_a), 

566 XYZ * factor_b, 

567 atol=TOLERANCE_ABSOLUTE_TESTS, 

568 ) 

569 

570 @ignore_numpy_errors 

571 def test_nan_xy_to_XYZ(self) -> None: 

572 """Test :func:`colour.models.cie_xyy.xy_to_XYZ` definition nan support.""" 

573 

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

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

576 xy_to_XYZ(cases)