Coverage for models/rgb/transfer_functions/tests/test_itur_bt_2100.py: 100%

1"""

2 Define the unit tests for the

3:mod:`colour.models.rgb.transfer_functions.itur_bt_2100` module.

4"""

5

6 import numpy as np

7

8 from colour.constants import TOLERANCE_ABSOLUTE_TESTS

9 from colour.models.rgb.transfer_functions import (

10 eotf_BT2100_PQ,

11 eotf_inverse_BT2100_PQ,

12 oetf_BT2100_HLG,

13 oetf_BT2100_PQ,

14 oetf_inverse_BT2100_HLG,

15 oetf_inverse_BT2100_PQ,

16 ootf_BT2100_PQ,

17 ootf_inverse_BT2100_PQ,

18)

19 from colour.models.rgb.transfer_functions.itur_bt_2100 import (

20 eotf_BT2100_HLG_1,

21 eotf_BT2100_HLG_2,

22 eotf_inverse_BT2100_HLG_1,

23 eotf_inverse_BT2100_HLG_2,

24 gamma_function_BT2100_HLG,

25 ootf_BT2100_HLG_1,

26 ootf_BT2100_HLG_2,

27 ootf_inverse_BT2100_HLG_1,

28 ootf_inverse_BT2100_HLG_2,

29)

30 from colour.utilities import domain_range_scale, ignore_numpy_errors

31

32 __author__ = "Colour Developers"

33 __copyright__ = "Copyright 2013 Colour Developers"

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

35 __maintainer__ = "Colour Developers"

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

37 __status__ = "Production"

38

39 __all__ = [

40 "TestOetf_BT2100_PQ",

41 "TestOetf_inverse_BT2100_PQ",

42 "TestEotf_BT2100_PQ",

43 "TestEotf_inverse_BT2100_PQ",

44 "TestOotf_BT2100_PQ",

45 "TestOotf_inverse_BT2100_PQ",

46 "TestGamma_function_BT2100_HLG",

47 "TestOetf_BT2100_HLG",

48 "TestOetf_inverse_BT2100_HLG",

49 "TestEotf_BT2100_HLG_1",

50 "TestEotf_BT2100_HLG_2",

51 "TestEotf_inverse_BT2100_HLG_1",

52 "TestEotf_inverse_BT2100_HLG_2",

53 "TestOotf_BT2100_HLG_1",

54 "TestOotf_BT2100_HLG_2",

55 "TestOotf_inverse_BT2100_HLG_1",

56 "TestOotf_inverse_BT2100_HLG_2",

57]

58

59

60 class TestOetf_BT2100_PQ:

61 """

62 Define :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\

63 oetf_BT2100_PQ` definition unit tests methods.

64 """

65

66 def test_oetf_BT2100_PQ(self) -> None:

67 """

68 Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\

69 oetf_BT2100_PQ` definition.

70 """

71

72 np.testing.assert_allclose(

73 oetf_BT2100_PQ(0.0),

74 0.000000730955903,

75 atol=TOLERANCE_ABSOLUTE_TESTS,

76 )

77

78 np.testing.assert_allclose(

79 oetf_BT2100_PQ(0.1),

80 0.724769816665726,

81 atol=TOLERANCE_ABSOLUTE_TESTS,

82 )

83

84 np.testing.assert_allclose(

85 oetf_BT2100_PQ(1.0),

86 0.999999934308041,

87 atol=TOLERANCE_ABSOLUTE_TESTS,

88 )

89

90 def test_n_dimensional_oetf_BT2100_PQ(self) -> None:

91 """

92 Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\

93 oetf_BT2100_PQ` definition n-dimensional arrays support.

94 """

95

96 E = 0.1

97 E_p = oetf_BT2100_PQ(E)

98

99 E = np.tile(E, 6)

100 E_p = np.tile(E_p, 6)

101 np.testing.assert_allclose(

102 oetf_BT2100_PQ(E), E_p, atol=TOLERANCE_ABSOLUTE_TESTS

103 )

104

105 E = np.reshape(E, (2, 3))

106 E_p = np.reshape(E_p, (2, 3))

107 np.testing.assert_allclose(

108 oetf_BT2100_PQ(E), E_p, atol=TOLERANCE_ABSOLUTE_TESTS

109 )

110

111 E = np.reshape(E, (2, 3, 1))

112 E_p = np.reshape(E_p, (2, 3, 1))

113 np.testing.assert_allclose(

114 oetf_BT2100_PQ(E), E_p, atol=TOLERANCE_ABSOLUTE_TESTS

115 )

116

117 def test_domain_range_scale_oetf_BT2100_PQ(self) -> None:

118 """

119 Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\

120 oetf_BT2100_PQ` definition domain and range scale support.

121 """

122

123 E = 0.1

124 E_p = oetf_BT2100_PQ(E)

125

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

127 for scale, factor in d_r:

128 with domain_range_scale(scale):

129 np.testing.assert_allclose(

130 oetf_BT2100_PQ(E * factor),

131 E_p * factor,

132 atol=TOLERANCE_ABSOLUTE_TESTS,

133 )

134

135 @ignore_numpy_errors

136 def test_nan_oetf_BT2100_PQ(self) -> None:

137 """

138 Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\

139 oetf_BT2100_PQ` definition nan support.

140 """

141

142 oetf_BT2100_PQ(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan]))

143

144

145 class TestOetf_inverse_BT2100_PQ:

146 """

147 Define :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\

148 oetf_inverse_BT2100_PQ` definition unit tests methods.

149 """

150

151 def test_oetf_inverse_BT2100_PQ(self) -> None:

152 """

153 Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\

154 oetf_inverse_BT2100_PQ` definition.

155 """

156

157 np.testing.assert_allclose(

158 oetf_inverse_BT2100_PQ(0.000000730955903),

159 0.0,

160 atol=TOLERANCE_ABSOLUTE_TESTS,

161 )

162

163 np.testing.assert_allclose(

164 oetf_inverse_BT2100_PQ(0.724769816665726),

165 0.1,

166 atol=TOLERANCE_ABSOLUTE_TESTS,

167 )

168

169 np.testing.assert_allclose(

170 oetf_inverse_BT2100_PQ(0.999999934308041),

171 1.0,

172 atol=TOLERANCE_ABSOLUTE_TESTS,

173 )

174

175 def test_n_dimensional_oetf_inverse_BT2100_PQ(self) -> None:

176 """

177 Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\

178 oetf_inverse_BT2100_PQ` definition n-dimensional arrays support.

179 """

180

181 E_p = 0.724769816665726

182 E = oetf_inverse_BT2100_PQ(E_p)

183

184 E_p = np.tile(E_p, 6)

185 E = np.tile(E, 6)

186 np.testing.assert_allclose(

187 oetf_inverse_BT2100_PQ(E_p), E, atol=TOLERANCE_ABSOLUTE_TESTS

188 )

189

190 E_p = np.reshape(E_p, (2, 3))

191 E = np.reshape(E, (2, 3))

192 np.testing.assert_allclose(

193 oetf_inverse_BT2100_PQ(E_p), E, atol=TOLERANCE_ABSOLUTE_TESTS

194 )

195

196 E_p = np.reshape(E_p, (2, 3, 1))

197 E = np.reshape(E, (2, 3, 1))

198 np.testing.assert_allclose(

199 oetf_inverse_BT2100_PQ(E_p), E, atol=TOLERANCE_ABSOLUTE_TESTS

200 )

201

202 def test_domain_range_scale_oetf_inverse_BT2100_PQ(self) -> None:

203 """

204 Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\

205 oetf_inverse_BT2100_PQ` definition domain and range scale support.

206 """

207

208 E_p = 0.724769816665726

209 E = oetf_inverse_BT2100_PQ(E_p)

210

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

212 for scale, factor in d_r:

213 with domain_range_scale(scale):

214 np.testing.assert_allclose(

215 oetf_inverse_BT2100_PQ(E_p * factor),

216 E * factor,

217 atol=TOLERANCE_ABSOLUTE_TESTS,

218 )

219

220 @ignore_numpy_errors

221 def test_nan_oetf_inverse_BT2100_PQ(self) -> None:

222 """

223 Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\

224 oetf_inverse_BT2100_PQ` definition nan support.

225 """

226

227 oetf_inverse_BT2100_PQ(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan]))

228

229

230 class TestEotf_BT2100_PQ:

231 """

232 Define :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\

233 eotf_BT2100_PQ` definition unit tests methods.

234 """

