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

1"""

2 Define the unit tests for the

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

11 log_decoding_REDLog,

12 log_decoding_REDLogFilm,

13 log_encoding_Log3G12,

14 log_encoding_REDLog,

15 log_encoding_REDLogFilm,

16)

17 from colour.models.rgb.transfer_functions.red import (

18 log_decoding_Log3G10_v1,

19 log_decoding_Log3G10_v2,

20 log_decoding_Log3G10_v3,

21 log_encoding_Log3G10_v1,

22 log_encoding_Log3G10_v2,

23 log_encoding_Log3G10_v3,

24)

25 from colour.utilities import domain_range_scale, ignore_numpy_errors

26

27 __author__ = "Colour Developers"

28 __copyright__ = "Copyright 2013 Colour Developers"

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

30 __maintainer__ = "Colour Developers"

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

32 __status__ = "Development"

33

34 __all__ = [

35 "TestLogEncoding_REDLog",

36 "TestLogDecoding_REDLog",

37 "TestLogEncoding_REDLogFilm",

38 "TestLogDecoding_REDLogFilm",

39 "TestLogEncoding_Log3G10_v1",

40 "TestLogDecoding_Log3G10_v1",

41 "TestLogEncoding_Log3G10_v2",

42 "TestLogDecoding_Log3G10_v2",

43 "TestLogEncoding_Log3G10_v3",

44 "TestLogDecoding_Log3G10_v3",

45 "TestLogEncoding_Log3G12",

46 "TestLogDecoding_Log3G12",

47]

48

49

50 class TestLogEncoding_REDLog:

51 """

52 Define :func:`colour.models.rgb.transfer_functions.red.\

53 log_encoding_REDLog` definition unit tests methods.

54 """

55

56 def test_log_encoding_REDLog(self) -> None:

57 """

58 Test :func:`colour.models.rgb.transfer_functions.red.\

59 log_encoding_REDLog` definition.

60 """

61

62 np.testing.assert_allclose(

63 log_encoding_REDLog(0.0), 0.0, atol=TOLERANCE_ABSOLUTE_TESTS

64 )

65

66 np.testing.assert_allclose(

67 log_encoding_REDLog(0.18),

68 0.637621845988175,

69 atol=TOLERANCE_ABSOLUTE_TESTS,

70 )

71

72 np.testing.assert_allclose(

73 log_encoding_REDLog(1.0), 1.0, atol=TOLERANCE_ABSOLUTE_TESTS

74 )

75

76 def test_n_dimensional_log_encoding_REDLog(self) -> None:

77 """

78 Test :func:`colour.models.rgb.transfer_functions.red.\

79 log_encoding_REDLog` definition n-dimensional arrays support.

80 """

81

82 x = 0.18

83 y = log_encoding_REDLog(x)

84

85 x = np.tile(x, 6)

86 y = np.tile(y, 6)

87 np.testing.assert_allclose(

88 log_encoding_REDLog(x), y, atol=TOLERANCE_ABSOLUTE_TESTS

89 )

90

91 x = np.reshape(x, (2, 3))

92 y = np.reshape(y, (2, 3))

93 np.testing.assert_allclose(

94 log_encoding_REDLog(x), y, atol=TOLERANCE_ABSOLUTE_TESTS

95 )

96

97 x = np.reshape(x, (2, 3, 1))

98 y = np.reshape(y, (2, 3, 1))

99 np.testing.assert_allclose(

100 log_encoding_REDLog(x), y, atol=TOLERANCE_ABSOLUTE_TESTS

101 )

102

103 def test_domain_range_scale_log_encoding_REDLog(self) -> None:

104 """

105 Test :func:`colour.models.rgb.transfer_functions.red.\

106 log_encoding_REDLog` definition domain and range scale support.

107 """

108

109 x = 0.18

110 y = log_encoding_REDLog(x)

111

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

113 for scale, factor in d_r:

114 with domain_range_scale(scale):

115 np.testing.assert_allclose(

116 log_encoding_REDLog(x * factor),

117 y * factor,

118 atol=TOLERANCE_ABSOLUTE_TESTS,

119 )

120

121 @ignore_numpy_errors

122 def test_nan_log_encoding_REDLog(self) -> None:

123 """

124 Test :func:`colour.models.rgb.transfer_functions.red.\

125 log_encoding_REDLog` definition nan support.

126 """

127

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

129

130

131 class TestLogDecoding_REDLog:

132 """

133 Define :func:`colour.models.rgb.transfer_functions.red.\

134 log_decoding_REDLog` definition unit tests methods.

135 """

136

137 def test_log_decoding_REDLog(self) -> None:

138 """

139 Test :func:`colour.models.rgb.transfer_functions.red.\

140 log_decoding_REDLog` definition.

