Coverage for colorimetry/tests/test_lightness.py: 100%

1"""Define the unit tests for the :mod:`colour.colorimetry.lightness` module."""

2

3 from __future__ import annotations

4

5 import numpy as np

6

7 from colour.colorimetry import (

8 intermediate_lightness_function_CIE1976,

9 lightness_Abebe2017,

10 lightness_CIE1976,

11 lightness_Fairchild2010,

12 lightness_Fairchild2011,

13 lightness_Glasser1958,

14 lightness_Wyszecki1963,

15)

16 from colour.colorimetry.lightness import lightness

17 from colour.constants import TOLERANCE_ABSOLUTE_TESTS

18 from colour.utilities import domain_range_scale, ignore_numpy_errors

19

20 __author__ = "Colour Developers"

21 __copyright__ = "Copyright 2013 Colour Developers"

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

23 __maintainer__ = "Colour Developers"

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

25 __status__ = "Production"

26

27 __all__ = [

28 "TestLightnessGlasser1958",

29 "TestLightnessWyszecki1963",

30 "TestIntermediateLightnessFunctionCIE1976",

31 "TestLightnessCIE1976",

32 "TestLightnessFairchild2010",

33 "TestLightnessFairchild2011",

34 "TestLightnessAbebe2017",

35 "TestLightness",

36]

37

38

39 class TestLightnessGlasser1958:

40 """

41 Define :func:`colour.colorimetry.lightness.lightness_Glasser1958`

42 definition unit tests methods.

43 """

44

45 def test_lightness_Glasser1958(self) -> None:

46 """

47 Test :func:`colour.colorimetry.lightness.lightness_Glasser1958`

48 definition.

49 """

50

51 np.testing.assert_allclose(

52 lightness_Glasser1958(12.19722535),

53 39.83512646492521,

54 atol=TOLERANCE_ABSOLUTE_TESTS,

55 )

56

57 np.testing.assert_allclose(

58 lightness_Glasser1958(23.04276781),

59 53.585946877480623,

60 atol=TOLERANCE_ABSOLUTE_TESTS,

61 )

62

63 np.testing.assert_allclose(

64 lightness_Glasser1958(6.15720079),

65 27.972867038082629,

66 atol=TOLERANCE_ABSOLUTE_TESTS,

67 )

68

69 def test_n_dimensional_lightness_Glasser1958(self) -> None:

70 """

71 Test :func:`colour.colorimetry.lightness.lightness_Glasser1958`

72 definition n-dimensional arrays support.

73 """

74

75 Y = 12.19722535

76 L = lightness_Glasser1958(Y)

77

78 Y = np.tile(Y, 6)

79 L = np.tile(L, 6)

80 np.testing.assert_allclose(

81 lightness_Glasser1958(Y), L, atol=TOLERANCE_ABSOLUTE_TESTS

82 )

83

84 Y = np.reshape(Y, (2, 3))

85 L = np.reshape(L, (2, 3))

86 np.testing.assert_allclose(

87 lightness_Glasser1958(Y), L, atol=TOLERANCE_ABSOLUTE_TESTS

88 )

89

90 Y = np.reshape(Y, (2, 3, 1))

91 L = np.reshape(L, (2, 3, 1))

92 np.testing.assert_allclose(

93 lightness_Glasser1958(Y), L, atol=TOLERANCE_ABSOLUTE_TESTS

94 )

95

96 def test_domain_range_scale_lightness_Glasser1958(self) -> None:

97 """

98 Test :func:`colour.colorimetry.lightness.lightness_Glasser1958`

99 definition domain and range scale support.

100 """

101

102 L = lightness_Glasser1958(12.19722535)

103

104 d_r = (("reference", 1), ("1", 0.01), ("100", 1))

105 for scale, factor in d_r:

106 with domain_range_scale(scale):

107 np.testing.assert_allclose(

108 lightness_Glasser1958(12.19722535 * factor),

109 L * factor,

110 atol=TOLERANCE_ABSOLUTE_TESTS,

111 )

112

113 @ignore_numpy_errors

114 def test_nan_lightness_Glasser1958(self) -> None:

115 """

116 Test :func:`colour.colorimetry.lightness.lightness_Glasser1958`

117 definition nan support.

118 """

119

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

121

122

123 class TestLightnessWyszecki1963:

