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

1"""

2 Define the unit tests for the

3:mod:`colour.models.rgb.transfer_functions.itut_h_273` 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_H273_ST428_1,

11 eotf_inverse_H273_ST428_1,

12 oetf_H273_IEC61966_2,

13 oetf_H273_Log,

14 oetf_H273_LogSqrt,

15 oetf_inverse_H273_IEC61966_2,

16 oetf_inverse_H273_Log,

17 oetf_inverse_H273_LogSqrt,

18)

19 from colour.utilities import domain_range_scale, ignore_numpy_errors

20

21 __author__ = "Colour Developers"

22 __copyright__ = "Copyright 2013 Colour Developers"

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

24 __maintainer__ = "Colour Developers"

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

26 __status__ = "Production"

27

28 __all__ = [

29 "TestOetf_H273_Log",

30 "TestOetf_inverse_H273_Log",

31 "TestOetf_H273_LogSqrt",

32 "TestOetf_inverse_H273_LogSqrt",

33 "TestOetf_H273_IEC61966_2",

34 "TestOetf_inverse_H273_IEC61966_2",

35 "TestEotf_inverse_H273_ST428_1",

36 "TestEotf_H273_ST428_1",

37]

38

39

40 class TestOetf_H273_Log:

41 """

42 Define :func:`colour.models.rgb.transfer_functions.itut_h_273.

43 oetf_H273_Log` definition unit tests methods.

44 """

45

46 def test_oetf_H273_Log(self) -> None:

47 """

48 Test :func:`colour.models.rgb.transfer_functions.itut_h_273.\

49 oetf_H273_Log` definition.

50 """

51

52 np.testing.assert_allclose(

53 oetf_H273_Log(0.0), 0.0, atol=TOLERANCE_ABSOLUTE_TESTS

54 )

55

56 np.testing.assert_allclose(

57 oetf_H273_Log(0.18),

58 0.627636252551653,

59 atol=TOLERANCE_ABSOLUTE_TESTS,

60 )

61

62 np.testing.assert_allclose(

63 oetf_H273_Log(1.0), 1.0, atol=TOLERANCE_ABSOLUTE_TESTS

64 )

65

66 def test_n_dimensional_oetf_H273_Log(self) -> None:

67 """

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

69 oetf_H273_Log` definition n-dimensional arrays support.

70 """

71

72 E = 0.18

73 E_p = oetf_H273_Log(E)

74

75 E = np.tile(E, 6)

76 E_p = np.tile(E_p, 6)

77 np.testing.assert_allclose(oetf_H273_Log(E), E_p, atol=TOLERANCE_ABSOLUTE_TESTS)

78

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

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

81 np.testing.assert_allclose(oetf_H273_Log(E), E_p, atol=TOLERANCE_ABSOLUTE_TESTS)

82

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

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

85 np.testing.assert_allclose(oetf_H273_Log(E), E_p, atol=TOLERANCE_ABSOLUTE_TESTS)

86

87 def test_domain_range_scale_oetf_H273_Log(self) -> None:

88 """

89 Test :func:`colour.models.rgb.transfer_functions.itut_h_273.\

90 oetf_H273_Log` definition domain and range scale support.

91 """

92

93 E = 0.18

94 E_p = oetf_H273_Log(E)

95

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

97 for scale, factor in d_r:

98 with domain_range_scale(scale):

99 np.testing.assert_allclose(

100 oetf_H273_Log(E * factor),

101 E_p * factor,

102 atol=TOLERANCE_ABSOLUTE_TESTS,

103 )

104

105 @ignore_numpy_errors

106 def test_nan_oetf_H273_Log(self) -> None:

107 """

108 Test :func:`colour.models.rgb.transfer_functions.itut_h_273.\

109 oetf_H273_Log` definition nan support.

110 """

111

112 oetf_H273_Log(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan]))

113

114

115 class TestOetf_inverse_H273_Log:

116 """

117 Define :func:`colour.models.rgb.transfer_functions.itut_h_273.\

118 oetf_inverse_H273_Log` definition unit tests methods.

119 """

120

121 def test_oetf_inverse_H273_Log(self) -> None:

122 """

123 Test :func:`colour.models.rgb.transfer_functions.itut_h_273.\