235

236 def test_eotf_BT2100_PQ(self) -> None:

237 """

238 Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\

239 eotf_BT2100_PQ` definition.

240 """

241

242 np.testing.assert_allclose(

243 eotf_BT2100_PQ(0.0), 0.0, atol=TOLERANCE_ABSOLUTE_TESTS

244 )

245

246 np.testing.assert_allclose(

247 eotf_BT2100_PQ(0.724769816665726),

248 779.98836083408537,

249 atol=TOLERANCE_ABSOLUTE_TESTS,

250 )

251

252 np.testing.assert_allclose(

253 eotf_BT2100_PQ(1.0), 10000.0, atol=TOLERANCE_ABSOLUTE_TESTS

254 )

255

256 def test_n_dimensional_eotf_BT2100_PQ(self) -> None:

257 """

258 Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\

259 eotf_BT2100_PQ` definition n-dimensional arrays support.

260 """

261

262 E_p = 0.724769816665726

263 F_D = eotf_BT2100_PQ(E_p)

264

265 E_p = np.tile(E_p, 6)

266 F_D = np.tile(F_D, 6)

267 np.testing.assert_allclose(

268 eotf_BT2100_PQ(E_p), F_D, atol=TOLERANCE_ABSOLUTE_TESTS

269 )

270

271 E_p = np.reshape(E_p, (2, 3))

272 F_D = np.reshape(F_D, (2, 3))

273 np.testing.assert_allclose(

274 eotf_BT2100_PQ(E_p), F_D, atol=TOLERANCE_ABSOLUTE_TESTS

275 )

276

277 E_p = np.reshape(E_p, (2, 3, 1))

278 F_D = np.reshape(F_D, (2, 3, 1))

279 np.testing.assert_allclose(

280 eotf_BT2100_PQ(E_p), F_D, atol=TOLERANCE_ABSOLUTE_TESTS

281 )

282

283 def test_domain_range_scale_eotf_BT2100_PQ(self) -> None:

284 """

285 Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\

286 eotf_BT2100_PQ` definition domain and range scale support.

287 """

288

289 E_p = 0.724769816665726

290 F_D = eotf_BT2100_PQ(E_p)

291

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

293 for scale, factor in d_r:

294 with domain_range_scale(scale):

295 np.testing.assert_allclose(

296 eotf_BT2100_PQ(E_p * factor),

297 F_D * factor,

298 atol=TOLERANCE_ABSOLUTE_TESTS,

299 )

300

301 @ignore_numpy_errors

302 def test_nan_eotf_BT2100_PQ(self) -> None:

303 """

304 Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\

305 eotf_BT2100_PQ` definition nan support.

306 """

307

308 eotf_BT2100_PQ(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan]))

309

310

311 class TestEotf_inverse_BT2100_PQ:

312 """

313 Define :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\

314 eotf_inverse_BT2100_PQ` definition unit tests methods.

315 """

316

317 def test_eotf_inverse_BT2100_PQ(self) -> None:

318 """

319 Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\

320 eotf_inverse_BT2100_PQ` definition.

321 """

322

323 np.testing.assert_allclose(

324 eotf_inverse_BT2100_PQ(0.0),

325 0.000000730955903,

326 atol=TOLERANCE_ABSOLUTE_TESTS,

327 )

328

329 np.testing.assert_allclose(

330 eotf_inverse_BT2100_PQ(779.98836083408537),

331 0.724769816665726,

332 atol=TOLERANCE_ABSOLUTE_TESTS,

333 )

334

335 np.testing.assert_allclose(

336 eotf_inverse_BT2100_PQ(10000.0), 1.0, atol=TOLERANCE_ABSOLUTE_TESTS

337 )

338

339 def test_n_dimensional_eotf_inverse_BT2100_PQ(self) -> None:

340 """

341 Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\

342 eotf_inverse_BT2100_PQ` definition n-dimensional arrays support.

343 """

344

345 F_D = 779.98836083408537

346 E_p = eotf_inverse_BT2100_PQ(F_D)

347

348 F_D = np.tile(F_D, 6)

349 E_p = np.tile(E_p, 6)

350 np.testing.assert_allclose(

351 eotf_inverse_BT2100_PQ(F_D), E_p, atol=TOLERANCE_ABSOLUTE_TESTS

352 )

353

354 F_D = np.reshape(F_D, (2, 3))

355 E_p = np.reshape(E_p, (2, 3))

356 np.testing.assert_allclose(

357 eotf_inverse_BT2100_PQ(F_D), E_p, atol=TOLERANCE_ABSOLUTE_TESTS

358 )

359

360 F_D = np.reshape(F_D, (2, 3, 1))

361 E_p = np.reshape(E_p, (2, 3, 1))

362 np.testing.assert_allclose(

363 eotf_inverse_BT2100_PQ(F_D), E_p, atol=TOLERANCE_ABSOLUTE_TESTS

364 )

365

366 def test_domain_range_scale_eotf_inverse_BT2100_PQ(self) -> None:

367 """

368 Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\

369 eotf_inverse_BT2100_PQ` definition domain and range scale support.

370 """

371

372 F_D = 779.98836083408537

373 E_p = eotf_inverse_BT2100_PQ(F_D)

374

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

376 for scale, factor in d_r:

377 with domain_range_scale(scale):

378 np.testing.assert_allclose(

379 eotf_inverse_BT2100_PQ(F_D * factor),

380 E_p * factor,

381 atol=TOLERANCE_ABSOLUTE_TESTS,

382 )

383

384 @ignore_numpy_errors

385 def test_nan_eotf_inverse_BT2100_PQ(self) -> None:

386 """

387 Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\

388 eotf_inverse_BT2100_PQ` definition nan support.

389 """

390

391 eotf_inverse_BT2100_PQ(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan]))

392

393

394 class TestOotf_BT2100_PQ:

395 """

396 Define :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\

397 ootf_BT2100_PQ` definition unit tests methods.

398 """

399

400 def test_ootf_BT2100_PQ(self) -> None:

401 """

402 Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\

403 ootf_BT2100_PQ` definition.

404 """

405

406 np.testing.assert_allclose(

407 ootf_BT2100_PQ(0.0), 0.0, atol=TOLERANCE_ABSOLUTE_TESTS

408 )

409

410 np.testing.assert_allclose(

411 ootf_BT2100_PQ(0.1),

412 779.98836083411584,

413 atol=TOLERANCE_ABSOLUTE_TESTS,

414 )

415

416 np.testing.assert_allclose(

417 ootf_BT2100_PQ(1.0),

418 9999.993723673924300,

419 atol=TOLERANCE_ABSOLUTE_TESTS,

420 )

421

422 def test_n_dimensional_ootf_BT2100_PQ(self) -> None:

423 """

424 Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\

425 ootf_BT2100_PQ` definition n-dimensional arrays support.

426 """

427

428 E = 0.1

429 F_D = ootf_BT2100_PQ(E)

430

431 E = np.tile(E, 6)

432 F_D = np.tile(F_D, 6)

433 np.testing.assert_allclose(

434 ootf_BT2100_PQ(E), F_D, atol=TOLERANCE_ABSOLUTE_TESTS

435 )

436

437 E = np.reshape(E, (2, 3))

438 F_D = np.reshape(F_D, (2, 3))

439 np.testing.assert_allclose(

440 ootf_BT2100_PQ(E), F_D, atol=TOLERANCE_ABSOLUTE_TESTS

441 )

442

443 E = np.reshape(E, (2, 3, 1))

444 F_D = np.reshape(F_D, (2, 3, 1))

445 np.testing.assert_allclose(

446 ootf_BT2100_PQ(E), F_D, atol=TOLERANCE_ABSOLUTE_TESTS

447 )

448

449 def test_domain_range_scale_ootf_BT2100_PQ(self) -> None:

450 """

451 Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\

452 ootf_BT2100_PQ` definition domain and range scale support.

453 """

454

455 E = 0.1

456 F_D = ootf_BT2100_PQ(E)

457

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

459 for scale, factor in d_r:

460 with domain_range_scale(scale):

461 np.testing.assert_allclose(

462 ootf_BT2100_PQ(E * factor),

463 F_D * factor,

464 atol=TOLERANCE_ABSOLUTE_TESTS,

465 )

466

467 @ignore_numpy_errors

468 def test_nan_ootf_BT2100_PQ(self) -> None:

469 """

470 Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\

471 ootf_BT2100_PQ` definition nan support.

472 """