124 """

125 Define :func:`colour.colorimetry.lightness.lightness_Wyszecki1963`

126 definition unit tests methods.

127 """

128

129 def test_lightness_Wyszecki1963(self) -> None:

130 """

131 Test :func:`colour.colorimetry.lightness.lightness_Wyszecki1963`

132 definition.

133 """

134

135 np.testing.assert_allclose(

136 lightness_Wyszecki1963(12.19722535),

137 40.547574599570197,

138 atol=TOLERANCE_ABSOLUTE_TESTS,

139 )

140

141 np.testing.assert_allclose(

142 lightness_Wyszecki1963(23.04276781),

143 54.140714588256841,

144 atol=TOLERANCE_ABSOLUTE_TESTS,

145 )

146

147 np.testing.assert_allclose(

148 lightness_Wyszecki1963(6.15720079),

149 28.821339499883976,

150 atol=TOLERANCE_ABSOLUTE_TESTS,

151 )

152

153 def test_n_dimensional_lightness_Wyszecki1963(self) -> None:

154 """

155 Test :func:`colour.colorimetry.lightness.lightness_Wyszecki1963`

156 definition n-dimensional arrays support.

157 """

158

159 Y = 12.19722535

160 W = lightness_Wyszecki1963(Y)

161

162 Y = np.tile(Y, 6)

163 W = np.tile(W, 6)

164 np.testing.assert_allclose(

165 lightness_Wyszecki1963(Y), W, atol=TOLERANCE_ABSOLUTE_TESTS

166 )

167

168 Y = np.reshape(Y, (2, 3))

169 W = np.reshape(W, (2, 3))

170 np.testing.assert_allclose(

171 lightness_Wyszecki1963(Y), W, atol=TOLERANCE_ABSOLUTE_TESTS

172 )

173

174 Y = np.reshape(Y, (2, 3, 1))

175 W = np.reshape(W, (2, 3, 1))

176 np.testing.assert_allclose(

177 lightness_Wyszecki1963(Y), W, atol=TOLERANCE_ABSOLUTE_TESTS

178 )

179

180 def test_domain_range_scale_lightness_Wyszecki1963(self) -> None:

181 """

182 Test :func:`colour.colorimetry.lightness.lightness_Wyszecki1963`

183 definition domain and range scale support.

184 """

185

186 W = lightness_Wyszecki1963(12.19722535)

187

188 d_r = (("reference", 1), ("1", 0.01), ("100", 1))

189 for scale, factor in d_r:

190 with domain_range_scale(scale):

191 np.testing.assert_allclose(

192 lightness_Wyszecki1963(12.19722535 * factor),

193 W * factor,

194 atol=TOLERANCE_ABSOLUTE_TESTS,

195 )

196

197 @ignore_numpy_errors

198 def test_nan_lightness_Wyszecki1963(self) -> None:

199 """

200 Test :func:`colour.colorimetry.lightness.lightness_Wyszecki1963`

201 definition nan support.

202 """

203

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

205

206

207 class TestIntermediateLightnessFunctionCIE1976:

208 """

209 Define :func:`colour.colorimetry.lightness.\

210 intermediate_lightness_function_CIE1976` definition unit tests methods.

211 """

212

213 def test_intermediate_lightness_function_CIE1976(self) -> None:

214 """

215 Test :func:`colour.colorimetry.lightness.\

216 intermediate_lightness_function_CIE1976` definition.

217 """

218

219 np.testing.assert_allclose(

220 intermediate_lightness_function_CIE1976(12.19722535),

221 0.495929964178047,

222 atol=TOLERANCE_ABSOLUTE_TESTS,

223 )

224

225 np.testing.assert_allclose(

226 intermediate_lightness_function_CIE1976(23.04276781),

227 0.613072093530391,

228 atol=TOLERANCE_ABSOLUTE_TESTS,

229 )

230

231 np.testing.assert_allclose(

232 intermediate_lightness_function_CIE1976(6.15720079),

233 0.394876333449113,

234 atol=TOLERANCE_ABSOLUTE_TESTS,

235 )

236

237 def test_n_dimensional_intermediate_lightness_function_CIE1976(self) -> None:

238 """

239 Test :func:`colour.colorimetry.lightness.\

240 intermediate_lightness_function_CIE1976` definition n-dimensional arrays

241 support.

242 """