124 oetf_inverse_H273_Log` definition.

125 """

126

127 # NOTE: The function is unfortunately clamped and cannot roundtrip

128 # properly.

129 np.testing.assert_allclose(

130 oetf_inverse_H273_Log(0.0), 0.01, atol=TOLERANCE_ABSOLUTE_TESTS

131 )

132

133 np.testing.assert_allclose(

134 oetf_inverse_H273_Log(0.627636252551653),

135 0.18,

136 atol=TOLERANCE_ABSOLUTE_TESTS,

137 )

138

139 np.testing.assert_allclose(

140 oetf_inverse_H273_Log(1.0), 1.0, atol=TOLERANCE_ABSOLUTE_TESTS

141 )

142

143 def test_n_dimensional_oetf_inverse_H273_Log(self) -> None:

144 """

145 Test :func:`colour.models.rgb.transfer_functions.itut_h_273.\

146 oetf_inverse_H273_Log` definition n-dimensional arrays support.

147 """

148

149 E_p = 0.627636252551653

150 E = oetf_inverse_H273_Log(E_p)

151

152 E_p = np.tile(E_p, 6)

153 E = np.tile(E, 6)

154 np.testing.assert_allclose(

155 oetf_inverse_H273_Log(E_p), E, atol=TOLERANCE_ABSOLUTE_TESTS

156 )

157

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

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

160 np.testing.assert_allclose(

161 oetf_inverse_H273_Log(E_p), E, atol=TOLERANCE_ABSOLUTE_TESTS

162 )

163

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

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

166 np.testing.assert_allclose(

167 oetf_inverse_H273_Log(E_p), E, atol=TOLERANCE_ABSOLUTE_TESTS

168 )

169

170 def test_domain_range_scale_oetf_inverse_H273_Log(self) -> None:

171 """

172 Test :func:`colour.models.rgb.transfer_functions.itut_h_273.\

173 oetf_inverse_H273_Log` definition domain and range scale support.

174 """

175

176 E_p = 0.627636252551653

177 E = oetf_inverse_H273_Log(E_p)

178

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

180 for scale, factor in d_r:

181 with domain_range_scale(scale):

182 np.testing.assert_allclose(

183 oetf_inverse_H273_Log(E_p * factor),

184 E * factor,

185 atol=TOLERANCE_ABSOLUTE_TESTS,

186 )

187

188 @ignore_numpy_errors

189 def test_nan_oetf_inverse_H273_Log(self) -> None:

190 """

191 Test :func:`colour.models.rgb.transfer_functions.itut_h_273.\

192 oetf_inverse_H273_Log` definition nan support.

193 """

194

195 oetf_inverse_H273_Log(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan]))

196

197

198 class TestOetf_H273_LogSqrt:

199 """

200 Define :func:`colour.models.rgb.transfer_functions.itut_h_273.

201 oetf_H273_LogSqrt` definition unit tests methods.

202 """

203

204 def test_oetf_H273_LogSqrt(self) -> None:

205 """

206 Test :func:`colour.models.rgb.transfer_functions.itut_h_273.\

207 oetf_H273_LogSqrt` definition.

208 """

209

210 np.testing.assert_allclose(

211 oetf_H273_LogSqrt(0.0), 0.0, atol=TOLERANCE_ABSOLUTE_TESTS

212 )

213

214 np.testing.assert_allclose(

215 oetf_H273_LogSqrt(0.18),

216 0.702109002041322,

217 atol=TOLERANCE_ABSOLUTE_TESTS,

218 )

219

220 np.testing.assert_allclose(

221 oetf_H273_LogSqrt(1.0), 1.0, atol=TOLERANCE_ABSOLUTE_TESTS

222 )

223

224 def test_n_dimensional_oetf_H273_LogSqrt(self) -> None:

225 """

226 Test :func:`colour.models.rgb.transfer_functions.itut_h_273.\

227 oetf_H273_LogSqrt` definition n-dimensional arrays support.

228 """

229

230 E = 0.18

231 E_p = oetf_H273_LogSqrt(E)

232

233 E = np.tile(E, 6)

234 E_p = np.tile(E_p, 6)

235 np.testing.assert_allclose(

236 oetf_H273_LogSqrt(E), E_p, atol=TOLERANCE_ABSOLUTE_TESTS

237 )

238

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

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

241 np.testing.assert_allclose(

242 oetf_H273_LogSqrt(E), E_p, atol=TOLERANCE_ABSOLUTE_TESTS

243 )

244

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

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

247 np.testing.assert_allclose(

248 oetf_H273_LogSqrt(E), E_p, atol=TOLERANCE_ABSOLUTE_TESTS

249 )

250

251 def test_domain_range_scale_oetf_H273_LogSqrt(self) -> None:

252 """

253 Test :func:`colour.models.rgb.transfer_functions.itut_h_273.\