141 """

142

143 np.testing.assert_allclose(

144 log_decoding_REDLog(0.0), 0.0, atol=TOLERANCE_ABSOLUTE_TESTS

145 )

146

147 np.testing.assert_allclose(

148 log_decoding_REDLog(0.637621845988175),

149 0.18,

150 atol=TOLERANCE_ABSOLUTE_TESTS,

151 )

152

153 np.testing.assert_allclose(

154 log_decoding_REDLog(1.0), 1.0, atol=TOLERANCE_ABSOLUTE_TESTS

155 )

156

157 def test_n_dimensional_log_decoding_REDLog(self) -> None:

158 """

159 Test :func:`colour.models.rgb.transfer_functions.red.\

160 log_decoding_REDLog` definition n-dimensional arrays support.

161 """

162

163 y = 0.637621845988175

164 x = log_decoding_REDLog(y)

165

166 y = np.tile(y, 6)

167 x = np.tile(x, 6)

168 np.testing.assert_allclose(

169 log_decoding_REDLog(y), x, atol=TOLERANCE_ABSOLUTE_TESTS

170 )

171

172 y = np.reshape(y, (2, 3))

173 x = np.reshape(x, (2, 3))

174 np.testing.assert_allclose(

175 log_decoding_REDLog(y), x, atol=TOLERANCE_ABSOLUTE_TESTS

176 )

177

178 y = np.reshape(y, (2, 3, 1))

179 x = np.reshape(x, (2, 3, 1))

180 np.testing.assert_allclose(

181 log_decoding_REDLog(y), x, atol=TOLERANCE_ABSOLUTE_TESTS

182 )

183

184 def test_domain_range_scale_log_decoding_REDLog(self) -> None:

185 """

186 Test :func:`colour.models.rgb.transfer_functions.red.\

187 log_decoding_REDLog` definition domain and range scale support.

188 """

189

190 y = 0.637621845988175

191 x = log_decoding_REDLog(y)

192

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

194 for scale, factor in d_r:

195 with domain_range_scale(scale):

196 np.testing.assert_allclose(

197 log_decoding_REDLog(y * factor),

198 x * factor,

199 atol=TOLERANCE_ABSOLUTE_TESTS,

200 )

201

202 @ignore_numpy_errors

203 def test_nan_log_decoding_REDLog(self) -> None:

204 """

205 Test :func:`colour.models.rgb.transfer_functions.red.\

206 log_decoding_REDLog` definition nan support.

207 """

208

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

210

211

212 class TestLogEncoding_REDLogFilm:

213 """

214 Define :func:`colour.models.rgb.transfer_functions.red.\

215 log_encoding_REDLogFilm` definition unit tests methods.

216 """

217

218 def test_log_encoding_REDLogFilm(self) -> None:

219 """

220 Test :func:`colour.models.rgb.transfer_functions.red.\

221 log_encoding_REDLogFilm` definition.

222 """

223

224 np.testing.assert_allclose(

225 log_encoding_REDLogFilm(0.0),

226 0.092864125122190,

227 atol=TOLERANCE_ABSOLUTE_TESTS,

228 )

229

230 np.testing.assert_allclose(

231 log_encoding_REDLogFilm(0.18),

232 0.457319613085418,

233 atol=TOLERANCE_ABSOLUTE_TESTS,

234 )

235

236 np.testing.assert_allclose(

237 log_encoding_REDLogFilm(1.0),

238 0.669599217986315,

239 atol=TOLERANCE_ABSOLUTE_TESTS,

240 )

241

242 def test_n_dimensional_log_encoding_REDLogFilm(self) -> None:

243 """

244 Test :func:`colour.models.rgb.transfer_functions.red.\

245 log_encoding_REDLogFilm` definition n-dimensional arrays support.

246 """

247

248 x = 0.18

249 y = log_encoding_REDLogFilm(x)

250

251 x = np.tile(x, 6)

252 y = np.tile(y, 6)

253 np.testing.assert_allclose(

254 log_encoding_REDLogFilm(x), y, atol=TOLERANCE_ABSOLUTE_TESTS

255 )

256

257 x = np.reshape(x, (2, 3))

258 y = np.reshape(y, (2, 3))

259 np.testing.assert_allclose(

260 log_encoding_REDLogFilm(x), y, atol=TOLERANCE_ABSOLUTE_TESTS

261 )

262

263 x = np.reshape(x, (2, 3, 1))

264 y = np.reshape(y, (2, 3, 1))

265 np.testing.assert_allclose(

266 log_encoding_REDLogFilm(x), y, atol=TOLERANCE_ABSOLUTE_TESTS

267 )

268

269 def test_domain_range_scale_log_encoding_REDLogFilm(self) -> None:

270 """