473

474 ootf_BT2100_PQ(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan]))

475

476

477 class TestOotf_inverse_BT2100_PQ:

478 """

479 Define :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\

480 ootf_inverse_BT2100_PQ` definition unit tests methods.

481 """

482

483 def test_ootf_inverse_BT2100_PQ(self) -> None:

484 """

485 Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\

486 ootf_inverse_BT2100_PQ` definition.

487 """

488

489 np.testing.assert_allclose(

490 ootf_inverse_BT2100_PQ(0.0), 0.0, atol=TOLERANCE_ABSOLUTE_TESTS

491 )

492

493 np.testing.assert_allclose(

494 ootf_inverse_BT2100_PQ(779.98836083411584),

495 0.1,

496 atol=TOLERANCE_ABSOLUTE_TESTS,

497 )

498

499 np.testing.assert_allclose(

500 ootf_inverse_BT2100_PQ(9999.993723673924300),

501 1.0,

502 atol=TOLERANCE_ABSOLUTE_TESTS,

503 )

504

505 def test_n_dimensional_ootf_inverse_BT2100_PQ(self) -> None:

506 """

507 Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\

508 ootf_inverse_BT2100_PQ` definition n-dimensional arrays support.

509 """

510

511 F_D = 779.98836083411584

512 E = ootf_inverse_BT2100_PQ(F_D)

513

514 F_D = np.tile(F_D, 6)

515 E = np.tile(E, 6)

516 np.testing.assert_allclose(

517 ootf_inverse_BT2100_PQ(F_D), E, atol=TOLERANCE_ABSOLUTE_TESTS

518 )

519

520 F_D = np.reshape(F_D, (2, 3))

521 E = np.reshape(E, (2, 3))

522 np.testing.assert_allclose(

523 ootf_inverse_BT2100_PQ(F_D), E, atol=TOLERANCE_ABSOLUTE_TESTS

524 )

525

526 F_D = np.reshape(F_D, (2, 3, 1))

527 E = np.reshape(E, (2, 3, 1))

528 np.testing.assert_allclose(

529 ootf_inverse_BT2100_PQ(F_D), E, atol=TOLERANCE_ABSOLUTE_TESTS

530 )

531

532 def test_domain_range_scale_ootf_inverse_BT2100_PQ(self) -> None:

533 """

534 Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\

535 ootf_inverse_BT2100_PQ` definition domain and range scale support.

536 """

537

538 F_D = 779.98836083411584

539 E = ootf_inverse_BT2100_PQ(F_D)

540

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

542 for scale, factor in d_r:

543 with domain_range_scale(scale):

544 np.testing.assert_allclose(

545 ootf_inverse_BT2100_PQ(F_D * factor),

546 E * factor,

547 atol=TOLERANCE_ABSOLUTE_TESTS,

548 )

549

550 @ignore_numpy_errors

551 def test_nan_ootf_inverse_BT2100_PQ(self) -> None:

552 """

553 Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\

554 ootf_inverse_BT2100_PQ` definition nan support.

555 """

556

557 ootf_inverse_BT2100_PQ(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan]))

558

559

560 class TestGamma_function_BT2100_HLG:

561 """

562 Define :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\

563 gamma_function_BT2100_HLG` definition unit tests methods.

564 """

565

566 def test_gamma_function_BT2100_HLG(self) -> None:

567 """

568 Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\

569 gamma_function_BT2100_HLG` definition.

570 """

571

572 np.testing.assert_allclose(

573 gamma_function_BT2100_HLG(1000.0),

574 1.2,

575 atol=TOLERANCE_ABSOLUTE_TESTS,

576 )

577

578 np.testing.assert_allclose(

579 gamma_function_BT2100_HLG(2000.0),

580 1.326432598178872,

581 atol=TOLERANCE_ABSOLUTE_TESTS,

582 )

583

584 np.testing.assert_allclose(

585 gamma_function_BT2100_HLG(4000.0),

586 1.452865196357744,

587 atol=TOLERANCE_ABSOLUTE_TESTS,

588 )

589

590 np.testing.assert_allclose(

591 gamma_function_BT2100_HLG(10000.0),

592 1.619999999999999,

593 atol=TOLERANCE_ABSOLUTE_TESTS,

594 )

595

596

597 class TestOetf_BT2100_HLG:

598 """

599 Define :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\

600 oetf_BT2100_HLG` definition unit tests methods.

601 """

602

603 def test_oetf_BT2100_HLG(self) -> None:

604 """

605 Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\

606 oetf_BT2100_HLG` definition.

607 """

608

609 np.testing.assert_allclose(

610 oetf_BT2100_HLG(0.0), 0.0, atol=TOLERANCE_ABSOLUTE_TESTS

611 )

612

613 np.testing.assert_allclose(

614 oetf_BT2100_HLG(0.18 / 12),

615 0.212132034355964,

616 atol=TOLERANCE_ABSOLUTE_TESTS,

617 )

618

619 np.testing.assert_allclose(

620 oetf_BT2100_HLG(1.0),

621 0.999999995536569,

622 atol=TOLERANCE_ABSOLUTE_TESTS,

623 )

624

625 def test_n_dimensional_oetf_BT2100_HLG(self) -> None:

626 """

627 Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\

628 oetf_BT2100_HLG` definition n-dimensional arrays support.

629 """

630

631 E = 0.18 / 12

632 E_p = oetf_BT2100_HLG(E)

633

634 E = np.tile(E, 6)

635 E_p = np.tile(E_p, 6)

636 np.testing.assert_allclose(

637 oetf_BT2100_HLG(E), E_p, atol=TOLERANCE_ABSOLUTE_TESTS

638 )

639

640 E = np.reshape(E, (2, 3))

641 E_p = np.reshape(E_p, (2, 3))

642 np.testing.assert_allclose(

643 oetf_BT2100_HLG(E), E_p, atol=TOLERANCE_ABSOLUTE_TESTS

644 )

645

646 E = np.reshape(E, (2, 3, 1))

647 E_p = np.reshape(E_p, (2, 3, 1))

648 np.testing.assert_allclose(

649 oetf_BT2100_HLG(E), E_p, atol=TOLERANCE_ABSOLUTE_TESTS

650 )

651

652 def test_domain_range_scale_oetf_BT2100_HLG(self) -> None:

653 """

654 Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\

655 oetf_BT2100_HLG` definition domain and range scale support.

656 """

657

658 E = 0.18 / 12

659 E_p = oetf_BT2100_HLG(E)

660

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

662 for scale, factor in d_r:

663 with domain_range_scale(scale):

664 np.testing.assert_allclose(

665 oetf_BT2100_HLG(E * factor),

666 E_p * factor,

667 atol=TOLERANCE_ABSOLUTE_TESTS,

668 )

669

670 @ignore_numpy_errors

671 def test_nan_oetf_BT2100_HLG(self) -> None:

672 """

673 Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\

674 oetf_BT2100_HLG` definition nan support.

675 """

676

677 oetf_BT2100_HLG(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan]))

678

679

680 class TestOetf_inverse_BT2100_HLG:

681 """

682 Define :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\

683 oetf_inverse_BT2100_HLG` definition unit tests methods.

684 """

685

686 def test_oetf_inverse_BT2100_HLG(self) -> None:

687 """

688 Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\

689 oetf_inverse_BT2100_HLG` definition.

690 """

691

692 np.testing.assert_allclose(

693 oetf_inverse_BT2100_HLG(0.0), 0.0, atol=TOLERANCE_ABSOLUTE_TESTS

694 )

695

696 np.testing.assert_allclose(

697 oetf_inverse_BT2100_HLG(0.212132034355964),

698 0.18 / 12,

699 atol=TOLERANCE_ABSOLUTE_TESTS,

700 )

701

702 np.testing.assert_allclose(

703 oetf_inverse_BT2100_HLG(0.999999995536569),

704 1.0,

705 atol=TOLERANCE_ABSOLUTE_TESTS,

706 )

707

708 def test_n_dimensional_oetf_inverse_BT2100_HLG(self) -> None:

709 """

710 Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\

711 oetf_inverse_BT2100_HLG` definition n-dimensional arrays support.

712 """

713

714 E_p = 0.212132034355964

715 E = oetf_inverse_BT2100_HLG(E_p)

716

717 E_p = np.tile(E_p, 6)

718 E = np.tile(E, 6)

719 np.testing.assert_allclose(

720 oetf_inverse_BT2100_HLG(E_p), E, atol=TOLERANCE_ABSOLUTE_TESTS

721 )