254 oetf_H273_LogSqrt` definition domain and range scale support.

255 """

256

257 E = 0.18

258 E_p = oetf_H273_LogSqrt(E)

259

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

261 for scale, factor in d_r:

262 with domain_range_scale(scale):

263 np.testing.assert_allclose(

264 oetf_H273_LogSqrt(E * factor),

265 E_p * factor,

266 atol=TOLERANCE_ABSOLUTE_TESTS,

267 )

268

269 @ignore_numpy_errors

270 def test_nan_oetf_H273_LogSqrt(self) -> None:

271 """

272 Test :func:`colour.models.rgb.transfer_functions.itut_h_273.\

273 oetf_H273_LogSqrt` definition nan support.

274 """

275

276 oetf_H273_LogSqrt(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan]))

277

278

279 class TestOetf_inverse_H273_LogSqrt:

280 """

281 Define :func:`colour.models.rgb.transfer_functions.itut_h_273.\

282 oetf_inverse_H273_LogSqrt` definition unit tests methods.

283 """

284

285 def test_oetf_inverse_H273_LogSqrt(self) -> None:

286 """

287 Test :func:`colour.models.rgb.transfer_functions.itut_h_273.\

288 oetf_inverse_H273_LogSqrt` definition.

289 """

290

291 # NOTE: The function is unfortunately clamped and cannot roundtrip

292 # properly.

293 np.testing.assert_allclose(

294 oetf_inverse_H273_LogSqrt(0.0),

295 0.003162277660168,

296 atol=TOLERANCE_ABSOLUTE_TESTS,

297 )

298

299 np.testing.assert_allclose(

300 oetf_inverse_H273_LogSqrt(0.702109002041322),

301 0.18,

302 atol=TOLERANCE_ABSOLUTE_TESTS,

303 )

304

305 np.testing.assert_allclose(

306 oetf_inverse_H273_LogSqrt(1.0), 1.0, atol=TOLERANCE_ABSOLUTE_TESTS

307 )

308

309 def test_n_dimensional_oetf_inverse_H273_LogSqrt(self) -> None:

310 """

311 Test :func:`colour.models.rgb.transfer_functions.itut_h_273.\

312 oetf_inverse_H273_LogSqrt` definition n-dimensional arrays support.

313 """

314

315 E_p = 0.702109002041322

316 E = oetf_inverse_H273_LogSqrt(E_p)

317

318 E_p = np.tile(E_p, 6)

319 E = np.tile(E, 6)

320 np.testing.assert_allclose(

321 oetf_inverse_H273_LogSqrt(E_p), E, atol=TOLERANCE_ABSOLUTE_TESTS

322 )

323

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

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

326 np.testing.assert_allclose(

327 oetf_inverse_H273_LogSqrt(E_p), E, atol=TOLERANCE_ABSOLUTE_TESTS

328 )

329

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

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

332 np.testing.assert_allclose(

333 oetf_inverse_H273_LogSqrt(E_p), E, atol=TOLERANCE_ABSOLUTE_TESTS

334 )

335

336 def test_domain_range_scale_oetf_inverse_H273_LogSqrt(self) -> None:

337 """

338 Test :func:`colour.models.rgb.transfer_functions.itut_h_273.\

339 oetf_inverse_H273_LogSqrt` definition domain and range scale support.

340 """

341

342 E_p = 0.702109002041322

343 E = oetf_inverse_H273_LogSqrt(E_p)

344

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

346 for scale, factor in d_r:

347 with domain_range_scale(scale):

348 np.testing.assert_allclose(

349 oetf_inverse_H273_LogSqrt(E_p * factor),

350 E * factor,

351 atol=TOLERANCE_ABSOLUTE_TESTS,

352 )

353

354 @ignore_numpy_errors

355 def test_nan_oetf_inverse_H273_LogSqrt(self) -> None:

356 """

357 Test :func:`colour.models.rgb.transfer_functions.itut_h_273.\