271 Test :func:`colour.models.rgb.transfer_functions.red.\

272 log_encoding_REDLogFilm` definition domain and range scale support.

273 """

274

275 x = 0.18

276 y = log_encoding_REDLogFilm(x)

277

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

279 for scale, factor in d_r:

280 with domain_range_scale(scale):

281 np.testing.assert_allclose(

282 log_encoding_REDLogFilm(x * factor),

283 y * factor,

284 atol=TOLERANCE_ABSOLUTE_TESTS,

285 )

286

287 @ignore_numpy_errors

288 def test_nan_log_encoding_REDLogFilm(self) -> None:

289 """

290 Test :func:`colour.models.rgb.transfer_functions.red.\

291 log_encoding_REDLogFilm` definition nan support.

292 """

293

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

295

296

297 class TestLogDecoding_REDLogFilm:

298 """

299 Define :func:`colour.models.rgb.transfer_functions.red.\

300 log_decoding_REDLogFilm` definition unit tests methods.

301 """

302

303 def test_log_decoding_REDLogFilm(self) -> None:

304 """

305 Test :func:`colour.models.rgb.transfer_functions.red.\

306 log_decoding_REDLogFilm` definition.

307 """

308

309 np.testing.assert_allclose(

310 log_decoding_REDLogFilm(0.092864125122190),

311 0.0,

312 atol=TOLERANCE_ABSOLUTE_TESTS,

313 )

314

315 np.testing.assert_allclose(

316 log_decoding_REDLogFilm(0.457319613085418),

317 0.18,

318 atol=TOLERANCE_ABSOLUTE_TESTS,

319 )

320

321 np.testing.assert_allclose(

322 log_decoding_REDLogFilm(0.669599217986315),

323 1.0,

324 atol=TOLERANCE_ABSOLUTE_TESTS,

325 )

326

327 def test_n_dimensional_log_decoding_REDLogFilm(self) -> None:

328 """

329 Test :func:`colour.models.rgb.transfer_functions.red.\

330 log_decoding_REDLogFilm` definition n-dimensional arrays support.

331 """

332

333 y = 0.457319613085418

334 x = log_decoding_REDLogFilm(y)

335

336 y = np.tile(y, 6)

337 x = np.tile(x, 6)

338 np.testing.assert_allclose(

339 log_decoding_REDLogFilm(y), x, atol=TOLERANCE_ABSOLUTE_TESTS

340 )

341

342 y = np.reshape(y, (2, 3))

343 x = np.reshape(x, (2, 3))

344 np.testing.assert_allclose(

345 log_decoding_REDLogFilm(y), x, atol=TOLERANCE_ABSOLUTE_TESTS

346 )

347

348 y = np.reshape(y, (2, 3, 1))

349 x = np.reshape(x, (2, 3, 1))

350 np.testing.assert_allclose(

351 log_decoding_REDLogFilm(y), x, atol=TOLERANCE_ABSOLUTE_TESTS

352 )

353

354 def test_domain_range_scale_log_decoding_REDLogFilm(self) -> None:

355 """

356 Test :func:`colour.models.rgb.transfer_functions.red.\

357 log_decoding_REDLogFilm` definition domain and range scale support.

358 """

359

360 y = 0.457319613085418

361 x = log_decoding_REDLogFilm(y)

362

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

364 for scale, factor in d_r:

365 with domain_range_scale(scale):

366 np.testing.assert_allclose(

367 log_decoding_REDLogFilm(y * factor),

368 x * factor,

369 atol=TOLERANCE_ABSOLUTE_TESTS,

370 )

371

372 @ignore_numpy_errors

373 def test_nan_log_decoding_REDLogFilm(self) -> None:

374 """

375 Test :func:`colour.models.rgb.transfer_functions.red.\

376 log_decoding_REDLogFilm` definition nan support.

377 """

378

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

380

381

382 class TestLogEncoding_Log3G10_v1:

383 """

384 Define :func:`colour.models.rgb.transfer_functions.red.\

385 log_encoding_Log3G10_v1` definition unit tests methods.

386 """

387

388 def test_log_encoding_Log3G10_v1(self) -> None:

389 """

390 Test :func:`colour.models.rgb.transfer_functions.red.\

391 log_encoding_Log3G10_v1` definition.

392 """

393

394 np.testing.assert_allclose(

395 log_encoding_Log3G10_v1(-1.0),

396 -0.496483569056003,

397 atol=TOLERANCE_ABSOLUTE_TESTS,

398 )

399

400 np.testing.assert_allclose(

401 log_encoding_Log3G10_v1(0.0), 0.0, atol=TOLERANCE_ABSOLUTE_TESTS

402 )

403

404 np.testing.assert_allclose(

405 log_encoding_Log3G10_v1(0.18),

406 0.333333644207707,

407 atol=TOLERANCE_ABSOLUTE_TESTS,

408 )

409

410 def test_n_dimensional_log_encoding_Log3G10_v1(self) -> None:

411 """