722

723 E_p = np.reshape(E_p, (2, 3))

724 E = np.reshape(E, (2, 3))

725 np.testing.assert_allclose(

726 oetf_inverse_BT2100_HLG(E_p), E, atol=TOLERANCE_ABSOLUTE_TESTS

727 )

728

729 E_p = np.reshape(E_p, (2, 3, 1))

730 E = np.reshape(E, (2, 3, 1))

731 np.testing.assert_allclose(

732 oetf_inverse_BT2100_HLG(E_p), E, atol=TOLERANCE_ABSOLUTE_TESTS

733 )

734

735 def test_domain_range_scale_oetf_inverse_BT2100_HLG(self) -> None:

736 """

737 Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\

738 oetf_inverse_BT2100_HLG` definition domain and range scale support.

739 """

740

741 E_p = 0.212132034355964

742 E = oetf_inverse_BT2100_HLG(E_p)

743

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

745 for scale, factor in d_r:

746 with domain_range_scale(scale):

747 np.testing.assert_allclose(

748 oetf_inverse_BT2100_HLG(E_p * factor),

749 E * factor,

750 atol=TOLERANCE_ABSOLUTE_TESTS,

751 )

752

753 @ignore_numpy_errors

754 def test_nan_oetf_inverse_BT2100_HLG(self) -> None:

755 """

756 Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\

757 oetf_inverse_BT2100_HLG` definition nan support.

758 """

759

760 oetf_inverse_BT2100_HLG(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan]))

761

762

763 class TestEotf_BT2100_HLG_1:

764 """

765 Define :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\

766 eotf_BT2100_HLG_1` definition unit tests methods.

767 """

768

769 def test_eotf_BT2100_HLG_1(self) -> None:

770 """

771 Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\

772 eotf_BT2100_HLG_1` definition.

773 """

774

775 np.testing.assert_allclose(

776 eotf_BT2100_HLG_1(0.0), 0.0, atol=TOLERANCE_ABSOLUTE_TESTS

777 )

778

779 np.testing.assert_allclose(

780 eotf_BT2100_HLG_1(0.212132034355964),

781 6.476039825649814,

782 atol=TOLERANCE_ABSOLUTE_TESTS,

783 )

784

785 np.testing.assert_allclose(

786 eotf_BT2100_HLG_1(1.0),

787 1000.000032321769100,

788 atol=TOLERANCE_ABSOLUTE_TESTS,

789 )

790

791 np.testing.assert_allclose(

792 eotf_BT2100_HLG_1(0.212132034355964, 0.001, 10000, 1.4),

793 27.96039175299561,

794 atol=TOLERANCE_ABSOLUTE_TESTS,

795 )

796

797 def test_n_dimensional_eotf_BT2100_HLG_1(self) -> None:

798 """

799 Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\

800 eotf_BT2100_HLG_1` definition n-dimensional arrays support.

801 """

802

803 E_p = 0.212132034355964

804 F_D = eotf_BT2100_HLG_1(E_p)

805

806 E_p = np.tile(E_p, 6)

807 F_D = np.tile(F_D, 6)

808 np.testing.assert_allclose(

809 eotf_BT2100_HLG_1(E_p), F_D, atol=TOLERANCE_ABSOLUTE_TESTS

810 )

811

812 E_p = np.reshape(E_p, (2, 3))

813 F_D = np.reshape(F_D, (2, 3))

814 np.testing.assert_allclose(

815 eotf_BT2100_HLG_1(E_p), F_D, atol=TOLERANCE_ABSOLUTE_TESTS

816 )

817

818 E_p = np.reshape(E_p, (2, 3, 1))

819 F_D = np.reshape(F_D, (2, 3, 1))

820 np.testing.assert_allclose(

821 eotf_BT2100_HLG_1(E_p), F_D, atol=TOLERANCE_ABSOLUTE_TESTS

822 )

823

824 E_p = np.reshape(E_p, (6, 1))

825 F_D = np.reshape(F_D, (6, 1))

826 np.testing.assert_allclose(

827 eotf_BT2100_HLG_1(E_p), F_D, atol=TOLERANCE_ABSOLUTE_TESTS

828 )

829

830 E_p = np.array([0.25, 0.50, 0.75])

831 F_D = np.array([12.49759413, 49.99037650, 158.94693786])

832 np.testing.assert_allclose(

833 eotf_BT2100_HLG_1(E_p), F_D, atol=TOLERANCE_ABSOLUTE_TESTS

834 )

835

836 E_p = np.tile(E_p, (6, 1))

837 F_D = np.tile(F_D, (6, 1))

838 np.testing.assert_allclose(

839 eotf_BT2100_HLG_1(E_p), F_D, atol=TOLERANCE_ABSOLUTE_TESTS

840 )

841

842 E_p = np.reshape(E_p, (2, 3, 3))

843 F_D = np.reshape(F_D, (2, 3, 3))

844 np.testing.assert_allclose(

845 eotf_BT2100_HLG_1(E_p), F_D, atol=TOLERANCE_ABSOLUTE_TESTS

846 )

847

848 def test_domain_range_scale_eotf_BT2100_HLG_1(self) -> None:

849 """

850 Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\

851 eotf_BT2100_HLG_1` definition domain and range scale support.

852 """

853

854 E_p = 0.212132034355964

855 F_D = eotf_BT2100_HLG_1(E_p)

856

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

858 for scale, factor in d_r:

859 with domain_range_scale(scale):

860 np.testing.assert_allclose(

861 eotf_BT2100_HLG_1(E_p * factor),

862 F_D * factor,

863 atol=TOLERANCE_ABSOLUTE_TESTS,

864 )

865

866 @ignore_numpy_errors

867 def test_nan_eotf_BT2100_HLG_1(self) -> None:

868 """

869 Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\

870 eotf_BT2100_HLG_1` definition nan support.

871 """

872

873 eotf_BT2100_HLG_1(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan]))

874

875

876 class TestEotf_BT2100_HLG_2:

877 """

878 Define :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\

879 eotf_BT2100_HLG_2` definition unit tests methods.

880 """

881

882 def test_eotf_BT2100_HLG_2(self) -> None:

883 """

884 Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\

885 eotf_BT2100_HLG_2` definition.

886 """

887

888 np.testing.assert_allclose(

889 eotf_BT2100_HLG_2(0.0), 0.0, atol=TOLERANCE_ABSOLUTE_TESTS

890 )

891

892 np.testing.assert_allclose(

893 eotf_BT2100_HLG_2(0.212132034355964),

894 6.476039825649814,

895 atol=TOLERANCE_ABSOLUTE_TESTS,

896 )

897

898 np.testing.assert_allclose(

899 eotf_BT2100_HLG_2(1.0),

900 1000.000032321769100,

901 atol=TOLERANCE_ABSOLUTE_TESTS,

902 )

903

904 np.testing.assert_allclose(

905 eotf_BT2100_HLG_2(0.212132034355964, 0.001, 10000, 1.4),

906 29.581261576946076,

907 atol=TOLERANCE_ABSOLUTE_TESTS,

908 )

909

910 def test_n_dimensional_eotf_BT2100_HLG_2(self) -> None:

911 """

912 Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\

913 eotf_BT2100_HLG_2` definition n-dimensional arrays support.

914 """

915

916 E_p = 0.212132034355964

917 F_D = eotf_BT2100_HLG_2(E_p)

918

919 E_p = np.tile(E_p, 6)

920 F_D = np.tile(F_D, 6)

921 np.testing.assert_allclose(

922 eotf_BT2100_HLG_2(E_p), F_D, atol=TOLERANCE_ABSOLUTE_TESTS

923 )

924

925 E_p = np.reshape(E_p, (2, 3))

926 F_D = np.reshape(F_D, (2, 3))

927 np.testing.assert_allclose(

928 eotf_BT2100_HLG_2(E_p), F_D, atol=TOLERANCE_ABSOLUTE_TESTS

929 )

930

931 E_p = np.reshape(E_p, (2, 3, 1))

932 F_D = np.reshape(F_D, (2, 3, 1))

933 np.testing.assert_allclose(

934 eotf_BT2100_HLG_2(E_p), F_D, atol=TOLERANCE_ABSOLUTE_TESTS

935 )

936

937 E_p = np.reshape(E_p, (6, 1))

938 F_D = np.reshape(F_D, (6, 1))