358 oetf_inverse_H273_LogSqrt` definition nan support.

359 """

360

361 oetf_inverse_H273_LogSqrt(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan]))

362

363

364 class TestOetf_H273_IEC61966_2:

365 """

366 Define :func:`colour.models.rgb.transfer_functions.itut_h_273.

367 oetf_H273_IEC61966_2` definition unit tests methods.

368 """

369

370 def test_oetf_H273_IEC61966_2(self) -> None:

371 """

372 Test :func:`colour.models.rgb.transfer_functions.itut_h_273.\

373 oetf_H273_IEC61966_2` definition.

374 """

375

376 np.testing.assert_allclose(

377 oetf_H273_IEC61966_2(-0.18),

378 -0.461356129500442,

379 atol=TOLERANCE_ABSOLUTE_TESTS,

380 )

381

382 np.testing.assert_allclose(

383 oetf_H273_IEC61966_2(0.0), 0.0, atol=TOLERANCE_ABSOLUTE_TESTS

384 )

385

386 np.testing.assert_allclose(

387 oetf_H273_IEC61966_2(0.18),

388 0.461356129500442,

389 atol=TOLERANCE_ABSOLUTE_TESTS,

390 )

391

392 np.testing.assert_allclose(

393 oetf_H273_IEC61966_2(1.0), 1.0, atol=TOLERANCE_ABSOLUTE_TESTS

394 )

395

396 def test_n_dimensional_oetf_H273_IEC61966_2(self) -> None:

397 """

398 Test :func:`colour.models.rgb.transfer_functions.itut_h_273.\

399 oetf_H273_IEC61966_2` definition n-dimensional arrays support.

400 """

401

402 E = 0.18

403 E_p = oetf_H273_IEC61966_2(E)

404

405 E = np.tile(E, 6)

406 E_p = np.tile(E_p, 6)

407 np.testing.assert_allclose(

408 oetf_H273_IEC61966_2(E), E_p, atol=TOLERANCE_ABSOLUTE_TESTS

409 )

410

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

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

413 np.testing.assert_allclose(

414 oetf_H273_IEC61966_2(E), E_p, atol=TOLERANCE_ABSOLUTE_TESTS

415 )

416

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

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

419 np.testing.assert_allclose(

420 oetf_H273_IEC61966_2(E), E_p, atol=TOLERANCE_ABSOLUTE_TESTS

421 )

422

423 def test_domain_range_scale_oetf_H273_IEC61966_2(self) -> None:

424 """

425 Test :func:`colour.models.rgb.transfer_functions.itut_h_273.\

426 oetf_H273_IEC61966_2` definition domain and range scale support.

427 """

428

429 E = 0.18

430 E_p = oetf_H273_IEC61966_2(E)

431

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

433 for scale, factor in d_r:

434 with domain_range_scale(scale):

435 np.testing.assert_allclose(

436 oetf_H273_IEC61966_2(E * factor),

437 E_p * factor,

438 atol=TOLERANCE_ABSOLUTE_TESTS,

439 )

440

441 @ignore_numpy_errors

442 def test_nan_oetf_H273_IEC61966_2(self) -> None:

443 """

444 Test :func:`colour.models.rgb.transfer_functions.itut_h_273.\

445 oetf_H273_IEC61966_2` definition nan support.

446 """

447

448 oetf_H273_IEC61966_2(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan]))

449

450

451 class TestOetf_inverse_H273_IEC61966_2:

452 """

453 Define :func:`colour.models.rgb.transfer_functions.itut_h_273.\

454 oetf_inverse_H273_IEC61966_2` definition unit tests methods.

455 """

456

457 def test_oetf_inverse_H273_IEC61966_2(self) -> None:

458 """

459 Test :func:`colour.models.rgb.transfer_functions.itut_h_273.\