412 Test :func:`colour.models.rgb.transfer_functions.red.\

413 log_encoding_Log3G10_v1` definition n-dimensional arrays support.

414 """

415

416 x = 0.18

417 y = log_encoding_Log3G10_v1(x)

418

419 x = np.tile(x, 6)

420 y = np.tile(y, 6)

421 np.testing.assert_allclose(

422 log_encoding_Log3G10_v1(x), y, atol=TOLERANCE_ABSOLUTE_TESTS

423 )

424

425 x = np.reshape(x, (2, 3))

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

427 np.testing.assert_allclose(

428 log_encoding_Log3G10_v1(x), y, atol=TOLERANCE_ABSOLUTE_TESTS

429 )

430

431 x = np.reshape(x, (2, 3, 1))

432 y = np.reshape(y, (2, 3, 1))

433 np.testing.assert_allclose(

434 log_encoding_Log3G10_v1(x), y, atol=TOLERANCE_ABSOLUTE_TESTS

435 )

436

437 def test_domain_range_scale_log_encoding_Log3G10_v1(self) -> None:

438 """

439 Test :func:`colour.models.rgb.transfer_functions.red.\

440 log_encoding_Log3G10_v1` definition domain and range scale support.

441 """

442

443 x = 0.18

444 y = log_encoding_Log3G10_v1(x)

445

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

447 for scale, factor in d_r:

448 with domain_range_scale(scale):

449 np.testing.assert_allclose(

450 log_encoding_Log3G10_v1(x * factor),

451 y * factor,

452 atol=TOLERANCE_ABSOLUTE_TESTS,

453 )

454

455 @ignore_numpy_errors

456 def test_nan_log_encoding_Log3G10_v1(self) -> None:

457 """

458 Test :func:`colour.models.rgb.transfer_functions.red.\

459 log_encoding_Log3G10_v1` definition nan support.

460 """

461

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

463

464

465 class TestLogDecoding_Log3G10_v1:

466 """

467 Define :func:`colour.models.rgb.transfer_functions.red.\

468 log_decoding_Log3G10_v1` definition unit tests methods.

469 """

470

471 def test_log_decoding_Log3G10_v1(self) -> None:

472 """

473 Test :func:`colour.models.rgb.transfer_functions.red.\

474 log_decoding_Log3G10_v1` definition.

475 """

476

477 np.testing.assert_allclose(

478 log_decoding_Log3G10_v1(-0.496483569056003),

479 -1.0,

480 atol=TOLERANCE_ABSOLUTE_TESTS,

481 )

482

483 np.testing.assert_allclose(

484 log_decoding_Log3G10_v1(0.0), 0.0, atol=TOLERANCE_ABSOLUTE_TESTS

485 )

486

487 np.testing.assert_allclose(

488 log_decoding_Log3G10_v1(0.333333644207707),

489 0.18,

490 atol=TOLERANCE_ABSOLUTE_TESTS,

491 )

492

493 def test_n_dimensional_log_decoding_Log3G10_v1(self) -> None:

494 """

495 Test :func:`colour.models.rgb.transfer_functions.red.\

496 log_decoding_Log3G10_v1` definition n-dimensional arrays support.

497 """

498

499 y = 0.333333644207707

500 x = log_decoding_Log3G10_v1(y)

501

502 y = np.tile(y, 6)

503 x = np.tile(x, 6)

504 np.testing.assert_allclose(

505 log_decoding_Log3G10_v1(y), x, atol=TOLERANCE_ABSOLUTE_TESTS

506 )

507

508 y = np.reshape(y, (2, 3))

509 x = np.reshape(x, (2, 3))

510 np.testing.assert_allclose(

511 log_decoding_Log3G10_v1(y), x, atol=TOLERANCE_ABSOLUTE_TESTS

512 )

513

514 y = np.reshape(y, (2, 3, 1))

515 x = np.reshape(x, (2, 3, 1))

516 np.testing.assert_allclose(

517 log_decoding_Log3G10_v1(y), x, atol=TOLERANCE_ABSOLUTE_TESTS

518 )

519

520 def test_domain_range_scale_log_decoding_Log3G10_v1(self) -> None:

521 """

522 Test :func:`colour.models.rgb.transfer_functions.red.\

523 log_decoding_Log3G10_v1` definition domain and range scale support.

524 """

525

526 y = 0.333333644207707

527 x = log_decoding_Log3G10_v1(y)

528

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

530 for scale, factor in d_r:

531 with domain_range_scale(scale):

532 np.testing.assert_allclose(

533 log_decoding_Log3G10_v1(y * factor),

534 x * factor,

535 atol=TOLERANCE_ABSOLUTE_TESTS,

536 )

537

538 @ignore_numpy_errors

539 def test_nan_log_decoding_Log3G10_v1(self) -> None:

540 """