939 np.testing.assert_allclose(

940 eotf_BT2100_HLG_2(E_p), F_D, atol=TOLERANCE_ABSOLUTE_TESTS

941 )

942

943 E_p = np.array([0.25, 0.50, 0.75])

944 F_D = np.array([12.49759413, 49.99037650, 158.94693786])

945 np.testing.assert_allclose(

946 eotf_BT2100_HLG_2(E_p), F_D, atol=TOLERANCE_ABSOLUTE_TESTS

947 )

948

949 E_p = np.tile(E_p, (6, 1))

950 F_D = np.tile(F_D, (6, 1))

951 np.testing.assert_allclose(

952 eotf_BT2100_HLG_2(E_p), F_D, atol=TOLERANCE_ABSOLUTE_TESTS

953 )

954

955 E_p = np.reshape(E_p, (2, 3, 3))

956 F_D = np.reshape(F_D, (2, 3, 3))

957 np.testing.assert_allclose(

958 eotf_BT2100_HLG_2(E_p), F_D, atol=TOLERANCE_ABSOLUTE_TESTS

959 )

960

961 def test_domain_range_scale_eotf_BT2100_HLG_2(self) -> None:

962 """

963 Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\

964 eotf_BT2100_HLG_2` definition domain and range scale support.

965 """

966

967 E_p = 0.212132034355964

968 F_D = eotf_BT2100_HLG_2(E_p)

969

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

971 for scale, factor in d_r:

972 with domain_range_scale(scale):

973 np.testing.assert_allclose(

974 eotf_BT2100_HLG_2(E_p * factor),

975 F_D * factor,

976 atol=TOLERANCE_ABSOLUTE_TESTS,

977 )

978

979 @ignore_numpy_errors

980 def test_nan_eotf_BT2100_HLG_2(self) -> None:

981 """

982 Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\

983 eotf_BT2100_HLG_2` definition nan support.

984 """

985

986 eotf_BT2100_HLG_2(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan]))

987

988

989 class TestEotf_inverse_BT2100_HLG_1:

990 """

991 Define :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\

992 eotf_inverse_BT2100_HLG_1` definition unit tests methods.

993 """

994

995 def test_eotf_inverse_BT2100_HLG_1(self) -> None:

996 """

997 Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\

998 eotf_inverse_BT2100_HLG_1` definition.

999 """

1000

1001 np.testing.assert_allclose(

1002 eotf_inverse_BT2100_HLG_1(0.0), 0.0, atol=TOLERANCE_ABSOLUTE_TESTS

1003 )

1004

1005 np.testing.assert_allclose(

1006 eotf_inverse_BT2100_HLG_1(6.476039825649814),

1007 0.212132034355964,

1008 atol=TOLERANCE_ABSOLUTE_TESTS,

1009 )

1010

1011 np.testing.assert_allclose(

1012 eotf_inverse_BT2100_HLG_1(1000.000032321769100),

1013 1.0,

1014 atol=TOLERANCE_ABSOLUTE_TESTS,

1015 )

1016

1017 np.testing.assert_allclose(

1018 eotf_inverse_BT2100_HLG_1(27.96039175299561, 0.001, 10000, 1.4),

1019 0.212132034355964,

1020 atol=TOLERANCE_ABSOLUTE_TESTS,

1021 )

1022

1023 def test_n_dimensional_eotf_inverse_BT2100_HLG_1(self) -> None:

1024 """

1025 Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\

1026 eotf_inverse_BT2100_HLG_1` definition n-dimensional arrays support.

1027 """

1028

1029 F_D = 6.476039825649814

1030 E_p = eotf_inverse_BT2100_HLG_1(F_D)

1031

1032 F_D = np.tile(F_D, 6)

1033 E_p = np.tile(E_p, 6)

1034 np.testing.assert_allclose(

1035 eotf_inverse_BT2100_HLG_1(F_D), E_p, atol=TOLERANCE_ABSOLUTE_TESTS

1036 )

1037

1038 F_D = np.reshape(F_D, (2, 3))

1039 E_p = np.reshape(E_p, (2, 3))

1040 np.testing.assert_allclose(

1041 eotf_inverse_BT2100_HLG_1(F_D), E_p, atol=TOLERANCE_ABSOLUTE_TESTS

1042 )

1043

1044 F_D = np.reshape(F_D, (2, 3, 1))

1045 E_p = np.reshape(E_p, (2, 3, 1))

1046 np.testing.assert_allclose(

1047 eotf_inverse_BT2100_HLG_1(F_D), E_p, atol=TOLERANCE_ABSOLUTE_TESTS

1048 )

1049

1050 F_D = np.reshape(F_D, (6, 1))

1051 E_p = np.reshape(E_p, (6, 1))

1052 np.testing.assert_allclose(

1053 eotf_inverse_BT2100_HLG_1(F_D), E_p, atol=TOLERANCE_ABSOLUTE_TESTS

1054 )

1055

1056 F_D = np.array([12.49759413, 49.99037650, 158.94693786])

1057 E_p = np.array([0.25, 0.50, 0.75])

1058 np.testing.assert_allclose(

1059 eotf_inverse_BT2100_HLG_1(F_D), E_p, atol=TOLERANCE_ABSOLUTE_TESTS

1060 )

1061

1062 F_D = np.tile(F_D, (6, 1))

1063 E_p = np.tile(E_p, (6, 1))

1064 np.testing.assert_allclose(

1065 eotf_inverse_BT2100_HLG_1(F_D), E_p, atol=TOLERANCE_ABSOLUTE_TESTS

1066 )

1067

1068 F_D = np.reshape(F_D, (2, 3, 3))

1069 E_p = np.reshape(E_p, (2, 3, 3))

1070 np.testing.assert_allclose(

1071 eotf_inverse_BT2100_HLG_1(F_D), E_p, atol=TOLERANCE_ABSOLUTE_TESTS

1072 )

1073

1074 def test_domain_range_scale_eotf_inverse_BT2100_HLG_1(self) -> None:

1075 """

1076 Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\

1077 eotf_inverse_BT2100_HLG_1` definition domain and range scale support.

1078 """

1079

1080 F_D = 6.476039825649814

1081 E_p = eotf_inverse_BT2100_HLG_1(F_D)

1082

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

1084 for scale, factor in d_r:

1085 with domain_range_scale(scale):

1086 np.testing.assert_allclose(

1087 eotf_inverse_BT2100_HLG_1(F_D * factor),

1088 E_p * factor,

1089 atol=TOLERANCE_ABSOLUTE_TESTS,

1090 )

1091

1092 @ignore_numpy_errors

1093 def test_nan_eotf_inverse_BT2100_HLG_1(self) -> None:

1094 """

1095 Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\

1096 eotf_inverse_BT2100_HLG_1` definition nan support.

1097 """

1098

1099 eotf_inverse_BT2100_HLG_1(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan]))

1100

1101

1102 class TestEotf_inverse_BT2100_HLG_2:

1103 """

1104 Define :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\

1105 eotf_inverse_BT2100_HLG_2` definition unit tests methods.

1106 """

1107

1108 def test_eotf_inverse_BT2100_HLG_2(self) -> None:

1109 """

1110 Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\

1111 eotf_inverse_BT2100_HLG_2` definition.

1112 """

1113

1114 np.testing.assert_allclose(

1115 eotf_inverse_BT2100_HLG_2(0.0), 0.0, atol=TOLERANCE_ABSOLUTE_TESTS

1116 )

1117

1118 np.testing.assert_allclose(

1119 eotf_inverse_BT2100_HLG_2(6.476039825649814),

1120 0.212132034355964,

1121 atol=TOLERANCE_ABSOLUTE_TESTS,

1122 )

1123

1124 np.testing.assert_allclose(

1125 eotf_inverse_BT2100_HLG_2(1000.000032321769100),

1126 1.0,

1127 atol=TOLERANCE_ABSOLUTE_TESTS,

1128 )

1129

1130 np.testing.assert_allclose(

1131 eotf_inverse_BT2100_HLG_2(29.581261576946076, 0.001, 10000, 1.4),

1132 0.212132034355964,

1133 atol=TOLERANCE_ABSOLUTE_TESTS,

1134 )

1135

1136 def test_n_dimensional_eotf_inverse_BT2100_HLG_2(self) -> None:

1137 """

1138 Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\

1139 eotf_inverse_BT2100_HLG_2` definition n-dimensional arrays support.

1140 """

1141

1142 F_D = 6.476039825649814