460 oetf_inverse_H273_IEC61966_2` definition.

461 """

462

463 np.testing.assert_allclose(

464 oetf_inverse_H273_IEC61966_2(-0.461356129500442),

465 -0.18,

466 atol=TOLERANCE_ABSOLUTE_TESTS,

467 )

468

469 np.testing.assert_allclose(

470 oetf_inverse_H273_IEC61966_2(0.0),

471 0.0,

472 atol=TOLERANCE_ABSOLUTE_TESTS,

473 )

474

475 np.testing.assert_allclose(

476 oetf_inverse_H273_IEC61966_2(0.461356129500442),

477 0.18,

478 atol=TOLERANCE_ABSOLUTE_TESTS,

479 )

480

481 np.testing.assert_allclose(

482 oetf_inverse_H273_IEC61966_2(1.0),

483 1.0,

484 atol=TOLERANCE_ABSOLUTE_TESTS,

485 )

486

487 def test_n_dimensional_oetf_inverse_H273_IEC61966_2(self) -> None:

488 """

489 Test :func:`colour.models.rgb.transfer_functions.itut_h_273.\

490 oetf_inverse_H273_IEC61966_2` definition n-dimensional arrays support.

491 """

492

493 E_p = 0.627636252551653

494 E = oetf_inverse_H273_IEC61966_2(E_p)

495

496 E_p = np.tile(E_p, 6)

497 E = np.tile(E, 6)

498 np.testing.assert_allclose(

499 oetf_inverse_H273_IEC61966_2(E_p), E, atol=TOLERANCE_ABSOLUTE_TESTS

500 )

501

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

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

504 np.testing.assert_allclose(

505 oetf_inverse_H273_IEC61966_2(E_p), E, atol=TOLERANCE_ABSOLUTE_TESTS

506 )

507

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

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

510 np.testing.assert_allclose(

511 oetf_inverse_H273_IEC61966_2(E_p), E, atol=TOLERANCE_ABSOLUTE_TESTS

512 )

513

514 def test_domain_range_scale_oetf_inverse_H273_IEC61966_2(self) -> None:

515 """

516 Test :func:`colour.models.rgb.transfer_functions.itut_h_273.\

517 oetf_inverse_H273_IEC61966_2` definition domain and range scale support.

518 """

519

520 E_p = 0.627636252551653

521 E = oetf_inverse_H273_IEC61966_2(E_p)

522

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

524 for scale, factor in d_r:

525 with domain_range_scale(scale):

526 np.testing.assert_allclose(

527 oetf_inverse_H273_IEC61966_2(E_p * factor),

528 E * factor,

529 atol=TOLERANCE_ABSOLUTE_TESTS,

530 )

531

532 @ignore_numpy_errors

533 def test_nan_oetf_inverse_H273_IEC61966_2(self) -> None:

534 """

535 Test :func:`colour.models.rgb.transfer_functions.itut_h_273.\

536 oetf_inverse_H273_IEC61966_2` definition nan support.

537 """

538

539 oetf_inverse_H273_IEC61966_2(

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

541 )

542

543

544 class TestEotf_inverse_H273_ST428_1:

545 """

546 Define :func:`colour.models.rgb.transfer_functions.itut_h_273.

547 eotf_inverse_H273_ST428_1` definition unit tests methods.

548 """

549

550 def test_eotf_inverse_H273_ST428_1(self) -> None:

551 """

552 Test :func:`colour.models.rgb.transfer_functions.itut_h_273.\

553 eotf_inverse_H273_ST428_1` definition.

554 """

555

556 np.testing.assert_allclose(

557 eotf_inverse_H273_ST428_1(0.0), 0.0, atol=TOLERANCE_ABSOLUTE_TESTS

558 )

559

560 np.testing.assert_allclose(

561 eotf_inverse_H273_ST428_1(0.18),

562 0.500048337717236,

563 atol=TOLERANCE_ABSOLUTE_TESTS,

564 )

565

566 np.testing.assert_allclose(

567 eotf_inverse_H273_ST428_1(1.0),

568 0.967042675317934,

569 atol=TOLERANCE_ABSOLUTE_TESTS,

570 )

571

572 def test_n_dimensional_eotf_inverse_H273_ST428_1(self) -> None:

573 """

574 Test :func:`colour.models.rgb.transfer_functions.itut_h_273.\