541 Test :func:`colour.models.rgb.transfer_functions.red.\

542 log_decoding_Log3G10_v1` definition nan support.

543 """

544

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

546

547

548 class TestLogEncoding_Log3G10_v2:

549 """

550 Define :func:`colour.models.rgb.transfer_functions.red.\

551 log_encoding_Log3G10_v2` definition unit tests methods.

552 """

553

554 def test_log_encoding_Log3G10_v2(self) -> None:

555 """

556 Test :func:`colour.models.rgb.transfer_functions.red.\

557 log_encoding_Log3G10_v2` definition.

558 """

559

560 np.testing.assert_allclose(

561 log_encoding_Log3G10_v2(-1.0),

562 -0.491512777522511,

563 atol=TOLERANCE_ABSOLUTE_TESTS,

564 )

565

566 np.testing.assert_allclose(

567 log_encoding_Log3G10_v2(0.0),

568 0.091551487714745,

569 atol=TOLERANCE_ABSOLUTE_TESTS,

570 )

571

572 np.testing.assert_allclose(

573 log_encoding_Log3G10_v2(0.18),

574 0.333332912025992,

575 atol=TOLERANCE_ABSOLUTE_TESTS,

576 )

577

578 def test_n_dimensional_log_encoding_Log3G10_v2(self) -> None:

579 """

580 Test :func:`colour.models.rgb.transfer_functions.red.\

581 log_encoding_Log3G10_v2` definition n-dimensional arrays support.

582 """

583

584 x = 0.18

585 y = log_encoding_Log3G10_v2(x)

586

587 x = np.tile(x, 6)

588 y = np.tile(y, 6)

589 np.testing.assert_allclose(

590 log_encoding_Log3G10_v2(x), y, atol=TOLERANCE_ABSOLUTE_TESTS

591 )

592

593 x = np.reshape(x, (2, 3))

594 y = np.reshape(y, (2, 3))

595 np.testing.assert_allclose(

596 log_encoding_Log3G10_v2(x), y, atol=TOLERANCE_ABSOLUTE_TESTS

597 )

598

599 x = np.reshape(x, (2, 3, 1))

600 y = np.reshape(y, (2, 3, 1))

601 np.testing.assert_allclose(

602 log_encoding_Log3G10_v2(x), y, atol=TOLERANCE_ABSOLUTE_TESTS

603 )

604

605 def test_domain_range_scale_log_encoding_Log3G10_v2(self) -> None:

606 """

607 Test :func:`colour.models.rgb.transfer_functions.red.\

608 log_encoding_Log3G10_v2` definition domain and range scale support.

609 """

610

611 x = 0.18

612 y = log_encoding_Log3G10_v2(x)

613

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

615 for scale, factor in d_r:

616 with domain_range_scale(scale):

617 np.testing.assert_allclose(

618 log_encoding_Log3G10_v2(x * factor),

619 y * factor,

620 atol=TOLERANCE_ABSOLUTE_TESTS,

621 )

622

623 @ignore_numpy_errors

624 def test_nan_log_encoding_Log3G10_v2(self) -> None:

625 """

626 Test :func:`colour.models.rgb.transfer_functions.red.\

627 log_encoding_Log3G10_v2` definition nan support.

628 """

629

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

631

632

633 class TestLogDecoding_Log3G10_v2:

634 """

635 Define :func:`colour.models.rgb.transfer_functions.red.\

636 log_decoding_Log3G10_v2` definition unit tests methods.

637 """

638

639 def test_log_decoding_Log3G10_v2(self) -> None:

640 """

641 Test :func:`colour.models.rgb.transfer_functions.red.\

642 log_decoding_Log3G10_v2` definition.

643 """

644

645 np.testing.assert_allclose(

646 log_decoding_Log3G10_v2(-0.491512777522511),

647 -1.0,

648 atol=TOLERANCE_ABSOLUTE_TESTS,

649 )

650

651 np.testing.assert_allclose(

652 log_decoding_Log3G10_v2(0.091551487714745),

653 0.0,

654 atol=TOLERANCE_ABSOLUTE_TESTS,

655 )

656

657 np.testing.assert_allclose(

658 log_decoding_Log3G10_v2(0.333332912025992),

659 0.18,

660 atol=TOLERANCE_ABSOLUTE_TESTS,

661 )

662

663 def test_n_dimensional_log_decoding_Log3G10_v2(self) -> None:

664 """

665 Test :func:`colour.models.rgb.transfer_functions.red.\

666 log_decoding_Log3G10_v2` definition n-dimensional arrays support.