243

244 Y = 12.19722535

245 f_Y_Y_n = intermediate_lightness_function_CIE1976(Y)

246

247 Y = np.tile(Y, 6)

248 f_Y_Y_n = np.tile(f_Y_Y_n, 6)

249 np.testing.assert_allclose(

250 intermediate_lightness_function_CIE1976(Y),

251 f_Y_Y_n,

252 atol=TOLERANCE_ABSOLUTE_TESTS,

253 )

254

255 Y = np.reshape(Y, (2, 3))

256 f_Y_Y_n = np.reshape(f_Y_Y_n, (2, 3))

257 np.testing.assert_allclose(

258 intermediate_lightness_function_CIE1976(Y),

259 f_Y_Y_n,

260 atol=TOLERANCE_ABSOLUTE_TESTS,

261 )

262

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

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

265 np.testing.assert_allclose(

266 intermediate_lightness_function_CIE1976(Y),

267 f_Y_Y_n,

268 atol=TOLERANCE_ABSOLUTE_TESTS,

269 )

270

271 def test_domain_range_scale_intermediate_lightness_function_CIE1976(self) -> None:

272 """

273 Test :func:`colour.colorimetry.lightness.\

274 intermediate_lightness_function_CIE1976` definition domain and range scale

275 support.

276 """

277

278 f_Y_Y_n = intermediate_lightness_function_CIE1976(12.19722535, 100)

279

280 for scale in ("reference", "1", "100"):

281 with domain_range_scale(scale):

282 np.testing.assert_allclose(

283 intermediate_lightness_function_CIE1976(12.19722535, 100),

284 f_Y_Y_n,

285 atol=TOLERANCE_ABSOLUTE_TESTS,

286 )

287

288 @ignore_numpy_errors

289 def test_nan_intermediate_lightness_function_CIE1976(self) -> None:

290 """

291 Test :func:`colour.colorimetry.lightness.\

292 intermediate_lightness_function_CIE1976` definition nan support.

293 """

294

295 intermediate_lightness_function_CIE1976(

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

297 )

298

299

300 class TestLightnessCIE1976:

301 """

302 Define :func:`colour.colorimetry.lightness.lightness_CIE1976` definition

303 unit tests methods.

304 """

305

306 def test_lightness_CIE1976(self) -> None:

307 """

308 Test :func:`colour.colorimetry.lightness.lightness_CIE1976`

309 definition.

310 """

311

312 np.testing.assert_allclose(

313 lightness_CIE1976(12.19722535),

314 41.527875844653451,

315 atol=TOLERANCE_ABSOLUTE_TESTS,

316 )

317

318 np.testing.assert_allclose(

319 lightness_CIE1976(23.04276781),

320 55.116362849525402,

321 atol=TOLERANCE_ABSOLUTE_TESTS,

322 )

323

324 np.testing.assert_allclose(

325 lightness_CIE1976(6.15720079),

326 29.805654680097106,

327 atol=TOLERANCE_ABSOLUTE_TESTS,

328 )

329

330 np.testing.assert_allclose(

331 lightness_CIE1976(12.19722535, 50),

332 56.480581732417676,

333 atol=TOLERANCE_ABSOLUTE_TESTS,

334 )

335

336 np.testing.assert_allclose(

337 lightness_CIE1976(12.19722535, 75),

338 47.317620274162735,

339 atol=TOLERANCE_ABSOLUTE_TESTS,

340 )

341

342 np.testing.assert_allclose(

343 lightness_CIE1976(12.19722535, 95),

344 42.519930728120940,

345 atol=TOLERANCE_ABSOLUTE_TESTS,

346 )

347

348 def test_n_dimensional_lightness_CIE1976(self) -> None:

349 """

350 Test :func:`colour.colorimetry.lightness.lightness_CIE1976`

351 definition n-dimensional arrays support.

352 """

353

354 Y = 12.19722535

355 L_star = lightness_CIE1976(Y)

356

357 Y = np.tile(Y, 6)

358 L_star = np.tile(L_star, 6)

359 np.testing.assert_allclose(

360 lightness_CIE1976(Y), L_star, atol=TOLERANCE_ABSOLUTE_TESTS

361 )

362

363 Y = np.reshape(Y, (2, 3))