1143 E_p = eotf_inverse_BT2100_HLG_2(F_D)

1144

1145 F_D = np.tile(F_D, 6)

1146 E_p = np.tile(E_p, 6)

1147 np.testing.assert_allclose(

1148 eotf_inverse_BT2100_HLG_2(F_D), E_p, atol=TOLERANCE_ABSOLUTE_TESTS

1149 )

1150

1151 F_D = np.reshape(F_D, (2, 3))

1152 E_p = np.reshape(E_p, (2, 3))

1153 np.testing.assert_allclose(

1154 eotf_inverse_BT2100_HLG_2(F_D), E_p, atol=TOLERANCE_ABSOLUTE_TESTS

1155 )

1156

1157 F_D = np.reshape(F_D, (2, 3, 1))

1158 E_p = np.reshape(E_p, (2, 3, 1))

1159 np.testing.assert_allclose(

1160 eotf_inverse_BT2100_HLG_2(F_D), E_p, atol=TOLERANCE_ABSOLUTE_TESTS

1161 )

1162

1163 F_D = np.reshape(F_D, (6, 1))

1164 E_p = np.reshape(E_p, (6, 1))

1165 np.testing.assert_allclose(

1166 eotf_inverse_BT2100_HLG_2(F_D), E_p, atol=TOLERANCE_ABSOLUTE_TESTS

1167 )

1168

1169 F_D = np.array([12.49759413, 49.99037650, 158.94693786])

1170 E_p = np.array([0.25, 0.50, 0.75])

1171 np.testing.assert_allclose(

1172 eotf_inverse_BT2100_HLG_2(F_D), E_p, atol=TOLERANCE_ABSOLUTE_TESTS

1173 )

1174

1175 F_D = np.tile(F_D, (6, 1))

1176 E_p = np.tile(E_p, (6, 1))

1177 np.testing.assert_allclose(

1178 eotf_inverse_BT2100_HLG_2(F_D), E_p, atol=TOLERANCE_ABSOLUTE_TESTS

1179 )

1180

1181 F_D = np.reshape(F_D, (2, 3, 3))

1182 E_p = np.reshape(E_p, (2, 3, 3))

1183 np.testing.assert_allclose(

1184 eotf_inverse_BT2100_HLG_2(F_D), E_p, atol=TOLERANCE_ABSOLUTE_TESTS

1185 )

1186

1187 def test_domain_range_scale_eotf_inverse_BT2100_HLG_2(self) -> None:

1188 """

1189 Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\

1190 eotf_inverse_BT2100_HLG_2` definition domain and range scale support.

1191 """

1192

1193 F_D = 6.476039825649814

1194 E_p = eotf_inverse_BT2100_HLG_2(F_D)

1195

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

1197 for scale, factor in d_r:

1198 with domain_range_scale(scale):

1199 np.testing.assert_allclose(

1200 eotf_inverse_BT2100_HLG_2(F_D * factor),

1201 E_p * factor,

1202 atol=TOLERANCE_ABSOLUTE_TESTS,

1203 )

1204

1205 @ignore_numpy_errors

1206 def test_nan_eotf_inverse_BT2100_HLG_2(self) -> None:

1207 """

1208 Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\

1209 eotf_inverse_BT2100_HLG_2` definition nan support.

1210 """

1211

1212 eotf_inverse_BT2100_HLG_2(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan]))

1213

1214

1215 class TestOotf_BT2100_HLG_1:

1216 """

1217 Define :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\

1218 ootf_BT2100_HLG_1` definition unit tests methods.

1219 """

1220

1221 def test_ootf_BT2100_HLG_1(self) -> None:

1222 """

1223 Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\

1224 ootf_BT2100_HLG_1` definition.

1225 """

1226

1227 np.testing.assert_allclose(

1228 ootf_BT2100_HLG_1(0.0), 0.0, atol=TOLERANCE_ABSOLUTE_TESTS

1229 )

1230

1231 np.testing.assert_allclose(

1232 ootf_BT2100_HLG_1(0.1),

1233 63.095734448019336,

1234 atol=TOLERANCE_ABSOLUTE_TESTS,

1235 )

1236

1237 np.testing.assert_allclose(

1238 ootf_BT2100_HLG_1(1.0), 1000.0, atol=TOLERANCE_ABSOLUTE_TESTS

1239 )

1240

1241 np.testing.assert_allclose(

1242 ootf_BT2100_HLG_1(0.1, 0.001, 10000, 1.4),

1243 398.108130742780300,

1244 atol=TOLERANCE_ABSOLUTE_TESTS,

1245 )

1246

1247 a = np.array(

1248 [

1249 [45.884942278760597, 0.000000000000000, -45.884942278760597],

1250 [

1251 -63.095734448019336,

1252 -63.095734448019336,

1253 -63.095734448019336,

1254 ],

1255 [63.095734448019336, 63.095734448019336, 63.095734448019336],

1256 [51.320396090100672, -51.320396090100672, 51.320396090100672],

1257 ],

1258 )

1259 np.testing.assert_allclose(

1260 ootf_BT2100_HLG_1(

1261 np.array(

1262 [

1263 [0.1, 0.0, -0.1],

1264 [-0.1, -0.1, -0.1],

1265 [0.1, 0.1, 0.1],

1266 [0.1, -0.1, 0.1],

1267 ]

1268 )

1269 ),

1270 a,

1271 atol=TOLERANCE_ABSOLUTE_TESTS,

1272 )

1273

1274 def test_n_dimensional_ootf_BT2100_HLG_1(self) -> None:

1275 """

1276 Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\

1277 ootf_BT2100_HLG_1` definition n-dimensional arrays support.

1278 """

1279

1280 E = 0.1

1281 F_D = ootf_BT2100_HLG_1(E)

1282

1283 E = np.tile(E, 6)

1284 F_D = np.tile(F_D, 6)

1285 np.testing.assert_allclose(

1286 ootf_BT2100_HLG_1(E), F_D, atol=TOLERANCE_ABSOLUTE_TESTS

1287 )

1288

1289 E = np.reshape(E, (2, 3))

1290 F_D = np.reshape(F_D, (2, 3))

1291 np.testing.assert_allclose(

1292 ootf_BT2100_HLG_1(E), F_D, atol=TOLERANCE_ABSOLUTE_TESTS

1293 )

1294

1295 E = np.reshape(E, (2, 3, 1))

1296 F_D = np.reshape(F_D, (2, 3, 1))

1297 np.testing.assert_allclose(

1298 ootf_BT2100_HLG_1(E), F_D, atol=TOLERANCE_ABSOLUTE_TESTS

1299 )

1300

1301 E = np.reshape(E, (6, 1))

1302 F_D = np.reshape(F_D, (6, 1))

1303 np.testing.assert_allclose(

1304 ootf_BT2100_HLG_1(E), F_D, atol=TOLERANCE_ABSOLUTE_TESTS

1305 )

1306

1307 E = np.array([0.25, 0.50, 0.75])

1308 F_D = np.array([213.01897444, 426.03794887, 639.05692331])

1309 np.testing.assert_allclose(

1310 ootf_BT2100_HLG_1(E), F_D, atol=TOLERANCE_ABSOLUTE_TESTS

1311 )

1312

1313 E = np.tile(E, (6, 1))

1314 F_D = np.tile(F_D, (6, 1))

1315 np.testing.assert_allclose(

1316 ootf_BT2100_HLG_1(E), F_D, atol=TOLERANCE_ABSOLUTE_TESTS

1317 )

1318

1319 E = np.reshape(E, (2, 3, 3))

1320 F_D = np.reshape(F_D, (2, 3, 3))

1321 np.testing.assert_allclose(

1322 ootf_BT2100_HLG_1(E), F_D, atol=TOLERANCE_ABSOLUTE_TESTS

1323 )

1324

1325 def test_domain_range_scale_ootf_BT2100_HLG_1(self) -> None:

1326 """

1327 Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\

1328 ootf_BT2100_HLG_1` definition domain and range scale support.

1329 """

1330

1331 E = 0.1

1332 F_D = ootf_BT2100_HLG_1(E)

1333

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

1335 for scale, factor in d_r:

1336 with domain_range_scale(scale):

1337 np.testing.assert_allclose(

1338 ootf_BT2100_HLG_1(E * factor),

1339 F_D * factor,

1340 atol=TOLERANCE_ABSOLUTE_TESTS,

1341 )

1342

1343 @ignore_numpy_errors