667 """

668

669 y = 0.333332912025992

670 x = log_decoding_Log3G10_v2(y)

671

672 y = np.tile(y, 6)

673 x = np.tile(x, 6)

674 np.testing.assert_allclose(

675 log_decoding_Log3G10_v2(y), x, atol=TOLERANCE_ABSOLUTE_TESTS

676 )

677

678 y = np.reshape(y, (2, 3))

679 x = np.reshape(x, (2, 3))

680 np.testing.assert_allclose(

681 log_decoding_Log3G10_v2(y), x, atol=TOLERANCE_ABSOLUTE_TESTS

682 )

683

684 y = np.reshape(y, (2, 3, 1))

685 x = np.reshape(x, (2, 3, 1))

686 np.testing.assert_allclose(

687 log_decoding_Log3G10_v2(y), x, atol=TOLERANCE_ABSOLUTE_TESTS

688 )

689

690 def test_domain_range_scale_log_decoding_Log3G10_v2(self) -> None:

691 """

692 Test :func:`colour.models.rgb.transfer_functions.red.\

693 log_decoding_Log3G10_v2` definition domain and range scale support.

694 """

695

696 y = 0.333333644207707

697 x = log_decoding_Log3G10_v2(y)

698

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

700 for scale, factor in d_r:

701 with domain_range_scale(scale):

702 np.testing.assert_allclose(

703 log_decoding_Log3G10_v2(y * factor),

704 x * factor,

705 atol=TOLERANCE_ABSOLUTE_TESTS,

706 )

707

708 @ignore_numpy_errors

709 def test_nan_log_decoding_Log3G10_v2(self) -> None:

710 """

711 Test :func:`colour.models.rgb.transfer_functions.red.\

712 log_decoding_Log3G10_v2` definition nan support.

713 """

714

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

716

717

718 class TestLogEncoding_Log3G10_v3:

719 """

720 Define :func:`colour.models.rgb.transfer_functions.red.\

721 log_encoding_Log3G10_v3` definition unit tests methods.

722 """

723

724 def test_log_encoding_Log3G10_v3(self) -> None:

725 """

726 Test :func:`colour.models.rgb.transfer_functions.red.\

727 log_encoding_Log3G10_v3` definition.

728 """

729

730 np.testing.assert_allclose(

731 log_encoding_Log3G10_v3(-1.0),

732 -15.040773,

733 atol=TOLERANCE_ABSOLUTE_TESTS,

734 )

735

736 np.testing.assert_allclose(

737 log_encoding_Log3G10_v3(0.0),

738 0.091551487714745,

739 atol=TOLERANCE_ABSOLUTE_TESTS,

740 )

741

742 np.testing.assert_allclose(

743 log_encoding_Log3G10_v3(0.18),

744 0.333332912025992,

745 atol=TOLERANCE_ABSOLUTE_TESTS,

746 )

747

748 def test_n_dimensional_log_encoding_Log3G10_v3(self) -> None:

749 """

750 Test :func:`colour.models.rgb.transfer_functions.red.\

751 log_encoding_Log3G10_v3` definition n-dimensional arrays support.

752 """

753

754 x = 0.18

755 y = log_encoding_Log3G10_v3(x)

756

757 x = np.tile(x, 6)

758 y = np.tile(y, 6)

759 np.testing.assert_allclose(

760 log_encoding_Log3G10_v3(x), y, atol=TOLERANCE_ABSOLUTE_TESTS

761 )

762

763 x = np.reshape(x, (2, 3))

764 y = np.reshape(y, (2, 3))

765 np.testing.assert_allclose(

766 log_encoding_Log3G10_v3(x), y, atol=TOLERANCE_ABSOLUTE_TESTS

767 )

768

769 x = np.reshape(x, (2, 3, 1))

770 y = np.reshape(y, (2, 3, 1))

771 np.testing.assert_allclose(

772 log_encoding_Log3G10_v3(x), y, atol=TOLERANCE_ABSOLUTE_TESTS

773 )

774

775 def test_domain_range_scale_log_encoding_Log3G10_v3(self) -> None:

776 """

777 Test :func:`colour.models.rgb.transfer_functions.red.\

778 log_encoding_Log3G10_v3` definition domain and range scale support.

779 """

780

781 x = 0.18

782 y = log_encoding_Log3G10_v3(x)

783

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

785 for scale, factor in d_r:

786 with domain_range_scale(scale):

787 np.testing.assert_allclose(

788 log_encoding_Log3G10_v3(x * factor),

789 y * factor,

790 atol=TOLERANCE_ABSOLUTE_TESTS,

791 )

792

793 @ignore_numpy_errors

794 def test_nan_log_encoding_Log3G10_v3(self) -> None:

795 """

796 Test :func:`colour.models.rgb.transfer_functions.red.\

797 log_encoding_Log3G10_v3` definition nan support.