364 L_star = np.reshape(L_star, (2, 3))

365 np.testing.assert_allclose(

366 lightness_CIE1976(Y), L_star, atol=TOLERANCE_ABSOLUTE_TESTS

367 )

368

369 Y = np.reshape(Y, (2, 3, 1))

370 L_star = np.reshape(L_star, (2, 3, 1))

371 np.testing.assert_allclose(

372 lightness_CIE1976(Y), L_star, atol=TOLERANCE_ABSOLUTE_TESTS

373 )

374

375 def test_domain_range_scale_lightness_CIE1976(self) -> None:

376 """

377 Test :func:`colour.colorimetry.lightness.lightness_CIE1976`

378 definition domain and range scale support.

379 """

380

381 L_star = lightness_CIE1976(12.19722535, 100)

382

383 d_r = (("reference", 1), ("1", 0.01), ("100", 1))

384 for scale, factor in d_r:

385 with domain_range_scale(scale):

386 np.testing.assert_allclose(

387 lightness_CIE1976(12.19722535 * factor, 100 * factor),

388 L_star * factor,

389 atol=TOLERANCE_ABSOLUTE_TESTS,

390 )

391

392 @ignore_numpy_errors

393 def test_nan_lightness_CIE1976(self) -> None:

394 """

395 Test :func:`colour.colorimetry.lightness.lightness_CIE1976`

396 definition nan support.

397 """

398

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

400

401

402 class TestLightnessFairchild2010:

403 """

404 Define :func:`colour.colorimetry.lightness.lightness_Fairchild2010`

405 definition unit tests methods.

406 """

407

408 def test_lightness_Fairchild2010(self) -> None:

409 """

410 Test :func:`colour.colorimetry.lightness.lightness_Fairchild2010`

411 definition.

412 """

413

414 np.testing.assert_allclose(

415 lightness_Fairchild2010(12.19722535 / 100),

416 31.996390226262736,

417 atol=TOLERANCE_ABSOLUTE_TESTS,

418 )

419

420 np.testing.assert_allclose(

421 lightness_Fairchild2010(23.04276781 / 100),

422 60.203153682783302,

423 atol=TOLERANCE_ABSOLUTE_TESTS,

424 )

425

426 np.testing.assert_allclose(

427 lightness_Fairchild2010(6.15720079 / 100),

428 11.836517240976489,

429 atol=TOLERANCE_ABSOLUTE_TESTS,

430 )

431

432 np.testing.assert_allclose(

433 lightness_Fairchild2010(12.19722535 / 100, 2.75),

434 24.424283249379986,

435 atol=TOLERANCE_ABSOLUTE_TESTS,

436 )

437

438 np.testing.assert_allclose(

439 lightness_Fairchild2010(1008),

440 100.019986327374240,

441 atol=TOLERANCE_ABSOLUTE_TESTS,

442 )

443

444 np.testing.assert_allclose(

445 lightness_Fairchild2010(100800),

446 100.019999997090270,

447 atol=TOLERANCE_ABSOLUTE_TESTS,

448 )

449

450 def test_n_dimensional_lightness_Fairchild2010(self) -> None:

451 """

452 Test :func:`colour.colorimetry.lightness.lightness_Fairchild2010`

453 definition n-dimensional arrays support.

454 """

455

456 Y = 12.19722535 / 100

457 L_hdr = lightness_Fairchild2010(Y)

458

459 Y = np.tile(Y, 6)

460 L_hdr = np.tile(L_hdr, 6)

461 np.testing.assert_allclose(

462 lightness_Fairchild2010(Y), L_hdr, atol=TOLERANCE_ABSOLUTE_TESTS

463 )

464

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

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

467 np.testing.assert_allclose(

468 lightness_Fairchild2010(Y), L_hdr, atol=TOLERANCE_ABSOLUTE_TESTS

469 )

470

471 Y = np.reshape(Y, (2, 3, 1))

472 L_hdr = np.reshape(L_hdr, (2, 3, 1))

473 np.testing.assert_allclose(

474 lightness_Fairchild2010(Y), L_hdr, atol=TOLERANCE_ABSOLUTE_TESTS

475 )

476

477 def test_domain_range_scale_lightness_Fairchild2010(self) -> None:

478 """

479 Test :func:`colour.colorimetry.lightness.lightness_Fairchild2010`

480 definition domain and range scale support.

481 """

482

483 L_hdr = lightness_Fairchild2010(12.19722535 / 100)

484

485 d_r = (("reference", 1, 1), ("1", 1, 0.01), ("100", 100, 1))

486 for scale, factor_a, factor_b in d_r:

487 with domain_range_scale(scale):

488 np.testing.assert_allclose(

489 lightness_Fairchild2010(12.19722535 / 100 * factor_a),

490 L_hdr * factor_b,

491 atol=TOLERANCE_ABSOLUTE_TESTS,

492 )

493

494 @ignore_numpy_errors

495 def test_nan_lightness_Fairchild2010(self) -> None:

496 """

497 Test :func:`colour.colorimetry.lightness.lightness_Fairchild2010`

498 definition nan support.

499 """

500

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

502

503

504 class TestLightnessFairchild2011:

505 """

506 Define :func:`colour.colorimetry.lightness.lightness_Fairchild2011`

507 definition unit tests methods.

508 """

509

510 def test_lightness_Fairchild2011(self) -> None:

511 """

512 Test :func:`colour.colorimetry.lightness.lightness_Fairchild2011`

513 definition.

514 """

515

516 np.testing.assert_allclose(

517 lightness_Fairchild2011(12.19722535 / 100),

518 51.852958445912506,

519 atol=TOLERANCE_ABSOLUTE_TESTS,

520 )

521

522 np.testing.assert_allclose(

523 lightness_Fairchild2011(23.04276781 / 100),

524 65.275207956353853,

525 atol=TOLERANCE_ABSOLUTE_TESTS,

526 )

527

528 np.testing.assert_allclose(

529 lightness_Fairchild2011(6.15720079 / 100),

530 39.818935510715917,

531 atol=TOLERANCE_ABSOLUTE_TESTS,

532 )

533

534 np.testing.assert_allclose(

535 lightness_Fairchild2011(12.19722535 / 100, 2.75),

536 0.13268968410139345,

537 atol=TOLERANCE_ABSOLUTE_TESTS,

538 )

539

540 np.testing.assert_allclose(

541 lightness_Fairchild2011(1008),

542 234.72925682,

543 atol=TOLERANCE_ABSOLUTE_TESTS,

544 )

545

546 np.testing.assert_allclose(

547 lightness_Fairchild2011(100800),

548 245.5705978,

549 atol=TOLERANCE_ABSOLUTE_TESTS,

550 )

551

552 def test_n_dimensional_lightness_Fairchild2011(self) -> None:

553 """

554 Test :func:`colour.colorimetry.lightness.lightness_Fairchild2011`

555 definition n-dimensional arrays support.

556 """

557

558 Y = 12.19722535 / 100

559 L_hdr = lightness_Fairchild2011(Y)

560

561 Y = np.tile(Y, 6)

562 L_hdr = np.tile(L_hdr, 6)

563 np.testing.assert_allclose(

564 lightness_Fairchild2011(Y), L_hdr, atol=TOLERANCE_ABSOLUTE_TESTS

565 )

566

567 Y = np.reshape(Y, (2, 3))

568 L_hdr = np.reshape(L_hdr, (2, 3))

569 np.testing.assert_allclose(

570 lightness_Fairchild2011(Y), L_hdr, atol=TOLERANCE_ABSOLUTE_TESTS

571 )

572

573 Y = np.reshape(Y, (2, 3, 1))

574 L_hdr = np.reshape(L_hdr, (2, 3, 1))

575 np.testing.assert_allclose(

576 lightness_Fairchild2011(Y), L_hdr, atol=TOLERANCE_ABSOLUTE_TESTS

577 )

578

579 def test_domain_range_scale_lightness_Fairchild2011(self) -> None:

580 """

581 Test :func:`colour.colorimetry.lightness.lightness_Fairchild2011`

582 definition domain and range scale support.

583 """

584

585 L_hdr = lightness_Fairchild2011(12.19722535 / 100)

586

587 d_r = (("reference", 1, 1), ("1", 1, 0.01), ("100", 100, 1))

588 for scale, factor_a, factor_b in d_r:

589 with domain_range_scale(scale):