1344 def test_nan_ootf_BT2100_HLG_1(self) -> None:

1345 """

1346 Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\

1347 ootf_BT2100_HLG_1` definition nan support.

1348 """

1349

1350 ootf_BT2100_HLG_1(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan]))

1351

1352

1353 class TestOotf_BT2100_HLG_2:

1354 """

1355 Define :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\

1356 ootf_BT2100_HLG_2` definition unit tests methods.

1357 """

1358

1359 def test_ootf_BT2100_HLG_2(self) -> None:

1360 """

1361 Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\

1362 ootf_BT2100_HLG_2` definition.

1363 """

1364

1365 np.testing.assert_allclose(

1366 ootf_BT2100_HLG_2(0.0), 0.0, atol=TOLERANCE_ABSOLUTE_TESTS

1367 )

1368

1369 np.testing.assert_allclose(

1370 ootf_BT2100_HLG_2(0.1),

1371 63.095734448019336,

1372 atol=TOLERANCE_ABSOLUTE_TESTS,

1373 )

1374

1375 np.testing.assert_allclose(

1376 ootf_BT2100_HLG_2(1.0), 1000.0, atol=TOLERANCE_ABSOLUTE_TESTS

1377 )

1378

1379 np.testing.assert_allclose(

1380 ootf_BT2100_HLG_2(0.1, 10000, 1.4),

1381 398.107170553497380,

1382 atol=TOLERANCE_ABSOLUTE_TESTS,

1383 )

1384

1385 a = np.array(

1386 [

1387 [45.884942278760597, 0.000000000000000, -45.884942278760597],

1388 [

1389 -63.095734448019336,

1390 -63.095734448019336,

1391 -63.095734448019336,

1392 ],

1393 [63.095734448019336, 63.095734448019336, 63.095734448019336],

1394 [51.320396090100672, -51.320396090100672, 51.320396090100672],

1395 ],

1396 )

1397 np.testing.assert_allclose(

1398 ootf_BT2100_HLG_2(

1399 np.array(

1400 [

1401 [0.1, 0.0, -0.1],

1402 [-0.1, -0.1, -0.1],

1403 [0.1, 0.1, 0.1],

1404 [0.1, -0.1, 0.1],

1405 ]

1406 )

1407 ),

1408 a,

1409 atol=TOLERANCE_ABSOLUTE_TESTS,

1410 )

1411

1412 def test_n_dimensional_ootf_BT2100_HLG_2(self) -> None:

1413 """

1414 Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\

1415 ootf_BT2100_HLG_2` definition n-dimensional arrays support.

1416 """

1417

1418 E = 0.1

1419 F_D = ootf_BT2100_HLG_2(E)

1420

1421 E = np.tile(E, 6)

1422 F_D = np.tile(F_D, 6)

1423 np.testing.assert_allclose(

1424 ootf_BT2100_HLG_2(E), F_D, atol=TOLERANCE_ABSOLUTE_TESTS

1425 )

1426

1427 E = np.reshape(E, (2, 3))

1428 F_D = np.reshape(F_D, (2, 3))

1429 np.testing.assert_allclose(

1430 ootf_BT2100_HLG_2(E), F_D, atol=TOLERANCE_ABSOLUTE_TESTS

1431 )

1432

1433 E = np.reshape(E, (2, 3, 1))

1434 F_D = np.reshape(F_D, (2, 3, 1))

1435 np.testing.assert_allclose(

1436 ootf_BT2100_HLG_2(E), F_D, atol=TOLERANCE_ABSOLUTE_TESTS

1437 )

1438

1439 E = np.reshape(E, (6, 1))

1440 F_D = np.reshape(F_D, (6, 1))

1441 np.testing.assert_allclose(

1442 ootf_BT2100_HLG_2(E), F_D, atol=TOLERANCE_ABSOLUTE_TESTS

1443 )

1444

1445 E = np.array([0.25, 0.50, 0.75])

1446 F_D = np.array([213.01897444, 426.03794887, 639.05692331])

1447 np.testing.assert_allclose(

1448 ootf_BT2100_HLG_2(E), F_D, atol=TOLERANCE_ABSOLUTE_TESTS

1449 )

1450

1451 E = np.tile(E, (6, 1))

1452 F_D = np.tile(F_D, (6, 1))

1453 np.testing.assert_allclose(

1454 ootf_BT2100_HLG_2(E), F_D, atol=TOLERANCE_ABSOLUTE_TESTS

1455 )

1456

1457 E = np.reshape(E, (2, 3, 3))

1458 F_D = np.reshape(F_D, (2, 3, 3))

1459 np.testing.assert_allclose(

1460 ootf_BT2100_HLG_2(E), F_D, atol=TOLERANCE_ABSOLUTE_TESTS

1461 )

1462

1463 def test_domain_range_scale_ootf_BT2100_HLG_2(self) -> None:

1464 """

1465 Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\

1466 ootf_BT2100_HLG_2` definition domain and range scale support.

1467 """

1468

1469 E = 0.1

1470 F_D = ootf_BT2100_HLG_1(E)

1471

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

1473 for scale, factor in d_r:

1474 with domain_range_scale(scale):

1475 np.testing.assert_allclose(

1476 ootf_BT2100_HLG_1(E * factor),

1477 F_D * factor,

1478 atol=TOLERANCE_ABSOLUTE_TESTS,

1479 )

1480

1481 @ignore_numpy_errors

1482 def test_nan_ootf_BT2100_HLG_1(self) -> None:

1483 """

1484 Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\

1485 ootf_BT2100_HLG_1` definition nan support.

1486 """

1487

1488 ootf_BT2100_HLG_1(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan]))

1489

1490

1491 class TestOotf_inverse_BT2100_HLG_1:

1492 """

1493 Define :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\

1494 ootf_inverse_BT2100_HLG_1` definition unit tests methods.

1495 """

1496

1497 def test_ootf_inverse_BT2100_HLG_1(self) -> None:

1498 """

1499 Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\

1500 ootf_inverse_BT2100_HLG_1` definition.

1501 """

1502

1503 np.testing.assert_allclose(

1504 ootf_inverse_BT2100_HLG_1(0.0), 0.0, atol=TOLERANCE_ABSOLUTE_TESTS

1505 )

1506

1507 np.testing.assert_allclose(

1508 ootf_inverse_BT2100_HLG_1(63.095734448019336),

1509 0.1,

1510 atol=TOLERANCE_ABSOLUTE_TESTS,

1511 )

1512

1513 np.testing.assert_allclose(

1514 ootf_inverse_BT2100_HLG_1(1000.0),

1515 1.0,

1516 atol=TOLERANCE_ABSOLUTE_TESTS,

1517 )

1518

1519 np.testing.assert_allclose(

1520 ootf_inverse_BT2100_HLG_1(398.108130742780300, 0.001, 10000, 1.4),

1521 0.1,

1522 atol=TOLERANCE_ABSOLUTE_TESTS,

1523 )

1524

1525 a = np.array(

1526 [

1527 [45.884942278760597, 0.000000000000000, -45.884942278760597],

1528 [

1529 -63.095734448019336,

1530 -63.095734448019336,

1531 -63.095734448019336,

1532 ],

1533 [63.095734448019336, 63.095734448019336, 63.095734448019336],

1534 [51.320396090100672, -51.320396090100672, 51.320396090100672],

1535 ]

1536 )

1537 np.testing.assert_allclose(

1538 ootf_inverse_BT2100_HLG_1(a),

1539 np.array(

1540 [

1541 [0.1, 0.0, -0.1],

1542 [-0.1, -0.1, -0.1],

1543 [0.1, 0.1, 0.1],

1544 [0.1, -0.1, 0.1],

1545 ]

1546 ),

1547 atol=TOLERANCE_ABSOLUTE_TESTS,

1548 )

1549

1550 def test_n_dimensional_ootf_inverse_BT2100_HLG_1(self) -> None:

1551 """

1552 Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\

1553 ootf_inverse_BT2100_HLG_1` definition n-dimensional arrays support.

1554 """

1555

1556 F_D = 63.095734448019336

1557 E = ootf_inverse_BT2100_HLG_1(F_D)

1558

1559 F_D = np.tile(F_D, 6)

1560 E = np.tile(E, 6)

1561 np.testing.assert_allclose(

1562 ootf_inverse_BT2100_HLG_1(F_D), E, atol=TOLERANCE_ABSOLUTE_TESTS

1563 )

1564

1565 F_D = np.reshape(F_D, (2, 3))