798 """

799

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

801

802

803 class TestLogDecoding_Log3G10_v3:

804 """

805 Define :func:`colour.models.rgb.transfer_functions.red.\

806 log_decoding_Log3G10_v3` definition unit tests methods.

807 """

808

809 def test_log_decoding_Log3G10_v3(self) -> None:

810 """

811 Test :func:`colour.models.rgb.transfer_functions.red.\

812 log_decoding_Log3G10_v3` definition.

813 """

814

815 np.testing.assert_allclose(

816 log_decoding_Log3G10_v3(-15.040773),

817 -1.0,

818 atol=TOLERANCE_ABSOLUTE_TESTS,

819 )

820

821 np.testing.assert_allclose(

822 log_decoding_Log3G10_v3(0.091551487714745),

823 0.0,

824 atol=TOLERANCE_ABSOLUTE_TESTS,

825 )

826

827 np.testing.assert_allclose(

828 log_decoding_Log3G10_v3(0.333332912025992),

829 0.18,

830 atol=TOLERANCE_ABSOLUTE_TESTS,

831 )

832

833 def test_n_dimensional_log_decoding_Log3G10_v3(self) -> None:

834 """

835 Test :func:`colour.models.rgb.transfer_functions.red.\

836 log_decoding_Log3G10_v3` definition n-dimensional arrays support.

837 """

838

839 y = 0.333332912025992

840 x = log_decoding_Log3G10_v3(y)

841

842 y = np.tile(y, 6)

843 x = np.tile(x, 6)

844 np.testing.assert_allclose(

845 log_decoding_Log3G10_v3(y), x, atol=TOLERANCE_ABSOLUTE_TESTS

846 )

847

848 y = np.reshape(y, (2, 3))

849 x = np.reshape(x, (2, 3))

850 np.testing.assert_allclose(

851 log_decoding_Log3G10_v3(y), x, atol=TOLERANCE_ABSOLUTE_TESTS

852 )

853

854 y = np.reshape(y, (2, 3, 1))

855 x = np.reshape(x, (2, 3, 1))

856 np.testing.assert_allclose(

857 log_decoding_Log3G10_v3(y), x, atol=TOLERANCE_ABSOLUTE_TESTS

858 )

859

860 def test_domain_range_scale_log_decoding_Log3G10_v3(self) -> None:

861 """

862 Test :func:`colour.models.rgb.transfer_functions.red.\

863 log_decoding_Log3G10_v3` definition domain and range scale support.

864 """

865

866 y = 0.333333644207707

867 x = log_decoding_Log3G10_v3(y)

868

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

870 for scale, factor in d_r:

871 with domain_range_scale(scale):

872 np.testing.assert_allclose(

873 log_decoding_Log3G10_v3(y * factor),

874 x * factor,

875 atol=TOLERANCE_ABSOLUTE_TESTS,

876 )

877

878 @ignore_numpy_errors

879 def test_nan_log_decoding_Log3G10_v3(self) -> None:

880 """

881 Test :func:`colour.models.rgb.transfer_functions.red.\

882 log_decoding_Log3G10_v3` definition nan support.

883 """

884

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

886

887

888 class TestLogEncoding_Log3G12:

889 """

890 Define :func:`colour.models.rgb.transfer_functions.red.\

891 log_encoding_Log3G12` definition unit tests methods.

892 """

893

894 def test_log_encoding_Log3G12(self) -> None:

895 """

896 Test :func:`colour.models.rgb.transfer_functions.red.\

897 log_encoding_Log3G12` definition.

898 """

899

900 np.testing.assert_allclose(

901 log_encoding_Log3G12(0.0), 0.0, atol=TOLERANCE_ABSOLUTE_TESTS

902 )

903

904 np.testing.assert_allclose(

905 log_encoding_Log3G12(0.18),

906 0.333332662015923,

907 atol=TOLERANCE_ABSOLUTE_TESTS,

908 )

909

910 np.testing.assert_allclose(

911 log_encoding_Log3G12(1.0),

912 0.469991923234319,

913 atol=TOLERANCE_ABSOLUTE_TESTS,

914 )

915

916 np.testing.assert_allclose(

917 log_encoding_Log3G12(0.18 * 2**12),

918 0.999997986792394,

919 atol=TOLERANCE_ABSOLUTE_TESTS,

920 )

921

922 def test_n_dimensional_log_encoding_Log3G12(self) -> None:

923 """

924 Test :func:`colour.models.rgb.transfer_functions.red.\

925 log_encoding_Log3G12` definition n-dimensional arrays support.