590 np.testing.assert_allclose(

591 lightness_Fairchild2011(12.19722535 / 100 * factor_a),

592 L_hdr * factor_b,

593 atol=TOLERANCE_ABSOLUTE_TESTS,

594 )

595

596 @ignore_numpy_errors

597 def test_nan_lightness_Fairchild2011(self) -> None:

598 """

599 Test :func:`colour.colorimetry.lightness.lightness_Fairchild2011`

600 definition nan support.

601 """

602

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

604

605

606 class TestLightnessAbebe2017:

607 """

608 Define :func:`colour.colorimetry.lightness.lightness_Abebe2017`

609 definition unit tests methods.

610 """

611

612 def test_lightness_Abebe2017(self) -> None:

613 """

614 Test :func:`colour.colorimetry.lightness.lightness_Abebe2017`

615 definition.

616 """

617

618 np.testing.assert_allclose(

619 lightness_Abebe2017(12.19722535),

620 0.486955571109229,

621 atol=TOLERANCE_ABSOLUTE_TESTS,

622 )

623

624 np.testing.assert_allclose(

625 lightness_Abebe2017(12.19722535, method="Stevens"),

626 0.474544792145434,

627 atol=TOLERANCE_ABSOLUTE_TESTS,

628 )

629

630 np.testing.assert_allclose(

631 lightness_Abebe2017(12.19722535, 1000),

632 0.286847428534793,

633 atol=TOLERANCE_ABSOLUTE_TESTS,

634 )

635

636 np.testing.assert_allclose(

637 lightness_Abebe2017(12.19722535, 4000),

638 0.192145492588158,

639 atol=TOLERANCE_ABSOLUTE_TESTS,

640 )

641

642 np.testing.assert_allclose(

643 lightness_Abebe2017(12.19722535, 4000, method="Stevens"),

644 0.170365211220992,

645 atol=TOLERANCE_ABSOLUTE_TESTS,

646 )

647

648 def test_n_dimensional_lightness_Abebe2017(self) -> None:

649 """

650 Test :func:`colour.colorimetry.lightness.lightness_Abebe2017`

651 definition n-dimensional arrays support.

652 """

653

654 Y = 12.19722535

655 L = lightness_Abebe2017(Y)

656

657 Y = np.tile(Y, 6)

658 L = np.tile(L, 6)

659 np.testing.assert_allclose(

660 lightness_Abebe2017(Y), L, atol=TOLERANCE_ABSOLUTE_TESTS

661 )

662

663 Y = np.reshape(Y, (2, 3))

664 L = np.reshape(L, (2, 3))

665 np.testing.assert_allclose(

666 lightness_Abebe2017(Y), L, atol=TOLERANCE_ABSOLUTE_TESTS

667 )

668

669 Y = np.reshape(Y, (2, 3, 1))

670 L = np.reshape(L, (2, 3, 1))

671 np.testing.assert_allclose(

672 lightness_Abebe2017(Y), L, atol=TOLERANCE_ABSOLUTE_TESTS

673 )

674

675 @ignore_numpy_errors

676 def test_nan_lightness_Abebe2017(self) -> None:

677 """

678 Test :func:`colour.colorimetry.lightness.lightness_Abebe2017`

679 definition nan support.

680 """

681

682 cases = np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])

683 lightness_Abebe2017(cases, cases)

684

685

686 class TestLightness:

687 """

688 Define :func:`colour.colorimetry.lightness.lightness` definition unit

689 tests methods.

690 """

691

692 def test_domain_range_scale_lightness(self) -> None:

693 """

694 Test :func:`colour.colorimetry.lightness.lightness` definition domain

695 and range scale support.

696 """

697

698 m = (

699 "Glasser 1958",

700 "Wyszecki 1963",

701 "CIE 1976",

702 "Fairchild 2010",

703 "Fairchild 2011",

704 "Abebe 2017",

705 )

706 v = [lightness(12.19722535, method, Y_n=100) for method in m]

707

708 d_r = (("reference", 1), ("1", 0.01), ("100", 1))

709 for method, value in zip(m, v, strict=True):

710 for scale, factor in d_r:

711 with domain_range_scale(scale):

712 np.testing.assert_allclose(

713 lightness(12.19722535 * factor, method, Y_n=100 * factor),

714 value * factor,

715 atol=TOLERANCE_ABSOLUTE_TESTS,

716 )