1566 E = np.reshape(E, (2, 3))

1567 np.testing.assert_allclose(

1568 ootf_inverse_BT2100_HLG_1(F_D), E, atol=TOLERANCE_ABSOLUTE_TESTS

1569 )

1570

1571 F_D = np.reshape(F_D, (2, 3, 1))

1572 E = np.reshape(E, (2, 3, 1))

1573 np.testing.assert_allclose(

1574 ootf_inverse_BT2100_HLG_1(F_D), E, atol=TOLERANCE_ABSOLUTE_TESTS

1575 )

1576

1577 F_D = np.reshape(F_D, (6, 1))

1578 E = np.reshape(E, (6, 1))

1579 np.testing.assert_allclose(

1580 ootf_inverse_BT2100_HLG_1(F_D), E, atol=TOLERANCE_ABSOLUTE_TESTS

1581 )

1582

1583 F_D = np.array([213.01897444, 426.03794887, 639.05692331])

1584 E = np.array([0.25, 0.50, 0.75])

1585 np.testing.assert_allclose(

1586 ootf_inverse_BT2100_HLG_1(F_D), E, atol=TOLERANCE_ABSOLUTE_TESTS

1587 )

1588

1589 F_D = np.tile(F_D, (6, 1))

1590 E = np.tile(E, (6, 1))

1591 np.testing.assert_allclose(

1592 ootf_inverse_BT2100_HLG_1(F_D), E, atol=TOLERANCE_ABSOLUTE_TESTS

1593 )

1594

1595 F_D = np.reshape(F_D, (2, 3, 3))

1596 E = np.reshape(E, (2, 3, 3))

1597 np.testing.assert_allclose(

1598 ootf_inverse_BT2100_HLG_1(F_D), E, atol=TOLERANCE_ABSOLUTE_TESTS

1599 )

1600

1601 def test_domain_range_scale_ootf_inverse_BT2100_HLG_1(self) -> None:

1602 """

1603 Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\

1604 ootf_inverse_BT2100_HLG_1` definition domain and range scale support.

1605 """

1606

1607 F_D = 63.095734448019336

1608 E = ootf_inverse_BT2100_HLG_1(F_D)

1609

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

1611 for scale, factor in d_r:

1612 with domain_range_scale(scale):

1613 np.testing.assert_allclose(

1614 ootf_inverse_BT2100_HLG_1(F_D * factor),

1615 E * factor,

1616 atol=TOLERANCE_ABSOLUTE_TESTS,

1617 )

1618

1619 @ignore_numpy_errors

1620 def test_nan_ootf_inverse_BT2100_HLG_1(self) -> None:

1621 """

1622 Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\

1623 ootf_inverse_BT2100_HLG_1` definition nan support.

1624 """

1625

1626 ootf_inverse_BT2100_HLG_1(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan]))

1627

1628

1629 class TestOotf_inverse_BT2100_HLG_2:

1630 """

1631 Define :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\

1632 ootf_inverse_BT2100_HLG_2` definition unit tests methods.

1633 """

1634

1635 def test_ootf_inverse_BT2100_HLG_2(self) -> None:

1636 """

1637 Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\

1638 ootf_inverse_BT2100_HLG_2` definition.

1639 """

1640

1641 np.testing.assert_allclose(

1642 ootf_inverse_BT2100_HLG_2(0.0), 0.0, atol=TOLERANCE_ABSOLUTE_TESTS

1643 )

1644

1645 np.testing.assert_allclose(

1646 ootf_inverse_BT2100_HLG_2(63.095734448019336),

1647 0.1,

1648 atol=TOLERANCE_ABSOLUTE_TESTS,

1649 )

1650

1651 np.testing.assert_allclose(

1652 ootf_inverse_BT2100_HLG_2(1000.0),

1653 1.0,

1654 atol=TOLERANCE_ABSOLUTE_TESTS,

1655 )

1656

1657 np.testing.assert_allclose(

1658 ootf_inverse_BT2100_HLG_2(398.107170553497380, 10000, 1.4),

1659 0.1,

1660 atol=TOLERANCE_ABSOLUTE_TESTS,

1661 )

1662

1663 a = np.array(

1664 [

1665 [45.884942278760597, 0.000000000000000, -45.884942278760597],

1666 [

1667 -63.095734448019336,

1668 -63.095734448019336,

1669 -63.095734448019336,

1670 ],

1671 [63.095734448019336, 63.095734448019336, 63.095734448019336],

1672 [51.320396090100672, -51.320396090100672, 51.320396090100672],

1673 ]

1674 )

1675 np.testing.assert_allclose(

1676 ootf_inverse_BT2100_HLG_2(a),

1677 np.array(

1678 [

1679 [0.1, 0.0, -0.1],

1680 [-0.1, -0.1, -0.1],

1681 [0.1, 0.1, 0.1],

1682 [0.1, -0.1, 0.1],

1683 ]

1684 ),

1685 atol=TOLERANCE_ABSOLUTE_TESTS,

1686 )

1687

1688 def test_n_dimensional_ootf_inverse_BT2100_HLG_2(self) -> None:

1689 """

1690 Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\

1691 ootf_inverse_BT2100_HLG_2` definition n-dimensional arrays support.

1692 """

1693

1694 F_D = 63.095734448019336

1695 E = ootf_inverse_BT2100_HLG_2(F_D)

1696

1697 F_D = np.tile(F_D, 6)

1698 E = np.tile(E, 6)

1699 np.testing.assert_allclose(

1700 ootf_inverse_BT2100_HLG_2(F_D), E, atol=TOLERANCE_ABSOLUTE_TESTS

1701 )

1702

1703 F_D = np.reshape(F_D, (2, 3))

1704 E = np.reshape(E, (2, 3))

1705 np.testing.assert_allclose(

1706 ootf_inverse_BT2100_HLG_2(F_D), E, atol=TOLERANCE_ABSOLUTE_TESTS

1707 )

1708

1709 F_D = np.reshape(F_D, (2, 3, 1))

1710 E = np.reshape(E, (2, 3, 1))

1711 np.testing.assert_allclose(

1712 ootf_inverse_BT2100_HLG_2(F_D), E, atol=TOLERANCE_ABSOLUTE_TESTS

1713 )

1714

1715 F_D = np.reshape(F_D, (6, 1))

1716 E = np.reshape(E, (6, 1))

1717 np.testing.assert_allclose(

1718 ootf_inverse_BT2100_HLG_2(F_D), E, atol=TOLERANCE_ABSOLUTE_TESTS

1719 )

1720

1721 F_D = np.array([213.01897444, 426.03794887, 639.05692331])

1722 E = np.array([0.25, 0.50, 0.75])

1723 np.testing.assert_allclose(

1724 ootf_inverse_BT2100_HLG_2(F_D), E, atol=TOLERANCE_ABSOLUTE_TESTS

1725 )

1726

1727 F_D = np.tile(F_D, (6, 1))

1728 E = np.tile(E, (6, 1))

1729 np.testing.assert_allclose(

1730 ootf_inverse_BT2100_HLG_2(F_D), E, atol=TOLERANCE_ABSOLUTE_TESTS

1731 )

1732

1733 F_D = np.reshape(F_D, (2, 3, 3))

1734 E = np.reshape(E, (2, 3, 3))

1735 np.testing.assert_allclose(

1736 ootf_inverse_BT2100_HLG_2(F_D), E, atol=TOLERANCE_ABSOLUTE_TESTS

1737 )

1738

1739 def test_domain_range_scale_ootf_inverse_BT2100_HLG_2(self) -> None:

1740 """

1741 Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\

1742 ootf_inverse_BT2100_HLG_2` definition domain and range scale support.

1743 """

1744

1745 F_D = 63.095734448019336

1746 E = ootf_inverse_BT2100_HLG_2(F_D)

1747

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

1749 for scale, factor in d_r:

1750 with domain_range_scale(scale):

1751 np.testing.assert_allclose(

1752 ootf_inverse_BT2100_HLG_2(F_D * factor),

1753 E * factor,

1754 atol=TOLERANCE_ABSOLUTE_TESTS,

1755 )

1756

1757 @ignore_numpy_errors

1758 def test_nan_ootf_inverse_BT2100_HLG_2(self) -> None:

1759 """

1760 Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\

1761 ootf_inverse_BT2100_HLG_2` definition nan support.

1762 """

1763

1764 ootf_inverse_BT2100_HLG_2(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan]))