Coverage for colour/colorimetry/tests/test_blackbody.py: 100%
74 statements
« prev ^ index » next coverage.py v7.11.0, created at 2025-11-15 19:01 +1300
« prev ^ index » next coverage.py v7.11.0, created at 2025-11-15 19:01 +1300
1"""Define the unit tests for the :mod:`colour.colorimetry.blackbody` module."""
3from __future__ import annotations
5import typing
6from itertools import product
8import numpy as np
9import pytest
11from colour.colorimetry import (
12 SpectralShape,
13 planck_law,
14 rayleigh_jeans_law,
15 sd_blackbody,
16 sd_rayleigh_jeans,
17)
18from colour.constants import TOLERANCE_ABSOLUTE_TESTS
20if typing.TYPE_CHECKING:
21 from colour.hints import NDArrayFloat
23from colour.utilities import ignore_numpy_errors
25__author__ = "Colour Developers"
26__copyright__ = "Copyright 2013 Colour Developers"
27__license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause"
28__maintainer__ = "Colour Developers"
29__email__ = "colour-developers@colour-science.org"
30__status__ = "Production"
32__all__ = [
33 "DATA_PLANCK_LAW",
34 "DATA_BLACKBODY",
35 "DATA_RAYLEIGH_JEANS_LAW",
36 "DATA_RAYLEIGH_JEANS",
37 "TestPlanckLaw",
38 "TestSdBlackbody",
39 "TestRayleighJeansLaw",
40 "TestSdRayleighJeans",
41]
44DATA_PLANCK_LAW: dict = {
45 1667: np.array(
46 [
47 0.000000000000000e000,
48 0.000000000000000e000,
49 0.000000000000000e000,
50 0.000000000000000e000,
51 6.006134512060715e-212,
52 2.581138199699265e-096,
53 2.991192553728005e-039,
54 1.800055676589435e-011,
55 2.468492049044663e002,
56 1.615956484003356e008,
57 2.311790654845391e010,
58 4.959729128263715e010,
59 1.429819160471000e010,
60 1.728272063092092e009,
61 1.454720412629704e008,
62 1.046192398426646e007,
63 ]
64 ),
65 5000: np.array(
66 [
67 0.000000000000000e000,
68 0.000000000000000e000,
69 0.000000000000000e000,
70 2.211832608569335e-132,
71 8.860635033018581e-056,
72 3.135062153702092e-018,
73 3.296566337346393e000,
74 5.975780855300837e008,
75 1.422301922547989e012,
76 1.231071705140845e013,
77 6.775708530833963e012,
78 1.074763978522569e012,
79 1.013929733763001e011,
80 7.670601003755050e009,
81 5.254367965012848e008,
82 3.434696144765859e007,
83 ]
84 ),
85 10000: np.array(
86 [
87 0.000000000000000e000,
88 0.000000000000000e000,
89 7.077864347421871e-131,
90 2.835403210565946e-054,
91 1.003219889184669e-016,
92 1.054901227950846e002,
93 1.912249873696268e010,
94 4.551366152153565e013,
95 3.939429456450704e014,
96 2.168226729866868e014,
97 3.439244731272221e013,
98 3.244575148041603e012,
99 2.454592321201616e011,
100 1.681397748804111e010,
101 1.099102766325075e009,
102 7.023565300892627e007,
103 ]
104 ),
105 100000: np.array(
106 [
107 3.887203488469926e-34,
108 2.126338122524389e-04,
109 2.780064431399975e10,
110 5.619415522222338e16,
111 1.412499469182817e19,
112 4.002679163635765e19,
113 1.309621960617621e19,
114 1.668675488105569e18,
115 1.436224908464434e17,
116 1.043271214642522e16,
117 7.012275974522810e14,
118 4.542159102349822e13,
119 2.889595565075848e12,
120 1.821997118722198e11,
121 1.143770312696396e10,
122 7.164293165970466e08,
123 ]
124 ),
125 10000000000000000000: np.array(
126 [
127 8.278028225847591e40,
128 5.173767641156605e39,
129 3.233604775723460e38,
130 2.021002984827344e37,
131 1.263126865517147e36,
132 7.894542909482346e34,
133 4.934089318426522e33,
134 3.083805824016593e32,
135 1.927378640010376e31,
136 1.204611650006487e30,
137 7.528822812540548e28,
138 4.705514257837843e27,
139 2.940946411148653e26,
140 1.838091506967908e25,
141 1.148807191854943e24,
142 7.180044949093393e22,
143 ]
144 ),
145}
147DATA_BLACKBODY: NDArrayFloat = np.array(
148 [
149 6654.27827064,
150 6709.60527925,
151 6764.82512152,
152 6819.93307864,
153 6874.92448983,
154 6929.79475262,
155 6984.53932320,
156 7039.15371664,
157 7093.63350719,
158 7147.97432845,
159 7202.17187363,
160 7256.22189565,
161 7310.12020737,
162 7363.86268165,
163 7417.44525154,
164 7470.86391025,
165 7524.11471135,
166 7577.19376869,
167 7630.09725652,
168 7682.82140944,
169 7735.36252240,
170 7787.71695067,
171 7839.88110979,
172 7891.85147549,
173 7943.62458362,
174 7995.19703005,
175 8046.56547051,
176 8097.72662050,
177 8148.67725513,
178 8199.41420894,
179 8249.93437573,
180 8300.23470836,
181 8350.31221854,
182 8400.16397663,
183 8449.78711137,
184 8499.17880967,
185 8548.33631631,
186 8597.25693372,
187 8645.93802164,
188 8694.37699689,
189 8742.57133299,
190 8790.51855994,
191 8838.21626380,
192 8885.66208644,
193 8932.85372514,
194 8979.78893227,
195 9026.46551490,
196 9072.88133449,
197 9119.03430644,
198 9164.92239976,
199 9210.54363669,
200 9255.89609224,
201 9300.97789384,
202 9345.78722093,
203 9390.32230452,
204 9434.58142677,
205 9478.56292060,
206 9522.26516922,
207 9565.68660570,
208 9608.82571256,
209 9651.68102126,
210 9694.25111185,
211 9736.53461241,
212 9778.53019868,
213 9820.23659354,
214 9861.65256660,
215 9902.77693369,
216 9943.60855641,
217 9984.14634166,
218 10024.38924118,
219 10064.33625106,
220 10103.98641125,
221 10143.33880512,
222 10182.39255895,
223 10221.14684147,
224 10259.60086337,
225 10297.75387680,
226 10335.60517492,
227 10373.15409140,
228 10410.39999994,
229 10447.34231378,
230 10483.98048522,
231 10520.31400514,
232 10556.34240253,
233 10592.06524395,
234 10627.48213314,
235 10662.59271046,
236 10697.39665243,
237 10731.89367128,
238 10766.08351444,
239 10799.96596406,
240 10833.54083657,
241 10866.80798215,
242 10899.76728432,
243 10932.41865941,
244 10964.76205614,
245 10996.79745511,
246 11028.52486836,
247 11059.94433889,
248 11091.05594022,
249 11121.85977591,
250 11152.35597912,
251 11182.54471212,
252 11212.42616589,
253 11242.00055963,
254 11271.26814031,
255 11300.22918226,
256 11328.88398670,
257 11357.23288130,
258 11385.27621977,
259 11413.01438137,
260 11440.44777057,
261 11467.57681651,
262 11494.40197267,
263 11520.92371641,
264 11547.14254852,
265 11573.05899287,
266 11598.67359596,
267 11623.98692649,
268 11648.99957501,
269 11673.71215347,
270 11698.12529482,
271 11722.23965267,
272 11746.05590082,
273 11769.57473294,
274 11792.79686212,
275 11815.72302055,
276 11838.35395910,
277 11860.69044694,
278 11882.73327121,
279 11904.48323661,
280 11925.94116506,
281 11947.10789532,
282 11967.98428265,
283 11988.57119843,
284 12008.86952986,
285 12028.88017954,
286 12048.60406519,
287 12068.04211929,
288 12087.19528873,
289 12106.06453447,
290 12124.65083127,
291 12142.95516728,
292 12160.97854379,
293 12178.72197486,
294 12196.18648704,
295 12213.37311905,
296 12230.28292145,
297 12246.91695637,
298 12263.27629719,
299 12279.36202824,
300 12295.17524453,
301 12310.71705141,
302 12325.98856435,
303 12340.99090860,
304 12355.72521896,
305 12370.19263945,
306 12384.39432308,
307 12398.33143156,
308 12412.00513505,
309 12425.41661189,
310 12438.56704832,
311 12451.45763827,
312 12464.08958306,
313 12476.46409119,
314 12488.58237807,
315 12500.44566579,
316 12512.05518287,
317 12523.41216403,
318 12534.51784999,
319 12545.37348716,
320 12555.98032751,
321 12566.33962828,
322 12576.45265178,
323 12586.32066519,
324 12595.94494032,
325 12605.32675343,
326 12614.46738498,
327 12623.36811947,
328 12632.03024523,
329 12640.45505419,
330 12648.64384173,
331 12656.59790644,
332 12664.31854999,
333 12671.80707689,
334 12679.06479434,
335 12686.09301201,
336 12692.89304194,
337 12699.46619826,
338 12705.81379711,
339 12711.93715643,
340 12717.83759579,
341 12723.51643624,
342 12728.97500013,
343 12734.21461098,
344 12739.23659331,
345 12744.04227248,
346 12748.63297453,
347 12753.01002609,
348 12757.17475416,
349 12761.12848599,
350 12764.87254898,
351 12768.40827049,
352 12771.73697774,
353 12774.85999765,
354 12777.77865673,
355 12780.49428093,
356 12783.00819555,
357 12785.32172507,
358 12787.43619307,
359 12789.35292209,
360 12791.07323350,
361 12792.59844743,
362 12793.92988261,
363 12795.06885627,
364 12796.01668406,
365 12796.77467992,
366 12797.34415597,
367 12797.72642243,
368 12797.92278749,
369 12797.93455726,
370 12797.76303562,
371 12797.40952415,
372 12796.87532205,
373 12796.16172604,
374 12795.27003026,
375 12794.20152618,
376 12792.95750257,
377 12791.53924533,
378 12789.94803749,
379 12788.18515908,
380 12786.25188706,
381 12784.14949528,
382 12781.87925435,
383 12779.44243162,
384 12776.84029106,
385 12774.07409325,
386 12771.14509526,
387 12768.05455060,
388 12764.80370917,
389 12761.39381718,
390 12757.82611712,
391 12754.10184764,
392 12750.22224355,
393 12746.18853574,
394 12742.00195113,
395 12737.66371261,
396 12733.17503899,
397 12728.53714494,
398 12723.75124098,
399 12718.81853337,
400 12713.74022411,
401 12708.51751090,
402 12703.15158703,
403 12697.64364143,
404 12691.99485855,
405 12686.20641836,
406 12680.27949632,
407 12674.21526329,
408 12668.01488555,
409 12661.67952475,
410 12655.21033783,
411 12648.60847706,
412 12641.87508995,
413 12635.01131925,
414 12628.01830291,
415 12620.89717405,
416 12613.64906092,
417 12606.27508691,
418 12598.77637047,
419 12591.15402515,
420 12583.40915951,
421 12575.54287714,
422 12567.55627664,
423 12559.45045156,
424 12551.22649042,
425 12542.88547667,
426 12534.42848868,
427 12525.85659972,
428 12517.17087794,
429 12508.37238636,
430 12499.46218286,
431 12490.44132013,
432 12481.31084572,
433 12472.07180197,
434 12462.72522603,
435 12453.27214983,
436 12443.71360008,
437 12434.05059828,
438 12424.28416067,
439 12414.41529824,
440 12404.44501674,
441 12394.37431665,
442 12384.20419318,
443 12373.93563628,
444 12363.56963061,
445 12353.10715554,
446 12342.54918519,
447 12331.89668836,
448 12321.15062856,
449 12310.31196403,
450 12299.38164769,
451 12288.36062720,
452 12277.24984489,
453 12266.05023782,
454 12254.76273776,
455 12243.38827118,
456 12231.92775927,
457 12220.38211792,
458 12208.75225776,
459 12197.03908412,
460 12185.24349708,
461 12173.36639143,
462 12161.40865671,
463 12149.37117718,
464 12137.25483188,
465 12125.06049458,
466 12112.78903381,
467 12100.44131289,
468 12088.01818988,
469 12075.52051766,
470 12062.94914387,
471 12050.30491098,
472 12037.58865624,
473 12024.80121175,
474 12011.94340442,
475 11999.01605600,
476 11986.01998309,
477 11972.95599717,
478 11959.82490456,
479 11946.62750648,
480 11933.36459906,
481 11920.03697332,
482 11906.64541520,
483 11893.19070557,
484 11879.67362026,
485 11866.09493006,
486 11852.45540071,
487 11838.75579295,
488 11824.99686253,
489 11811.17936021,
490 11797.30403177,
491 11783.37161803,
492 11769.38285489,
493 11755.33847331,
494 11741.23919934,
495 11727.08575414,
496 11712.87885400,
497 11698.61921032,
498 11684.30752968,
499 11669.94451382,
500 11655.53085966,
501 11641.06725934,
502 11626.55440020,
503 11611.99296484,
504 11597.38363109,
505 11582.72707208,
506 11568.02395621,
507 11553.27494718,
508 11538.48070404,
509 11523.64188117,
510 11508.75912831,
511 11493.83309058,
512 11478.86440851,
513 11463.85371803,
514 11448.80165051,
515 11433.70883278,
516 11418.57588715,
517 11403.40343140,
518 11388.19207883,
519 11372.94243828,
520 11357.65511413,
521 11342.33070633,
522 11326.96981042,
523 11311.57301754,
524 11296.14091447,
525 11280.67408363,
526 11265.17310311,
527 11249.63854667,
528 11234.07098379,
529 11218.47097968,
530 11202.83909529,
531 11187.17588733,
532 11171.48190831,
533 11155.75770652,
534 11140.00382611,
535 11124.22080706,
536 11108.40918520,
537 11092.56949227,
538 11076.70225590,
539 11060.80799967,
540 11044.88724309,
541 11028.94050163,
542 11012.96828677,
543 10996.97110598,
544 10980.94946277,
545 10964.90385669,
546 10948.83478337,
547 10932.74273452,
548 10916.62819797,
549 10900.49165767,
550 10884.33359373,
551 10868.15448243,
552 10851.95479625,
553 10835.73500386,
554 10819.49557018,
555 10803.23695638,
556 10786.95961991,
557 10770.66401450,
558 10754.35059021,
559 10738.01979343,
560 10721.67206689,
561 10705.30784972,
562 10688.92757743,
563 10672.53168195,
564 10656.12059164,
565 10639.69473134,
566 10623.25452233,
567 10606.80038243,
568 10590.33272593,
569 10573.85196369,
570 10557.35850312,
571 10540.85274820,
572 10524.33509952,
573 10507.80595427,
574 10491.26570629,
575 10474.71474607,
576 10458.15346079,
577 10441.58223429,
578 10425.00144718,
579 10408.41147676,
580 10391.81269711,
581 10375.20547907,
582 10358.59019029,
583 10341.96719523,
584 10325.33685516,
585 10308.69952825,
586 10292.05556949,
587 10275.40533080,
588 10258.74916099,
589 10242.08740581,
590 10225.42040795,
591 10208.74850708,
592 10192.07203984,
593 10175.39133990,
594 10158.70673793,
595 10142.01856166,
596 10125.32713586,
597 10108.63278242,
598 10091.93582030,
599 10075.23656557,
600 10058.53533147,
601 10041.83242836,
602 10025.12816380,
603 10008.42284253,
604 9991.71676650,
605 9975.01023489,
606 9958.30354412,
607 9941.59698789,
608 9924.89085715,
609 9908.18544019,
610 9891.48102260,
611 9874.77788729,
612 9858.07631455,
613 9841.37658201,
614 9824.67896473,
615 9807.98373514,
616 9791.29116311,
617 9774.60151594,
618 9757.91505839,
619 9741.23205271,
620 ]
621)
623DATA_RAYLEIGH_JEANS_LAW: dict = {
624 1667: np.array(
625 [
626 1.379970796097092e25,
627 8.624817475606822e23,
628 5.390510922254264e22,
629 3.369069326408915e21,
630 2.105668329005572e20,
631 1.316042705628482e19,
632 8.225266910178015e17,
633 5.140791818861259e16,
634 3.212994886788287e15,
635 2.008121804242679e14,
636 1.255076127651675e13,
637 7.844225797822966e11,
638 4.902641123639354e10,
639 3.064150702274596e09,
640 1.915094188921623e08,
641 1.196933868076014e07,
642 ]
643 ),
644 5000: np.array(
645 [
646 4.139084571376999e25,
647 2.586927857110624e24,
648 1.616829910694140e23,
649 1.010518694183838e22,
650 6.315741838648986e20,
651 3.947338649155616e19,
652 2.467086655722260e18,
653 1.541929159826412e17,
654 9.637057248915078e15,
655 6.023160780571924e14,
656 3.764475487857452e13,
657 2.352797179910908e12,
658 1.470498237444317e11,
659 9.190613984026983e09,
660 5.744133740016865e08,
661 3.590083587510540e07,
662 ]
663 ),
664 10000: np.array(
665 [
666 8.278169142753998e25,
667 5.173855714221249e24,
668 3.233659821388281e23,
669 2.021037388367675e22,
670 1.263148367729797e21,
671 7.894677298311232e19,
672 4.934173311444520e18,
673 3.083858319652825e17,
674 1.927411449783016e16,
675 1.204632156114385e15,
676 7.528950975714905e13,
677 4.705594359821815e12,
678 2.940996474888635e11,
679 1.838122796805397e10,
680 1.148826748003373e09,
681 7.180167175021081e07,
682 ]
683 ),
684 100000: np.array(
685 [
686 8.278169142753999e26,
687 5.173855714221249e25,
688 3.233659821388281e24,
689 2.021037388367675e23,
690 1.263148367729797e22,
691 7.894677298311232e20,
692 4.934173311444520e19,
693 3.083858319652825e18,
694 1.927411449783016e17,
695 1.204632156114385e16,
696 7.528950975714905e14,
697 4.705594359821816e13,
698 2.940996474888635e12,
699 1.838122796805397e11,
700 1.148826748003373e10,
701 7.180167175021081e08,
702 ]
703 ),
704 10000000000000000000: np.array(
705 [
706 8.278169142753998e40,
707 5.173855714221249e39,
708 3.233659821388280e38,
709 2.021037388367675e37,
710 1.263148367729797e36,
711 7.894677298311232e34,
712 4.934173311444520e33,
713 3.083858319652825e32,
714 1.927411449783016e31,
715 1.204632156114385e30,
716 7.528950975714904e28,
717 4.705594359821815e27,
718 2.940996474888635e26,
719 1.838122796805397e25,
720 1.148826748003373e24,
721 7.180167175021080e22,
722 ]
723 ),
724}
726DATA_RAYLEIGH_JEANS: NDArrayFloat = np.array(
727 [
728 2464304.08580116,
729 2437112.02495309,
730 2410293.99092788,
731 2383843.82698718,
732 2357755.49430373,
733 2332023.06938771,
734 2306640.74157597,
735 2281602.81058267,
736 2256903.68410954,
737 2232537.87551423,
738 2208500.00153509,
739 2184784.78007096,
740 2161387.02801446,
741 2138301.65913732,
742 2115523.68202642,
743 2093048.19806916,
744 2070870.39948685,
745 2048985.56741487,
746 2027389.07002836,
747 2006076.36071225,
748 1985042.97627445,
749 1964284.53520105,
750 1943796.73595254,
751 1923575.35529985,
752 1903616.24669927,
753 1883915.33870518,
754 1864468.63341964,
755 1845272.20497799,
756 1826322.19806929,
757 1807614.82649099,
758 1789146.37173673,
759 1770913.18161664,
760 1752911.66890902,
761 1735138.31004297,
762 1717589.64381086,
763 1700262.27011009,
764 1683152.84871331,
765 1666258.09806643,
766 1649574.79411371,
767 1633099.76914923,
768 1616829.91069414,
769 1600762.16039897,
770 1584893.51297047,
771 1569221.01512229,
772 1553741.76454898,
773 1538452.90892266,
774 1523351.64491191,
775 1508435.21722224,
776 1493700.91765764,
777 1479146.08420271,
778 1464768.10012489,
779 1450564.39309625,
780 1436532.43433442,
781 1422669.73776213,
782 1408973.85918499,
783 1395442.39548702,
784 1382072.98384357,
785 1368863.30095106,
786 1355811.06227338,
787 1342914.02130427,
788 1330169.96884561,
789 1317576.73230094,
790 1305132.17498411,
791 1292834.19544248,
792 1280680.72679452,
793 1268669.73608136,
794 1256799.22363196,
795 1245067.22244167,
796 1233471.79756379,
797 1222011.04551379,
798 1210683.09368606,
799 1199486.09978275,
800 1188418.25125442,
801 1177477.76475235,
802 1166662.88559214,
803 1155971.88722837,
804 1145403.07074002,
805 1134954.76432657,
806 1124625.32281429,
807 1114413.12717269,
808 1104316.58404080,
809 1094334.12526312,
810 1084464.20743492,
811 1074705.31145682,
812 1065055.94209833,
813 1055514.62757016,
814 1046079.91910521,
815 1036750.39054792,
816 1027524.63795180,
817 1018401.27918507,
818 1009378.95354415,
819 1000456.32137483,
820 991632.06370089,
821 982904.88186021,
822 974273.49714794,
823 965736.65046681,
824 957293.10198421,
825 948941.63079610,
826 940681.03459747,
827 932510.12935920,
828 924427.74901127,
829 916432.74513213,
830 908523.98664409,
831 900700.35951458,
832 892960.76646326,
833 885304.12667472,
834 877729.37551674,
835 870235.46426394,
836 862821.35982674,
837 855486.04448552,
838 848228.51562981,
839 841047.78550252,
840 833942.88094894,
841 826912.84317059,
842 819956.72748365,
843 813073.60308201,
844 806262.55280479,
845 799522.67290815,
846 792853.07284149,
847 786252.87502779,
848 779721.21464802,
849 773257.23942967,
850 766860.10943911,
851 760528.99687786,
852 754263.08588266,
853 748061.57232918,
854 741923.66363940,
855 735848.57859250,
856 729835.54713927,
857 723883.81021991,
858 717992.61958513,
859 712161.23762058,
860 706388.93717442,
861 700675.00138811,
862 695018.72353015,
863 689419.40683297,
864 683876.36433270,
865 678388.91871179,
866 672956.40214459,
867 667578.15614556,
868 662253.53142032,
869 656981.88771933,
870 651762.59369414,
871 646595.02675630,
872 641478.57293866,
873 636412.62675926,
874 631396.59108754,
875 626429.87701297,
876 621511.90371596,
877 616642.09834110,
878 611819.89587257,
879 607044.73901180,
880 602316.07805719,
881 597633.37078606,
882 592996.08233849,
883 588403.68510338,
884 583855.65860632,
885 579351.48939950,
886 574890.67095353,
887 570472.70355106,
888 566097.09418233,
889 561763.35644241,
890 557471.01043035,
891 553219.58264989,
892 549008.60591203,
893 544837.61923916,
894 540706.16777085,
895 536613.80267128,
896 532560.08103820,
897 528544.56581345,
898 524566.82569504,
899 520626.43505058,
900 516722.97383237,
901 512856.02749375,
902 509025.18690690,
903 505230.04828213,
904 501470.21308831,
905 497745.28797486,
906 494054.88469483,
907 490398.62002946,
908 486776.11571381,
909 483186.99836375,
910 479630.89940414,
911 476107.45499810,
912 472616.30597761,
913 469157.09777511,
914 465729.48035629,
915 462333.10815398,
916 458967.64000311,
917 455632.73907674,
918 452328.07282311,
919 449053.31290380,
920 445808.13513275,
921 442592.21941641,
922 439405.24969480,
923 436246.91388347,
924 433116.90381655,
925 430014.91519051,
926 426940.64750903,
927 423893.80402859,
928 420874.09170506,
929 417881.22114102,
930 414914.90653407,
931 411974.86562580,
932 409060.81965172,
933 406172.49329188,
934 403309.61462234,
935 400471.91506733,
936 397659.12935230,
937 394870.99545756,
938 392107.25457273,
939 389367.65105193,
940 386651.93236960,
941 383959.84907704,
942 381291.15475971,
943 378645.60599502,
944 376022.96231097,
945 373422.98614531,
946 370845.44280539,
947 368290.10042857,
948 365756.72994335,
949 363245.10503098,
950 360755.00208776,
951 358286.20018785,
952 355838.48104671,
953 353411.62898503,
954 351005.43089331,
955 348619.67619689,
956 346254.15682153,
957 343908.66715961,
958 341583.00403669,
959 339276.96667869,
960 336990.35667955,
961 334722.97796934,
962 332474.63678288,
963 330245.14162884,
964 328034.30325930,
965 325841.93463975,
966 323667.85091953,
967 321511.86940280,
968 319373.80951983,
969 317253.49279878,
970 315150.74283790,
971 313065.38527812,
972 310997.24777608,
973 308946.15997754,
974 306911.95349116,
975 304894.46186272,
976 302893.52054969,
977 300908.96689618,
978 298940.64010825,
979 296988.38122958,
980 295052.03311756,
981 293131.44041960,
982 291226.44954993,
983 289336.90866664,
984 287462.66764911,
985 285603.57807569,
986 283759.49320186,
987 281930.26793851,
988 280115.75883067,
989 278315.82403654,
990 276530.32330673,
991 274759.11796391,
992 273002.07088268,
993 271259.04646976,
994 269529.91064447,
995 267814.53081943,
996 266112.77588166,
997 264424.51617379,
998 262749.62347568,
999 261087.97098621,
1000 259439.43330537,
1001 257803.88641661,
1002 256181.20766940,
1003 254571.27576206,
1004 252973.97072484,
1005 251389.17390327,
1006 249816.76794164,
1007 248256.63676681,
1008 246708.66557223,
1009 245172.74080214,
1010 243648.75013606,
1011 242136.58247340,
1012 240636.12791839,
1013 239147.27776515,
1014 237669.92448300,
1015 236203.96170195,
1016 234749.28419840,
1017 233305.78788108,
1018 231873.36977708,
1019 230451.92801820,
1020 229041.36182739,
1021 227641.57150544,
1022 226252.45841778,
1023 224873.92498157,
1024 223505.87465285,
1025 222148.21191393,
1026 220800.84226099,
1027 219463.67219171,
1028 218136.60919325,
1029 216819.56173022,
1030 215512.43923297,
1031 214215.15208591,
1032 212927.61161606,
1033 211649.73008174,
1034 210381.42066140,
1035 209122.59744260,
1036 207873.17541119,
1037 206633.07044054,
1038 205402.19928097,
1039 204180.47954938,
1040 202967.82971887,
1041 201764.16910866,
1042 200569.41787401,
1043 199383.49699638,
1044 198206.32827363,
1045 197037.83431046,
1046 195877.93850882,
1047 194726.56505862,
1048 193583.63892843,
1049 192449.08585638,
1050 191322.83234115,
1051 190204.80563304,
1052 189094.93372528,
1053 187993.14534527,
1054 186899.36994615,
1055 185813.53769827,
1056 184735.57948091,
1057 183665.42687407,
1058 182603.01215037,
1059 181548.26826703,
1060 180501.12885795,
1061 179461.52822599,
1062 178429.40133520,
1063 177404.68380326,
1064 176387.31189398,
1065 175377.22250989,
1066 174374.35318497,
1067 173378.64207738,
1068 172390.02796239,
1069 171408.45022533,
1070 170433.84885467,
1071 169466.16443513,
1072 168505.33814099,
1073 167551.31172935,
1074 166604.02753355,
1075 165663.42845670,
1076 164729.45796522,
1077 163802.06008252,
1078 162881.17938270,
1079 161966.76098442,
1080 161058.75054476,
1081 160157.09425319,
1082 159261.73882564,
1083 158372.63149859,
1084 157489.72002329,
1085 156612.95266005,
1086 155742.27817251,
1087 154877.64582211,
1088 154019.00536257,
1089 153166.30703441,
1090 152319.50155957,
1091 151478.54013612,
1092 150643.37443299,
1093 149813.95658480,
1094 148990.23918670,
1095 148172.17528937,
1096 147359.71839398,
1097 146552.82244729,
1098 145751.44183673,
1099 144955.53138565,
1100 144165.04634850,
1101 143379.94240619,
1102 142600.17566142,
1103 141825.70263410,
1104 141056.48025685,
1105 140292.46587048,
1106 139533.61721964,
1107 138779.89244839,
1108 138031.25009594,
1109 137287.64909237,
1110 136549.04875443,
1111 135815.40878139,
1112 135086.68925090,
1113 134362.85061501,
1114 133643.85369608,
1115 132929.65968288,
1116 132220.23012665,
1117 131515.52693725,
1118 130815.51237932,
1119 130120.14906856,
1120 129429.39996793,
1121 128743.22838403,
1122 128061.59796343,
1123 127384.47268908,
1124 126711.81687677,
1125 126043.59517160,
1126 125379.77254452,
1127 124720.31428890,
1128 124065.18601715,
1129 123414.35365738,
1130 122767.78345007,
1131 122125.44194479,
1132 121487.29599703,
1133 120853.31276495,
1134 120223.45970624,
1135 119597.70457501,
1136 118976.01541870,
1137 118358.36057506,
1138 117744.70866907,
1139 117135.02861007,
1140 116529.28958873,
1141 115927.46107417,
1142 115329.51281112,
1143 114735.41481704,
1144 114145.13737933,
1145 113558.65105255,
1146 112975.92665569,
1147 112396.93526944,
1148 111821.64823355,
1149 111250.03714412,
1150 110682.07385104,
1151 110117.73045538,
1152 109556.97930681,
1153 108999.79300113,
1154 108446.14437769,
1155 107896.00651698,
1156 107349.35273818,
1157 106806.15659671,
1158 106266.39188188,
1159 105730.03261451,
1160 105197.05304458,
1161 104667.42764898,
1162 104141.13112915,
1163 103618.13840890,
1164 103098.42463211,
1165 102581.96516058,
1166 102068.73557183,
1167 101558.71165693,
1168 101051.86941838,
1169 100548.18506803,
1170 100047.63502494,
1171 99550.19591335,
1172 99055.84456065,
1173 98564.55799537,
1174 98076.31344514,
1175 97591.08833478,
1176 97108.86028431,
1177 96629.60710704,
1178 96153.30680767,
1179 95679.93758038,
1180 95209.47780699,
1181 94741.90605514,
1182 94277.20107639,
1183 93815.34180450,
1184 93356.30735360,
1185 92900.07701645,
1186 92446.63026267,
1187 91995.94673705,
1188 91548.00625781,
1189 91102.78881494,
1190 90660.27456852,
1191 90220.44384706,
1192 89783.27714590,
1193 89348.75512555,
1194 88916.85861013,
1195 88487.56858577,
1196 88060.86619906,
1197 87636.73275549,
1198 87215.14971794,
1199 ]
1200)
1203class TestPlanckLaw:
1204 """
1205 Define :func:`colour.colorimetry.blackbody.planck_law` definition unit
1206 tests methods.
1207 """
1209 def test_planck_law(self) -> None:
1210 """Test :func:`colour.colorimetry.blackbody.planck_law` definition."""
1212 wavelengths = 2 ** np.arange(0, 16, 1) * 1e-9
1213 for temperature, radiance in sorted(DATA_PLANCK_LAW.items()):
1214 np.testing.assert_allclose(
1215 planck_law(wavelengths, temperature),
1216 radiance,
1217 atol=TOLERANCE_ABSOLUTE_TESTS,
1218 )
1220 def test_n_dimensional_planck_law(self) -> None:
1221 """
1222 Test :func:`colour.colorimetry.blackbody.planck_law` definition
1223 n-dimensional arrays support.
1224 """
1226 wl = 500 * 1e-9
1227 p = planck_law(wl, 5500)
1229 wl = np.tile(wl, 6)
1230 p = np.tile(p, 6)
1231 np.testing.assert_allclose(
1232 planck_law(wl, 5500),
1233 p,
1234 atol=TOLERANCE_ABSOLUTE_TESTS,
1235 )
1237 wl = np.reshape(wl, (2, 3))
1238 # The "colour.colorimetry.planck_law" definition behaviour with
1239 # n-dimensional arrays is unusual.
1240 # p = np.np.reshape(p, (2, 3))
1241 np.testing.assert_allclose(
1242 planck_law(wl, 5500),
1243 p,
1244 atol=TOLERANCE_ABSOLUTE_TESTS,
1245 )
1247 wl = np.reshape(wl, (2, 3, 1))
1248 # The "colour.colorimetry.planck_law" definition behaviour with
1249 # n-dimensional arrays is unusual.
1250 # p = np.reshape(p, (2, 3, 1))
1251 np.testing.assert_allclose(
1252 planck_law(wl, 5500),
1253 p,
1254 atol=TOLERANCE_ABSOLUTE_TESTS,
1255 )
1257 # The "colour.colorimetry.planck_law" definition behaviour with
1258 # n-dimensional arrays is unusual.
1259 p = planck_law(500 * 1e-9, [5000, 5500, 6000])
1260 p = np.tile(p, (6, 1))
1261 np.testing.assert_allclose(
1262 planck_law(wl, [5000, 5500, 6000]),
1263 p,
1264 atol=TOLERANCE_ABSOLUTE_TESTS,
1265 )
1267 def test_raise_exception_planck_law(self) -> None:
1268 """
1269 Test :func:`colour.colorimetry.blackbody.planck_law` definition
1270 raised exception.
1271 """
1273 for wavelength in [-1.0, 0.0, -np.inf, np.nan]:
1274 pytest.raises(AssertionError, planck_law, wavelength, 5500)
1276 @ignore_numpy_errors
1277 def test_nan_planck_law(self) -> None:
1278 """
1279 Test :func:`colour.colorimetry.blackbody.planck_law` definition nan
1280 support.
1281 """
1283 # NOTE: Only testing infinity support as
1284 cases = [1.0, np.inf]
1285 cases = np.array(list(set(product(cases, repeat=3))))
1286 planck_law(cases, cases)
1289class TestSdBlackbody:
1290 """
1291 Define :func:`colour.colorimetry.blackbody.sd_blackbody` definition unit
1292 tests methods.
1293 """
1295 def test_sd_blackbody(self) -> None:
1296 """Test :func:`colour.colorimetry.blackbody.sd_blackbody` definition."""
1298 np.testing.assert_allclose(
1299 sd_blackbody(5000, SpectralShape(360, 830, 1)).values,
1300 DATA_BLACKBODY,
1301 atol=TOLERANCE_ABSOLUTE_TESTS,
1302 )
1305class TestRayleighJeansLaw:
1306 """
1307 Define :func:`colour.colorimetry.blackbody.rayleigh_jeans_law` definition unit
1308 tests methods.
1309 """
1311 def test_rayleigh_jeans_law(self) -> None:
1312 """
1313 Test :func:`colour.colorimetry.blackbody.rayleigh_jeans_law`
1314 definition.
1315 """
1317 wavelengths = 2 ** np.arange(0, 16, 1) * 1e-9
1318 for temperature, radiance in sorted(DATA_RAYLEIGH_JEANS_LAW.items()):
1319 np.testing.assert_allclose(
1320 rayleigh_jeans_law(wavelengths, temperature),
1321 radiance,
1322 atol=TOLERANCE_ABSOLUTE_TESTS,
1323 )
1325 def test_n_dimensional_rayleigh_jeans_law(self) -> None:
1326 """
1327 Test :func:`colour.colorimetry.blackbody.rayleigh_jeans_law` definition
1328 n-dimensional arrays support.
1329 """
1331 wl = 500 * 1e-9
1332 p = rayleigh_jeans_law(wl, 5500)
1334 wl = np.tile(wl, 6)
1335 p = np.tile(p, 6)
1336 np.testing.assert_allclose(
1337 rayleigh_jeans_law(wl, 5500),
1338 p,
1339 atol=TOLERANCE_ABSOLUTE_TESTS,
1340 )
1342 wl = np.reshape(wl, (2, 3))
1343 # The "colour.colorimetry.rayleigh_jeans_law" definition behaviour with
1344 # n-dimensional arrays is unusual.
1345 # p = np.np.reshape(p, (2, 3))
1346 np.testing.assert_allclose(
1347 rayleigh_jeans_law(wl, 5500),
1348 p,
1349 atol=TOLERANCE_ABSOLUTE_TESTS,
1350 )
1352 wl = np.reshape(wl, (2, 3, 1))
1353 # The "colour.colorimetry.rayleigh_jeans_law" definition behaviour with
1354 # n-dimensional arrays is unusual.
1355 # p = np.reshape(p, (2, 3, 1))
1356 np.testing.assert_allclose(
1357 rayleigh_jeans_law(wl, 5500),
1358 p,
1359 atol=TOLERANCE_ABSOLUTE_TESTS,
1360 )
1362 # The "colour.colorimetry.rayleigh_jeans_law" definition behaviour with
1363 # n-dimensional arrays is unusual.
1364 p = rayleigh_jeans_law(500 * 1e-9, [5000, 5500, 6000])
1365 p = np.tile(p, (6, 1))
1366 np.testing.assert_allclose(
1367 rayleigh_jeans_law(wl, [5000, 5500, 6000]),
1368 p,
1369 atol=TOLERANCE_ABSOLUTE_TESTS,
1370 )
1372 @ignore_numpy_errors
1373 def test_nan_rayleigh_jeans_law(self) -> None:
1374 """
1375 Test :func:`colour.colorimetry.blackbody.rayleigh_jeans_law` definition
1376 nan support.
1377 """
1379 cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan]
1380 cases = np.array(list(set(product(cases, repeat=3))))
1381 rayleigh_jeans_law(cases, cases)
1384class TestSdRayleighJeans:
1385 """
1386 Define :func:`colour.colorimetry.blackbody.sd_rayleigh_jeans` definition unit
1387 tests methods.
1388 """
1390 def test_sd_rayleigh_jeans(self) -> None:
1391 """
1392 Test :func:`colour.colorimetry.blackbody.sd_rayleigh_jeans`
1393 definition.
1394 """
1396 np.testing.assert_allclose(
1397 sd_rayleigh_jeans(5000, SpectralShape(360, 830, 1)).values,
1398 DATA_RAYLEIGH_JEANS,
1399 atol=TOLERANCE_ABSOLUTE_TESTS,
1400 )