575 eotf_inverse_H273_ST428_1` definition n-dimensional arrays support.

576 """

577

578 E = 0.18

579 E_p = eotf_inverse_H273_ST428_1(E)

580

581 E = np.tile(E, 6)

582 E_p = np.tile(E_p, 6)

583 np.testing.assert_allclose(

584 eotf_inverse_H273_ST428_1(E), E_p, atol=TOLERANCE_ABSOLUTE_TESTS

585 )

586

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

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

589 np.testing.assert_allclose(

590 eotf_inverse_H273_ST428_1(E), E_p, atol=TOLERANCE_ABSOLUTE_TESTS

591 )

592

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

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

595 np.testing.assert_allclose(

596 eotf_inverse_H273_ST428_1(E), E_p, atol=TOLERANCE_ABSOLUTE_TESTS

597 )

598

599 def test_domain_range_scale_eotf_inverse_H273_ST428_1(self) -> None:

600 """

601 Test :func:`colour.models.rgb.transfer_functions.itut_h_273.\

602 eotf_inverse_H273_ST428_1` definition domain and range scale support.

603 """

604

605 E = 0.18

606 E_p = eotf_inverse_H273_ST428_1(E)

607

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

609 for scale, factor in d_r:

610 with domain_range_scale(scale):

611 np.testing.assert_allclose(

612 eotf_inverse_H273_ST428_1(E * factor),

613 E_p * factor,

614 atol=TOLERANCE_ABSOLUTE_TESTS,

615 )

616

617 @ignore_numpy_errors

618 def test_nan_eotf_inverse_H273_ST428_1(self) -> None:

619 """

620 Test :func:`colour.models.rgb.transfer_functions.itut_h_273.\

621 eotf_inverse_H273_ST428_1` definition nan support.

622 """

623

624 eotf_inverse_H273_ST428_1(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan]))

625

626

627 class TestEotf_H273_ST428_1:

628 """

629 Define :func:`colour.models.rgb.transfer_functions.itut_h_273.\

630 eotf_H273_ST428_1` definition unit tests methods.

631 """

632

633 def test_eotf_H273_ST428_1(self) -> None:

634 """

635 Test :func:`colour.models.rgb.transfer_functions.itut_h_273.\

636 eotf_H273_ST428_1` definition.

637 """

638

639 np.testing.assert_allclose(

640 eotf_H273_ST428_1(0.0), 0.0, atol=TOLERANCE_ABSOLUTE_TESTS

641 )

642

643 np.testing.assert_allclose(

644 eotf_H273_ST428_1(0.500048337717236),

645 0.18,

646 atol=TOLERANCE_ABSOLUTE_TESTS,

647 )

648

649 np.testing.assert_allclose(

650 eotf_H273_ST428_1(0.967042675317934),

651 1.0,

652 atol=TOLERANCE_ABSOLUTE_TESTS,

653 )

654

655 def test_n_dimensional_eotf_H273_ST428_1(self) -> None:

656 """

657 Test :func:`colour.models.rgb.transfer_functions.itut_h_273.\

658 eotf_H273_ST428_1` definition n-dimensional arrays support.

659 """

660

661 E_p = 0.500048337717236

662 E = eotf_H273_ST428_1(E_p)

663

664 E_p = np.tile(E_p, 6)

665 E = np.tile(E, 6)

666 np.testing.assert_allclose(

667 eotf_H273_ST428_1(E_p), E, atol=TOLERANCE_ABSOLUTE_TESTS

668 )

669

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

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

672 np.testing.assert_allclose(

673 eotf_H273_ST428_1(E_p), E, atol=TOLERANCE_ABSOLUTE_TESTS

674 )

675

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

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

678 np.testing.assert_allclose(

679 eotf_H273_ST428_1(E_p), E, atol=TOLERANCE_ABSOLUTE_TESTS

680 )

681

682 def test_domain_range_scale_eotf_H273_ST428_1(self) -> None:

683 """

684 Test :func:`colour.models.rgb.transfer_functions.itut_h_273.\

685 eotf_H273_ST428_1` definition domain and range scale support.

686 """

687

688 E_p = 0.500048337717236

689 E = eotf_H273_ST428_1(E_p)

690

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

692 for scale, factor in d_r:

693 with domain_range_scale(scale):

694 np.testing.assert_allclose(

695 eotf_H273_ST428_1(E_p * factor),

696 E * factor,

697 atol=TOLERANCE_ABSOLUTE_TESTS,

698 )

699

700 @ignore_numpy_errors

701 def test_nan_eotf_H273_ST428_1(self) -> None:

702 """

703 Test :func:`colour.models.rgb.transfer_functions.itut_h_273.\

704 eotf_H273_ST428_1` definition nan support.

705 """

706

707 eotf_H273_ST428_1(np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan]))