926 """

927

928 x = 0.18

929 y = log_encoding_Log3G12(x)

930

931 x = np.tile(x, 6)

932 y = np.tile(y, 6)

933 np.testing.assert_allclose(

934 log_encoding_Log3G12(x), y, atol=TOLERANCE_ABSOLUTE_TESTS

935 )

936

937 x = np.reshape(x, (2, 3))

938 y = np.reshape(y, (2, 3))

939 np.testing.assert_allclose(

940 log_encoding_Log3G12(x), y, atol=TOLERANCE_ABSOLUTE_TESTS

941 )

942

943 x = np.reshape(x, (2, 3, 1))

944 y = np.reshape(y, (2, 3, 1))

945 np.testing.assert_allclose(

946 log_encoding_Log3G12(x), y, atol=TOLERANCE_ABSOLUTE_TESTS

947 )

948

949 def test_domain_range_scale_log_encoding_Log3G12(self) -> None:

950 """

951 Test :func:`colour.models.rgb.transfer_functions.red.\

952 log_encoding_Log3G12` definition domain and range scale support.

953 """

954

955 x = 0.18

956 y = log_encoding_Log3G12(x)

957

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

959 for scale, factor in d_r:

960 with domain_range_scale(scale):

961 np.testing.assert_allclose(

962 log_encoding_Log3G12(x * factor),

963 y * factor,

964 atol=TOLERANCE_ABSOLUTE_TESTS,

965 )

966

967 @ignore_numpy_errors

968 def test_nan_log_encoding_Log3G12(self) -> None:

969 """

970 Test :func:`colour.models.rgb.transfer_functions.red.\

971 log_encoding_Log3G12` definition nan support.

972 """

973

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

975

976

977 class TestLogDecoding_Log3G12:

978 """

979 Define :func:`colour.models.rgb.transfer_functions.red.\

980 log_decoding_Log3G12` definition unit tests methods.

981 """

982

983 def test_log_decoding_Log3G12(self) -> None:

984 """

985 Test :func:`colour.models.rgb.transfer_functions.red.\

986 log_decoding_Log3G12` definition.

987 """

988

989 np.testing.assert_allclose(

990 log_decoding_Log3G12(0.0), 0.0, atol=TOLERANCE_ABSOLUTE_TESTS

991 )

992

993 np.testing.assert_allclose(

994 log_decoding_Log3G12(0.333332662015923),

995 0.18,

996 atol=TOLERANCE_ABSOLUTE_TESTS,

997 )

998

999 np.testing.assert_allclose(

1000 log_decoding_Log3G12(0.469991923234319),

1001 1.0,

1002 atol=TOLERANCE_ABSOLUTE_TESTS,

1003 )

1004

1005 np.testing.assert_allclose(

1006 log_decoding_Log3G12(1.0),

1007 737.29848406719,

1008 atol=TOLERANCE_ABSOLUTE_TESTS,

1009 )

1010

1011 def test_n_dimensional_log_decoding_Log3G12(self) -> None:

1012 """

1013 Test :func:`colour.models.rgb.transfer_functions.red.\

1014 log_decoding_Log3G12` definition n-dimensional arrays support.

1015 """

1016

1017 y = 0.333332662015923

1018 x = log_decoding_Log3G12(y)

1019

1020 y = np.tile(y, 6)

1021 x = np.tile(x, 6)

1022 np.testing.assert_allclose(

1023 log_decoding_Log3G12(y), x, atol=TOLERANCE_ABSOLUTE_TESTS

1024 )

1025

1026 y = np.reshape(y, (2, 3))

1027 x = np.reshape(x, (2, 3))

1028 np.testing.assert_allclose(

1029 log_decoding_Log3G12(y), x, atol=TOLERANCE_ABSOLUTE_TESTS

1030 )

1031

1032 y = np.reshape(y, (2, 3, 1))

1033 x = np.reshape(x, (2, 3, 1))

1034 np.testing.assert_allclose(

1035 log_decoding_Log3G12(y), x, atol=TOLERANCE_ABSOLUTE_TESTS

1036 )

1037

1038 def test_domain_range_scale_log_decoding_Log3G12(self) -> None:

1039 """

1040 Test :func:`colour.models.rgb.transfer_functions.red.\

1041 log_decoding_Log3G12` definition domain and range scale support.

1042 """

1043

1044 y = 0.18

1045 x = log_decoding_Log3G12(y)

1046

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

1048 for scale, factor in d_r:

1049 with domain_range_scale(scale):

1050 np.testing.assert_allclose(

1051 log_decoding_Log3G12(y * factor),

1052 x * factor,

1053 atol=TOLERANCE_ABSOLUTE_TESTS,

1054 )

1055

1056 @ignore_numpy_errors

1057 def test_nan_log_decoding_Log3G12(self) -> None:

1058 """

1059 Test :func:`colour.models.rgb.transfer_functions.red.\

1060 log_decoding_Log3G12` definition nan support.

1061 """

1062

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