| 1 |
from __future__ import annotations |
| 2 |
import sys |
| 3 |
from typing import TypedDict |
| 4 |
|
| 5 |
import pytest |
| 6 |
from _pytest.fixtures import SubRequest |
| 7 |
|
| 8 |
from DisplayCAL.cgats import CGATS, stable_sort_by_l |
| 9 |
from DisplayCAL.config import get_current_profile |
| 10 |
from DisplayCAL.dev.mocks import check_call |
| 11 |
from DisplayCAL.util_io import LineBufferedStream, Files |
| 12 |
from DisplayCAL.worker import FilteredStream |
| 13 |
|
| 14 |
|
| 15 |
def test_cgats_with_sample_data_1(data_files): |
| 16 |
"""Test CGATS class with some sample data""" |
| 17 |
cgats = CGATS(cgats=data_files["cgats0.txt"].absolute()) |
| 18 |
|
| 19 |
assert cgats[0]["DESCRIPTOR"] == b"Output Characterisation" |
| 20 |
assert ( |
| 21 |
cgats[0]["ORIGINATOR"] == b"Barbieri Gateway MAC 4.5.0, Speclib Version: 4.59" |
| 22 |
) |
| 23 |
assert ( |
| 24 |
cgats[0]["INSTRUMENTATION"] |
| 25 |
== b"Spectropad ver:6.26-6.10 R DOC,SN=B5101140,MN=B11J0026,1" |
| 26 |
) |
| 27 |
assert ( |
| 28 |
cgats[0]["BARBIERI_INFO_0"] |
| 29 |
== b"Mode=Reflection,Measurement Condition=M1,Aperture=6,IntegrationTime=7" |
| 30 |
) |
| 31 |
assert ( |
| 32 |
cgats[0]["BARBIERI_INFO_1"] |
| 33 |
== b"<Type>eChartJob</Type>, <ReferenceCheck>1</ReferenceCheck>, <JobName>IT8_" |
| 34 |
b"7-4-M1</JobName>, Spectro_xy_version=1, Spectro_xy_version=1,File_Format=" |
| 35 |
b"BARBIERI - Horizontal (default),Patches_X=24," |
| 36 |
) |
| 37 |
assert ( |
| 38 |
cgats[0]["BARBIERI_INFO_2"] |
| 39 |
== b"Patches_Y=17,Number_of_Patches=1617,Number_of_Pages=4,Target_Size_X=277,T" |
| 40 |
b"arget_Size_Y=206,MR,Illuminant=D50,Observer=10,Density=Status T,Save_Spec" |
| 41 |
b"tral=1,Save_Lab=1,Save_XYZ=1,Save_Density=1," |
| 42 |
) |
| 43 |
assert ( |
| 44 |
cgats[0]["BARBIERI_INFO_3"] |
| 45 |
== b"Save_CxF=255,Fast_Measuring_Mode=1,Use_AutoPositioning=1,Use_AutoRecognit" |
| 46 |
b"ion=0,Run_Profiler=0,Reference_File_Name=References/IT8_7-4 CMYK visual.r" |
| 47 |
b"ef,Quality_Control=0,Control_Reference_File=," |
| 48 |
) |
| 49 |
assert ( |
| 50 |
cgats[0]["BARBIERI_INFO_4"] |
| 51 |
== b"Control_Settings_File=,Profile_File_Name=,Target_Image_Preview=Previews/I" |
| 52 |
b"T8_7-4 CMYK visual.bmp,Spot_Measurement_Mode=0,Spot_Measurement=0,Display" |
| 53 |
b"_Values=0,Number_of_Measurements_per_Patch_y=1," |
| 54 |
) |
| 55 |
assert ( |
| 56 |
cgats[0]["BARBIERI_INFO_5"] |
| 57 |
== b"Distance_of_Measurements_per_Patch_y=10,Number_of_Measurements_per_Patch_" |
| 58 |
b"x=1,Distance_of_Measurements_per_Patch_x=10,Average_Method=1,Target_Heade" |
| 59 |
b"r_Size=20,AutoPositioning_Mode=0," |
| 60 |
) |
| 61 |
assert ( |
| 62 |
cgats[0]["BARBIERI_INFO_6"] |
| 63 |
== b"Continuous_Measurement_Mode=0,Save_Continuous_Measurement=0,Continuous_Me" |
| 64 |
b"asurement_Delay=0,CF_Option=1,Calibration_Frequency=0,Measuring_Aperture=" |
| 65 |
b"6,Slope_Factor=1.000,Job_protection=-1," |
| 66 |
) |
| 67 |
assert ( |
| 68 |
cgats[0]["BARBIERI_INFO_7"] |
| 69 |
== b"Measurement_Condition=M1,Translucency_Mode=0,Translucency_IntTime=1000,Sa" |
| 70 |
b"ve_Debug=0," |
| 71 |
) |
| 72 |
assert ( |
| 73 |
cgats[0]["MEASUREMENT_SOURCE"] |
| 74 |
== b"Illumination=D50 ObserverAngle=10degree WhiteBase=Abs Filter=No" |
| 75 |
) |
| 76 |
assert cgats[0]["ILLUMINANT"] == b"D50" |
| 77 |
assert cgats[0]["OBSERVER"] == b"10" |
| 78 |
assert ( |
| 79 |
cgats[0]["PRINT_CONDITIONS"] |
| 80 |
== b"No printer defined, No resolution defined, No ink defined, No paper defi" |
| 81 |
b"ned, No screening defined" |
| 82 |
) |
| 83 |
assert cgats[0]["NUMBER_OF_FIELDS"] == 52 |
| 84 |
assert isinstance(cgats[0]["DATA_FORMAT"], CGATS) |
| 85 |
|
| 86 |
keys = [ |
| 87 |
"CMYK_C", |
| 88 |
"CMYK_M", |
| 89 |
"CMYK_Y", |
| 90 |
"CMYK_K", |
| 91 |
"XYZ_X", |
| 92 |
"XYZ_Y", |
| 93 |
"XYZ_Z", |
| 94 |
"LAB_L", |
| 95 |
"LAB_A", |
| 96 |
"LAB_B", |
| 97 |
"SPECTRAL_380", |
| 98 |
"SPECTRAL_390", |
| 99 |
"SPECTRAL_400", |
| 100 |
"SPECTRAL_410", |
| 101 |
"SPECTRAL_420", |
| 102 |
"SPECTRAL_430", |
| 103 |
"SPECTRAL_440", |
| 104 |
"SPECTRAL_450", |
| 105 |
"SPECTRAL_460", |
| 106 |
"SPECTRAL_470", |
| 107 |
"SPECTRAL_480", |
| 108 |
"SPECTRAL_490", |
| 109 |
"SPECTRAL_500", |
| 110 |
"SPECTRAL_510", |
| 111 |
"SPECTRAL_520", |
| 112 |
"SPECTRAL_530", |
| 113 |
"SPECTRAL_540", |
| 114 |
"SPECTRAL_550", |
| 115 |
"SPECTRAL_560", |
| 116 |
"SPECTRAL_570", |
| 117 |
"SPECTRAL_580", |
| 118 |
"SPECTRAL_590", |
| 119 |
"SPECTRAL_600", |
| 120 |
"SPECTRAL_610", |
| 121 |
"SPECTRAL_620", |
| 122 |
"SPECTRAL_630", |
| 123 |
"SPECTRAL_640", |
| 124 |
"SPECTRAL_650", |
| 125 |
"SPECTRAL_660", |
| 126 |
"SPECTRAL_670", |
| 127 |
"SPECTRAL_680", |
| 128 |
"SPECTRAL_690", |
| 129 |
"SPECTRAL_700", |
| 130 |
"SPECTRAL_710", |
| 131 |
"SPECTRAL_720", |
| 132 |
"SPECTRAL_730", |
| 133 |
"SPECTRAL_740", |
| 134 |
"SPECTRAL_750", |
| 135 |
"SPECTRAL_760", |
| 136 |
"SPECTRAL_770", |
| 137 |
"SPECTRAL_780", |
| 138 |
] |
| 139 |
|
| 140 |
# TO GENERATE DATA |
| 141 |
# for i in range(cgats[0]['NUMBER_OF_SETS']): |
| 142 |
# values = ", ".join([str(x) for x in cgats[0]['DATA'][i].values()]) |
| 143 |
# print(f" {i}: [{values}],") |
| 144 |
|
| 145 |
values = { |
| 146 |
0: [1, 0.0, 100.0, 20.0, 0.0, 36.266, 25.588, 21.129, 57.644, 43.118, -0.587, 0.22703, 0.158521, 0.198916, 0.233576, 0.273344, 0.281545, 0.275103, 0.268394, 0.2608, 0.25577, 0.240171, 0.224809, 0.213421, 0.19068, 0.164624, 0.13483, 0.12763, 0.129758, 0.126645, 0.130081, 0.177509, 0.272117, 0.429915, 0.576974, 0.683854, 0.746946, 0.776108, 0.794132, 0.808238, 0.815922, 0.816633, 0.81732, 0.824127, 0.824325, 0.824718, 0.83017, 0.831191, 0.83384, 0.83384, 0.83384, 0.83384,], |
| 147 |
1: [2, 0.0, 85.0, 20.0, 0.0, 38.662, 28.299, 23.364, 60.157, 40.057, -0.601, 0.274704, 0.168645, 0.211179, 0.250617, 0.295082, 0.305504, 0.300246, 0.295093, 0.289493, 0.286288, 0.273133, 0.258376, 0.247178, 0.223566, 0.194819, 0.161104, 0.15285, 0.155392, 0.15176, 0.155079, 0.207079, 0.306173, 0.463505, 0.604229, 0.70203, 0.758555, 0.784057, 0.800388, 0.813682, 0.820672, 0.82168, 0.823508, 0.831216, 0.828949, 0.829395, 0.835401, 0.838929, 0.841753, 0.841753, 0.841753, 0.841753,], |
| 148 |
2: [3, 0.0, 70.0, 20.0, 0.0, 41.428, 31.681, 25.498, 63.078, 36.05, 0.536, 0.23112, 0.172207, 0.221313, 0.264632, 0.311902, 0.325723, 0.321866, 0.318828, 0.317081, 0.317275, 0.308422, 0.29693, 0.287657, 0.264574, 0.234287, 0.197652, 0.18771, 0.190387, 0.185953, 0.18918, 0.245586, 0.347588, 0.502066, 0.633031, 0.719415, 0.768109, 0.789507, 0.803672, 0.81579, 0.82215, 0.821852, 0.822152, 0.829452, 0.828198, 0.828533, 0.834266, 0.835057, 0.842139, 0.842139, 0.842139, 0.842139,], |
| 149 |
3: [4, 0.0, 55.0, 20.0, 0.0, 45.513, 36.729, 28.22, 67.074, 30.828, 2.754, 0.218564, 0.182374, 0.235281, 0.284068, 0.336732, 0.353667, 0.350615, 0.348262, 0.34972, 0.353871, 0.352098, 0.348736, 0.344867, 0.325774, 0.294521, 0.253248, 0.241124, 0.244228, 0.238822, 0.241937, 0.305103, 0.41057, 0.55931, 0.673954, 0.743283, 0.78138, 0.797305, 0.808648, 0.819299, 0.824913, 0.824598, 0.824403, 0.831217, 0.829997, 0.830138, 0.83639, 0.839101, 0.842862, 0.842862, 0.842862, 0.842862,], |
| 150 |
4: [5, 0.0, 40.0, 20.0, 0.0, 51.41, 44.315, 32.297, 72.439, 23.822, 5.54, 0.179846, 0.193834, 0.252103, 0.307782, 0.366728, 0.388613, 0.389364, 0.393721, 0.402893, 0.413308, 0.421461, 0.427721, 0.430264, 0.415827, 0.384044, 0.339534, 0.325223, 0.329108, 0.322862, 0.325749, 0.395277, 0.502877, 0.636999, 0.72377, 0.769836, 0.795023, 0.804875, 0.813572, 0.822762, 0.827487, 0.827436, 0.82682, 0.834021, 0.832718, 0.831247, 0.836521, 0.838606, 0.844015, 0.844015, 0.844015, 0.844015,], |
| 151 |
5: [6, 0.0, 30.0, 20.0, 0.0, 55.008, 49.174, 34.85, 75.559, 19.608, 7.148, 0.37016, 0.1983, 0.263395, 0.324705, 0.38756, 0.409243, 0.41288, 0.422213, 0.436569, 0.450381, 0.464107, 0.476682, 0.484204, 0.474681, 0.443393, 0.397553, 0.381964, 0.386302, 0.379386, 0.381907, 0.4544, 0.559581, 0.679708, 0.747761, 0.781105, 0.799988, 0.806783, 0.813788, 0.822796, 0.827119, 0.826215, 0.825702, 0.832313, 0.830966, 0.829475, 0.834936, 0.83735, 0.841089, 0.841089, 0.841089, 0.841089,], |
| 152 |
6: [7, 0.0, 20.0, 20.0, 0.0, 59.581, 55.607, 37.455, 79.39, 14.273, 10.086, 0.14007, 0.203257, 0.271542, 0.337358, 0.405274, 0.434317, 0.438829, 0.448776, 0.466504, 0.485766, 0.510213, 0.534794, 0.550742, 0.549314, 0.521919, 0.478624, 0.462862, 0.467584, 0.461588, 0.463786, 0.532937, 0.627132, 0.724591, 0.773093, 0.794568, 0.807647, 0.811793, 0.817288, 0.825166, 0.829055, 0.827766, 0.826826, 0.830837, 0.830135, 0.829046, 0.831644, 0.83029, 0.831417, 0.831417, 0.831417, 0.831417,], |
| 153 |
7: [8, 0.0, 10.0, 20.0, 0.0, 65.621, 64.674, 40.962, 84.316, 6.956, 13.904, 0.140803, 0.212377, 0.285737, 0.359451, 0.433695, 0.46689, 0.472929, 0.485189, 0.508602, 0.533595, 0.568508, 0.606079, 0.633761, 0.648128, 0.632218, 0.603189, 0.589922, 0.594206, 0.591529, 0.590701, 0.641412, 0.7052, 0.765422, 0.792178, 0.803407, 0.811992, 0.814125, 0.81891, 0.82649, 0.829661, 0.82829, 0.827179, 0.831384, 0.82984, 0.82956, 0.834308, 0.836347, 0.838753, 0.838753, 0.838753, 0.838753,], |
| 154 |
8: [9, 0.0, 0.0, 20.0, 0.0, 74.173, 77.878, 45.546, 90.724, -2.356, 19.228, 0.212895, 0.226007, 0.307983, 0.391678, 0.473875, 0.510948, 0.519092, 0.535516, 0.563649, 0.592841, 0.637903, 0.691631, 0.734935, 0.778418, 0.788965, 0.794365, 0.789319, 0.793541, 0.79698, 0.789356, 0.795117, 0.802413, 0.809776, 0.810017, 0.810176, 0.814511, 0.814652, 0.81876, 0.825596, 0.829271, 0.827477, 0.826685, 0.830895, 0.829069, 0.827596, 0.830788, 0.829694, 0.832583, 0.832583, 0.832583, 0.832583,], |
| 155 |
9: [10, 0.0, 100.0, 10.0, 0.0, 37.003, 26.118, 24.382, 58.149, 43.369, -5.953, 0.349415, 0.18234, 0.23642, 0.283576, 0.333148, 0.340254, 0.329331, 0.314389, 0.296822, 0.28406, 0.258049, 0.23534, 0.220215, 0.195589, 0.169089, 0.139374, 0.132424, 0.134512, 0.131322, 0.134707, 0.181502, 0.274578, 0.430365, 0.576222, 0.682475, 0.7454, 0.77477, 0.792532, 0.806671, 0.81492, 0.815652, 0.81674, 0.824637, 0.824021, 0.824834, 0.831626, 0.836586, 0.843208, 0.843208, 0.843208, 0.843208,], |
| 156 |
} |
| 157 |
|
| 158 |
for i in values: |
| 159 |
for j, k in enumerate(keys): |
| 160 |
assert cgats[0]["DATA"][i][k] == values[i][j + 1] |
| 161 |
|
| 162 |
|
| 163 |
def test_cgats_with_sample_data_1A(data_files): |
| 164 |
"""Test CGATS class with some sample data""" |
| 165 |
cgats = CGATS(cgats=data_files["cgats0.txt"].absolute()) |
| 166 |
|
| 167 |
assert cgats[0]["DESCRIPTOR"] == b"Output Characterisation" |
| 168 |
assert ( |
| 169 |
cgats[0]["ORIGINATOR"] == b"Barbieri Gateway MAC 4.5.0, Speclib Version: 4.59" |
| 170 |
) |
| 171 |
assert ( |
| 172 |
cgats[0]["INSTRUMENTATION"] |
| 173 |
== b"Spectropad ver:6.26-6.10 R DOC,SN=B5101140,MN=B11J0026,1" |
| 174 |
) |
| 175 |
assert ( |
| 176 |
cgats[0]["BARBIERI_INFO_0"] |
| 177 |
== b"Mode=Reflection,Measurement Condition=M1,Aperture=6,IntegrationTime=7" |
| 178 |
) |
| 179 |
assert ( |
| 180 |
cgats[0]["BARBIERI_INFO_1"] |
| 181 |
== b"<Type>eChartJob</Type>, <ReferenceCheck>1</ReferenceCheck>, <JobName>IT8_" |
| 182 |
b"7-4-M1</JobName>, Spectro_xy_version=1, Spectro_xy_version=1,File_Format=" |
| 183 |
b"BARBIERI - Horizontal (default),Patches_X=24," |
| 184 |
) |
| 185 |
assert ( |
| 186 |
cgats[0]["BARBIERI_INFO_2"] |
| 187 |
== b"Patches_Y=17,Number_of_Patches=1617,Number_of_Pages=4,Target_Size_X=277,T" |
| 188 |
b"arget_Size_Y=206,MR,Illuminant=D50,Observer=10,Density=Status T,Save_Spec" |
| 189 |
b"tral=1,Save_Lab=1,Save_XYZ=1,Save_Density=1," |
| 190 |
) |
| 191 |
assert ( |
| 192 |
cgats[0]["BARBIERI_INFO_3"] |
| 193 |
== b"Save_CxF=255,Fast_Measuring_Mode=1,Use_AutoPositioning=1,Use_AutoRecognit" |
| 194 |
b"ion=0,Run_Profiler=0,Reference_File_Name=References/IT8_7-4 CMYK visual.r" |
| 195 |
b"ef,Quality_Control=0,Control_Reference_File=," |
| 196 |
) |
| 197 |
assert ( |
| 198 |
cgats[0]["BARBIERI_INFO_4"] |
| 199 |
== b"Control_Settings_File=,Profile_File_Name=,Target_Image_Preview=Previews/I" |
| 200 |
b"T8_7-4 CMYK visual.bmp,Spot_Measurement_Mode=0,Spot_Measurement=0,Display" |
| 201 |
b"_Values=0,Number_of_Measurements_per_Patch_y=1," |
| 202 |
) |
| 203 |
assert ( |
| 204 |
cgats[0]["BARBIERI_INFO_5"] |
| 205 |
== b"Distance_of_Measurements_per_Patch_y=10,Number_of_Measurements_per_Patch_" |
| 206 |
b"x=1,Distance_of_Measurements_per_Patch_x=10,Average_Method=1,Target_Heade" |
| 207 |
b"r_Size=20,AutoPositioning_Mode=0," |
| 208 |
) |
| 209 |
assert ( |
| 210 |
cgats[0]["BARBIERI_INFO_6"] |
| 211 |
== b"Continuous_Measurement_Mode=0,Save_Continuous_Measurement=0,Continuous_Me" |
| 212 |
b"asurement_Delay=0,CF_Option=1,Calibration_Frequency=0,Measuring_Aperture=" |
| 213 |
b"6,Slope_Factor=1.000,Job_protection=-1," |
| 214 |
) |
| 215 |
assert ( |
| 216 |
cgats[0]["BARBIERI_INFO_7"] |
| 217 |
== b"Measurement_Condition=M1,Translucency_Mode=0,Translucency_IntTime=1000,Sa" |
| 218 |
b"ve_Debug=0," |
| 219 |
) |
| 220 |
assert ( |
| 221 |
cgats[0]["MEASUREMENT_SOURCE"] |
| 222 |
== b"Illumination=D50 ObserverAngle=10degree WhiteBase=Abs Filter=No" |
| 223 |
) |
| 224 |
assert cgats[0]["ILLUMINANT"] == b"D50" |
| 225 |
assert cgats[0]["OBSERVER"] == b"10" |
| 226 |
assert ( |
| 227 |
cgats[0]["PRINT_CONDITIONS"] |
| 228 |
== b"No printer defined, No resolution defined, No ink defined, No paper defi" |
| 229 |
b"ned, No screening defined" |
| 230 |
) |
| 231 |
assert cgats[0]["NUMBER_OF_FIELDS"] == 52 |
| 232 |
assert isinstance(cgats[0]["DATA_FORMAT"], CGATS) |
| 233 |
|
| 234 |
keys = ["CMYK_C", "CMYK_M", "CMYK_Y", "CMYK_K", "XYZ_X", "XYZ_Y", "XYZ_Z", "LAB_L", "LAB_A", "LAB_B", "SPECTRAL_380", "SPECTRAL_390", "SPECTRAL_400", "SPECTRAL_410", "SPECTRAL_420", "SPECTRAL_430", "SPECTRAL_440", "SPECTRAL_450", "SPECTRAL_460", "SPECTRAL_470", "SPECTRAL_480", "SPECTRAL_490", "SPECTRAL_500", "SPECTRAL_510", "SPECTRAL_520", "SPECTRAL_530", "SPECTRAL_540", "SPECTRAL_550", "SPECTRAL_560", "SPECTRAL_570", "SPECTRAL_580", "SPECTRAL_590", "SPECTRAL_600", "SPECTRAL_610", "SPECTRAL_620", "SPECTRAL_630", "SPECTRAL_640", "SPECTRAL_650", "SPECTRAL_660", "SPECTRAL_670", "SPECTRAL_680", "SPECTRAL_690", "SPECTRAL_700", "SPECTRAL_710", "SPECTRAL_720", "SPECTRAL_730", "SPECTRAL_740", "SPECTRAL_750", "SPECTRAL_760", "SPECTRAL_770", "SPECTRAL_780",] |
| 235 |
|
| 236 |
# TO GENERATE DATA |
| 237 |
# for i in range(cgats[0]['NUMBER_OF_SETS']): |
| 238 |
# values = ", ".join([str(x) for x in cgats[0]['DATA'][i].values()]) |
| 239 |
# print(f" {i}: [{values}],") |
| 240 |
|
| 241 |
values = { |
| 242 |
0: [ 1, 0.0, 100.0, 20.0, 0.0, 36.266, 25.588, 21.129, 57.644, 43.118, -0.587, 0.22703, 0.158521, 0.198916, 0.233576, 0.273344, 0.281545, 0.275103, 0.268394, 0.2608, 0.25577, 0.240171, 0.224809, 0.213421, 0.19068, 0.164624, 0.13483, 0.12763, 0.129758, 0.126645, 0.130081, 0.177509, 0.272117, 0.429915, 0.576974, 0.683854, 0.746946, 0.776108, 0.794132, 0.808238, 0.815922, 0.816633, 0.81732, 0.824127, 0.824325, 0.824718, 0.83017, 0.831191, 0.83384, 0.83384, 0.83384, 0.83384,], |
| 243 |
1: [ 2, 0.0, 85.0, 20.0, 0.0, 38.662, 28.299, 23.364, 60.157, 40.057, -0.601, 0.274704, 0.168645, 0.211179, 0.250617, 0.295082, 0.305504, 0.300246, 0.295093, 0.289493, 0.286288, 0.273133, 0.258376, 0.247178, 0.223566, 0.194819, 0.161104, 0.15285, 0.155392, 0.15176, 0.155079, 0.207079, 0.306173, 0.463505, 0.604229, 0.70203, 0.758555, 0.784057, 0.800388, 0.813682, 0.820672, 0.82168, 0.823508, 0.831216, 0.828949, 0.829395, 0.835401, 0.838929, 0.841753, 0.841753, 0.841753, 0.841753,], |
| 244 |
} |
| 245 |
|
| 246 |
for i in values: |
| 247 |
for j, k in enumerate(keys): |
| 248 |
assert cgats[0]["DATA"][i][k] == values[i][j + 1] |
| 249 |
|
| 250 |
|
| 251 |
def test_cgats_with_sample_data_2(data_files): |
| 252 |
"""Test ``DisplayCAL.cgats.CGATS`` class with some sample data""" |
| 253 |
cgats = CGATS(cgats=data_files["ccxx.ti1"].absolute()) |
| 254 |
|
| 255 |
assert ( |
| 256 |
cgats[0]["DESCRIPTOR"] |
| 257 |
== b"Argyll Calibration Target chart information 1 for creating .ti3 for ccxxmake" |
| 258 |
) |
| 259 |
assert cgats[0]["ORIGINATOR"] == b"Argyll targen" |
| 260 |
assert cgats[0]["KEYWORDS"] == {0: b"APPROX_WHITE_POINT", 1: b"COLOR_REP"} |
| 261 |
assert cgats[0]["APPROX_WHITE_POINT"] == b"95.045781 100.000003 108.905751" |
| 262 |
assert cgats[0]["COLOR_REP"] == b"RGB" |
| 263 |
assert cgats[0]["NUMBER_OF_FIELDS"] == 7 |
| 264 |
assert cgats[0]["NUMBER_OF_SETS"] == 4 |
| 265 |
|
| 266 |
assert isinstance(cgats[0]["DATA_FORMAT"], CGATS) |
| 267 |
assert isinstance(cgats[0]["DATA"], CGATS) |
| 268 |
|
| 269 |
keys = ["SAMPLE_ID", "RGB_R", "RGB_G", "RGB_B", "XYZ_X", "XYZ_Y", "XYZ_Z"] |
| 270 |
|
| 271 |
# TO GENERATE DATA |
| 272 |
# for i in range(cgats[0]['NUMBER_OF_SETS']): |
| 273 |
# values = ", ".join([str(x) for x in cgats[0]['DATA'][i].values()]) |
| 274 |
# print(f" {i}: [{values}],") |
| 275 |
|
| 276 |
values = { |
| 277 |
0: [1, 100.00, 100.00, 100.00, 95.046, 100.00, 108.91], |
| 278 |
1: [2, 100.00, 0.0000, 0.0000, 41.238, 21.260, 1.9306], |
| 279 |
2: [3, 0.0000, 100.00, 0.0000, 35.757, 71.520, 11.921], |
| 280 |
3: [4, 0.0000, 0.0000, 100.00, 18.050, 7.2205, 95.055], |
| 281 |
} |
| 282 |
|
| 283 |
for i in values: |
| 284 |
for j, k in enumerate(keys): |
| 285 |
assert cgats[0]["DATA"][i][k] == values[i][j] |
| 286 |
|
| 287 |
|
| 288 |
def test_cgats_with_sample_targ_data(data_files): |
| 289 |
"""Test ``DisplayCAL.cgats.CGATS`` class with data coming from the ``Text`` class""" |
| 290 |
from DisplayCAL.icc_profile import Text |
| 291 |
|
| 292 |
with open(data_files["ccxx.ti1"].absolute(), "rb") as f: |
| 293 |
targ_data = f.read() |
| 294 |
targ_tag = Text(targ_data) |
| 295 |
targ_tag.tagSignature = "targ" |
| 296 |
targ_tag.tagData = targ_data |
| 297 |
cgats = CGATS(cgats=targ_tag) |
| 298 |
|
| 299 |
assert isinstance(cgats, CGATS) |
| 300 |
assert ( |
| 301 |
cgats[0]["DESCRIPTOR"] |
| 302 |
== b"Argyll Calibration Target chart information 1 for creating .ti3 for ccxxmake" |
| 303 |
) |
| 304 |
assert cgats[0]["ORIGINATOR"] == b"Argyll targen" |
| 305 |
assert cgats[0]["KEYWORDS"] == {0: b"APPROX_WHITE_POINT", 1: b"COLOR_REP"} |
| 306 |
assert cgats[0]["APPROX_WHITE_POINT"] == b"95.045781 100.000003 108.905751" |
| 307 |
assert cgats[0]["COLOR_REP"] == b"RGB" |
| 308 |
assert cgats[0]["NUMBER_OF_FIELDS"] == 7 |
| 309 |
assert cgats[0]["NUMBER_OF_SETS"] == 4 |
| 310 |
|
| 311 |
assert isinstance(cgats[0]["DATA_FORMAT"], CGATS) |
| 312 |
assert isinstance(cgats[0]["DATA"], CGATS) |
| 313 |
|
| 314 |
keys = ["SAMPLE_ID", "RGB_R", "RGB_G", "RGB_B", "XYZ_X", "XYZ_Y", "XYZ_Z"] |
| 315 |
|
| 316 |
# TO GENERATE DATA |
| 317 |
# for i in range(cgats[0]['NUMBER_OF_SETS']): |
| 318 |
# values = ", ".join([str(x) for x in cgats[0]['DATA'][i].values()]) |
| 319 |
# print(f" {i}: [{values}],") |
| 320 |
|
| 321 |
values = { |
| 322 |
0: [1, 100.00, 100.00, 100.00, 95.046, 100.00, 108.91], |
| 323 |
1: [2, 100.00, 0.0000, 0.0000, 41.238, 21.260, 1.9306], |
| 324 |
2: [3, 0.0000, 100.00, 0.0000, 35.757, 71.520, 11.921], |
| 325 |
3: [4, 0.0000, 0.0000, 100.00, 18.050, 7.2205, 95.055], |
| 326 |
} |
| 327 |
|
| 328 |
for i in values: |
| 329 |
for j, k in enumerate(keys): |
| 330 |
assert cgats[0]["DATA"][i][k] == values[i][j] |
| 331 |
|
| 332 |
|
| 333 |
def test_cgats_with_sample_ti3_data(data_files): |
| 334 |
"""Test ``DisplayCAL.cgats.CGATS`` class with data coming from the ti3 file""" |
| 335 |
cgats = CGATS(cgats=data_files["0_16.ti3"].absolute()) |
| 336 |
|
| 337 |
assert isinstance(cgats, CGATS) |
| 338 |
assert cgats[0]["DESCRIPTOR"] == b"Argyll Calibration Target chart information 3" |
| 339 |
assert cgats[0]["ORIGINATOR"] == b"Argyll dispread" |
| 340 |
assert cgats[0]["DEVICE_CLASS"] == b"DISPLAY" |
| 341 |
assert cgats[0]["COLOR_REP"] == b"RGB_XYZ" |
| 342 |
assert cgats[0]["TARGET_INSTRUMENT"] == b"X-Rite i1 DisplayPro, ColorMunki Display" |
| 343 |
assert cgats[0]["DISPLAY_TYPE_REFRESH"] == b"NO" |
| 344 |
assert cgats[0]["DISPLAY_TYPE_BASE_ID"] == 1 |
| 345 |
assert cgats[0]["INSTRUMENT_TYPE_SPECTRAL"] == b"NO" |
| 346 |
assert cgats[0]["LUMINANCE_XYZ_CDM2"] == b"115.999513 125.380126 138.006230" |
| 347 |
assert cgats[0]["NORMALIZED_TO_Y_100"] == b"YES" |
| 348 |
assert cgats[0]["VIDEO_LUT_CALIBRATION_POSSIBLE"] == b"YES" |
| 349 |
assert cgats[0]["NUMBER_OF_FIELDS"] == 7 |
| 350 |
assert isinstance(cgats[0]["DATA_FORMAT"], CGATS) |
| 351 |
assert isinstance(cgats[0]["DATA"], CGATS) |
| 352 |
|
| 353 |
keys = ["SAMPLE_ID", "RGB_R", "RGB_G", "RGB_B", "XYZ_X", "XYZ_Y", "XYZ_Z"] |
| 354 |
|
| 355 |
# TO GENERATE DATA |
| 356 |
# for i in range(cgats[0]['NUMBER_OF_SETS']): |
| 357 |
# values = ", ".join([str(x) for x in cgats[0]['DATA'][i].values()]) |
| 358 |
# print(f" {i}: [{values}],") |
| 359 |
|
| 360 |
values = { |
| 361 |
0: [1, 100.00, 100.00, 100.00, 92.51826, 100.00, 110.0703], |
| 362 |
1: [2, 0.0000, 0.0000, 0.0000, 0.119951, 0.129559, 0.239291], |
| 363 |
2: [3, 6.25, 6.25, 6.25, 0.321875, 0.348479, 0.479568], |
| 364 |
} |
| 365 |
|
| 366 |
for i in values: |
| 367 |
for j, k in enumerate(keys): |
| 368 |
assert cgats[0]["DATA"][i][k] == values[i][j] |
| 369 |
|
| 370 |
|
| 371 |
def test_cgats_from_ti3_back_to_bytes(data_files): |
| 372 |
"""Test ``DisplayCAL.cgats.CGATS`` class with data coming from the ti3 file and |
| 373 |
then converted back to bytes |
| 374 |
""" |
| 375 |
path = data_files["0_16_proper.ti3"].absolute() |
| 376 |
with open(path, "rb") as f: |
| 377 |
raw_data = f.read() |
| 378 |
|
| 379 |
# fix the line endings for Windows |
| 380 |
if sys.platform == "win32": |
| 381 |
raw_data = raw_data.replace(b"\r\n", b"\n") |
| 382 |
cgats = CGATS(cgats=path) |
| 383 |
assert bytes(cgats) == raw_data |
| 384 |
|
| 385 |
|
| 386 |
def test_cgats_get_colorants_method(data_files): |
| 387 |
"""Test ``DisplayCAL.cgats.CGATS`` get_colorants() method.""" |
| 388 |
path = data_files["default.ti3"].absolute() |
| 389 |
cgats = CGATS(cgats=path) |
| 390 |
result = cgats.get_colorants() |
| 391 |
expected_result = [ |
| 392 |
{"RGB_B": 0.0, "RGB_G": 0.0, "RGB_R": 100.0, "SAMPLE_ID": 9, "XYZ_X": 41.83, "XYZ_Y": 22.052, "XYZ_Z": 2.9132,}, |
| 393 |
{"RGB_B": 0.0, "RGB_G": 100.0, "RGB_R": 0.0, "SAMPLE_ID": 100, "XYZ_X": 36.405, "XYZ_Y": 71.801, "XYZ_Z": 12.802,}, |
| 394 |
{"RGB_B": 100.0, "RGB_G": 0.0, "RGB_R": 0.0, "SAMPLE_ID": 156, "XYZ_X": 18.871, "XYZ_Y": 8.1473, "XYZ_Z": 95.129,}, |
| 395 |
] |
| 396 |
assert result == expected_result |
| 397 |
|
| 398 |
|
| 399 |
def test_cgats_get_descriptor_method(data_files): |
| 400 |
"""Test ``DisplayCAL.cgats.CGATS`` get_descriptor() method.""" |
| 401 |
path = data_files["default.ti3"].absolute() |
| 402 |
cgats = CGATS(cgats=path) |
| 403 |
result = cgats.get_descriptor() |
| 404 |
expected_result = b"Argyll Calibration Target chart information 3" |
| 405 |
assert result == expected_result |
| 406 |
|
| 407 |
|
| 408 |
def test_cgats_get_method(data_files): |
| 409 |
"""Test ``DisplayCAL.cgats.CGATS`` get() method.""" |
| 410 |
path = data_files["default.ti3"].absolute() |
| 411 |
cgats = CGATS(cgats=path) |
| 412 |
result = cgats.get(0)["DESCRIPTOR"] |
| 413 |
expected_result = b"Argyll Calibration Target chart information 3" |
| 414 |
assert result == expected_result |
| 415 |
|
| 416 |
|
| 417 |
def test_cgats_getitem_method_1(data_files): |
| 418 |
"""Test ``DisplayCAL.cgats.CGATS`` get() method.""" |
| 419 |
path = data_files["default.ti3"].absolute() |
| 420 |
cgats = CGATS(cgats=path) |
| 421 |
result = cgats[0]["DESCRIPTOR"] |
| 422 |
expected_result = b"Argyll Calibration Target chart information 3" |
| 423 |
assert result == expected_result |
| 424 |
|
| 425 |
|
| 426 |
def test_cgats_getitem_method_2(data_files): |
| 427 |
"""Test ``DisplayCAL.cgats.CGATS`` get() method.""" |
| 428 |
path = data_files["default.ti3"].absolute() |
| 429 |
cgats = CGATS(cgats=path) |
| 430 |
result = cgats[-1]["DESCRIPTOR"] |
| 431 |
expected_result = b"Argyll Device Calibration State" |
| 432 |
assert result == expected_result |
| 433 |
|
| 434 |
|
| 435 |
def test_cgats_fix_zero_measurements_1(data_files): |
| 436 |
"""Test DisplayCAL.cgats.CGATS.fix_zero_measurements() method.""" |
| 437 |
path = data_files["0_16.ti1"].absolute() |
| 438 |
cgats = CGATS(cgats=path) |
| 439 |
cgats.fix_zero_measurements() |
| 440 |
|
| 441 |
|
| 442 |
def test_cgats_fix_zero_measurements_2(data_files): |
| 443 |
"""Test DisplayCAL.cgats.CGATS.fix_zero_measurements() method.""" |
| 444 |
path = data_files["0_16.ti3"].absolute() |
| 445 |
cgats = CGATS(cgats=path) |
| 446 |
cgats.fix_zero_measurements() |
| 447 |
|
| 448 |
|
| 449 |
def test_cgats_fix_zero_measurements_3(data_files): |
| 450 |
"""Test DisplayCAL.cgats.CGATS.fix_zero_measurements() method.""" |
| 451 |
path = data_files["Monitor.cal"].absolute() |
| 452 |
cgats = CGATS(cgats=path) |
| 453 |
cgats.fix_zero_measurements() |
| 454 |
|
| 455 |
|
| 456 |
def test_cgats_fix_zero_measurements_4(data_files): |
| 457 |
"""Test DisplayCAL.cgats.CGATS.fix_zero_measurements() method.""" |
| 458 |
path = data_files["Monitor.ti1"].absolute() |
| 459 |
cgats = CGATS(cgats=path) |
| 460 |
cgats.fix_zero_measurements() |
| 461 |
|
| 462 |
|
| 463 |
def test_cgats_fix_zero_measurements_5(data_files): |
| 464 |
"""Test DisplayCAL.cgats.CGATS.fix_zero_measurements() method.""" |
| 465 |
path = data_files["Monitor.ti3"].absolute() |
| 466 |
cgats = CGATS(cgats=path) |
| 467 |
cgats.fix_zero_measurements() |
| 468 |
|
| 469 |
|
| 470 |
def test_cgats_fix_zero_measurements_6(data_files): |
| 471 |
"""Test DisplayCAL.cgats.CGATS.fix_zero_measurements() method.""" |
| 472 |
path = data_files["Monitor_ZeroValues.ti3"].absolute() |
| 473 |
cgats = CGATS(cgats=path) |
| 474 |
cgats.fix_zero_measurements() |
| 475 |
|
| 476 |
|
| 477 |
def test_cgats_fix_zero_measurements_7(data_files): |
| 478 |
"""Test DisplayCAL.cgats.CGATS.fix_zero_measurements() method.""" |
| 479 |
path = data_files["Monitor_AllBlack.ti3"].absolute() |
| 480 |
cgats = CGATS(cgats=path) |
| 481 |
cgats.fix_zero_measurements() |
| 482 |
|
| 483 |
|
| 484 |
def test_cgats_fix_zero_measurements_8(data_files): |
| 485 |
"""Test DisplayCAL.cgats.CGATS.fix_zero_measurements() method. For #68.""" |
| 486 |
from DisplayCAL.worker import Worker |
| 487 |
|
| 488 |
worker = Worker() |
| 489 |
worker.get_logfiles(False) |
| 490 |
|
| 491 |
path = data_files["Monitor_AllBlack.ti3"].absolute() |
| 492 |
cgats = CGATS(cgats=path) |
| 493 |
cgats.fix_zero_measurements(logfile=worker.get_logfiles(False)) |
| 494 |
|
| 495 |
|
| 496 |
def test_export_3d_1(data_files): |
| 497 |
"""Test DisplayCAL.cgats.CGATS.export_3d() method.""" |
| 498 |
import pathlib |
| 499 |
import tempfile |
| 500 |
|
| 501 |
export_path = pathlib.Path(tempfile.gettempdir()) / "ccxx_RGB.x3d.html" |
| 502 |
path = data_files["Monitor.ti1"].absolute() |
| 503 |
cgats = CGATS(cgats=path) |
| 504 |
cgats.export_3d( |
| 505 |
str(export_path.absolute()), |
| 506 |
colorspace="RGB", |
| 507 |
rgb_black_offset=40, |
| 508 |
normalize_rgb_white=False, |
| 509 |
compress=False, |
| 510 |
file_format="HTML", |
| 511 |
) |
| 512 |
|
| 513 |
|
| 514 |
@pytest.mark.parametrize( |
| 515 |
"function,result", |
| 516 |
[ |
| 517 |
( |
| 518 |
"sort_rgb_gray_to_top", |
| 519 |
[ |
| 520 |
[100.0, 100.0, 100.0, 100.0, 100.0, 100.0], |
| 521 |
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0], |
| 522 |
[50.0, 50.0, 50.0, 100.0, 100.0, 100.0], |
| 523 |
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0], |
| 524 |
[80.0, 80.0, 80.0, 100.0, 100.0, 100.0], |
| 525 |
[50.0, 100.0, 100.0, 100.0, 100.0, 100.0], |
| 526 |
[50.0, 0.0, 0.0, 0.0, 0.0, 0.0], |
| 527 |
[25.0, 50.0, 25.0, 0.0, 0.0, 0.0], |
| 528 |
[50.0, 50.0, 25.0, 0.0, 0.0, 0.0], |
| 529 |
[50.0, 50.0, 100.0, 0.0, 0.0, 0.0], |
| 530 |
], |
| 531 |
), |
| 532 |
( |
| 533 |
"sort_rgb_white_to_top", |
| 534 |
[ |
| 535 |
[100.0, 100.0, 100.0, 100.0, 100.0, 100.0], |
| 536 |
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0], |
| 537 |
[50.0, 50.0, 50.0, 100.0, 100.0, 100.0], |
| 538 |
[50.0, 100.0, 100.0, 100.0, 100.0, 100.0], |
| 539 |
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0], |
| 540 |
[50.0, 0.0, 0.0, 0.0, 0.0, 0.0], |
| 541 |
[80.0, 80.0, 80.0, 100.0, 100.0, 100.0], |
| 542 |
[25.0, 50.0, 25.0, 0.0, 0.0, 0.0], |
| 543 |
[50.0, 50.0, 25.0, 0.0, 0.0, 0.0], |
| 544 |
[50.0, 50.0, 100.0, 0.0, 0.0, 0.0], |
| 545 |
], |
| 546 |
), |
| 547 |
( |
| 548 |
"sort_by_hsi", |
| 549 |
[ |
| 550 |
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0], |
| 551 |
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0], |
| 552 |
[50.0, 50.0, 50.0, 100.0, 100.0, 100.0], |
| 553 |
[80.0, 80.0, 80.0, 100.0, 100.0, 100.0], |
| 554 |
[100.0, 100.0, 100.0, 100.0, 100.0, 100.0], |
| 555 |
[50.0, 0.0, 0.0, 0.0, 0.0, 0.0], |
| 556 |
[50.0, 50.0, 25.0, 0.0, 0.0, 0.0], |
| 557 |
[25.0, 50.0, 25.0, 0.0, 0.0, 0.0], |
| 558 |
[50.0, 100.0, 100.0, 100.0, 100.0, 100.0], |
| 559 |
[50.0, 50.0, 100.0, 0.0, 0.0, 0.0], |
| 560 |
], |
| 561 |
), |
| 562 |
( |
| 563 |
"sort_by_hsl", |
| 564 |
[ |
| 565 |
[50.0, 0.0, 0.0, 0.0, 0.0, 0.0], |
| 566 |
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0], |
| 567 |
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0], |
| 568 |
[50.0, 50.0, 50.0, 100.0, 100.0, 100.0], |
| 569 |
[80.0, 80.0, 80.0, 100.0, 100.0, 100.0], |
| 570 |
[100.0, 100.0, 100.0, 100.0, 100.0, 100.0], |
| 571 |
[50.0, 50.0, 25.0, 0.0, 0.0, 0.0], |
| 572 |
[25.0, 50.0, 25.0, 0.0, 0.0, 0.0], |
| 573 |
[50.0, 100.0, 100.0, 100.0, 100.0, 100.0], |
| 574 |
[50.0, 50.0, 100.0, 0.0, 0.0, 0.0], |
| 575 |
], |
| 576 |
), |
| 577 |
( |
| 578 |
"sort_by_hsv", |
| 579 |
[ |
| 580 |
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0], |
| 581 |
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0], |
| 582 |
[50.0, 50.0, 50.0, 100.0, 100.0, 100.0], |
| 583 |
[80.0, 80.0, 80.0, 100.0, 100.0, 100.0], |
| 584 |
[100.0, 100.0, 100.0, 100.0, 100.0, 100.0], |
| 585 |
[50.0, 0.0, 0.0, 0.0, 0.0, 0.0], |
| 586 |
[50.0, 50.0, 25.0, 0.0, 0.0, 0.0], |
| 587 |
[25.0, 50.0, 25.0, 0.0, 0.0, 0.0], |
| 588 |
[50.0, 100.0, 100.0, 100.0, 100.0, 100.0], |
| 589 |
[50.0, 50.0, 100.0, 0.0, 0.0, 0.0], |
| 590 |
], |
| 591 |
), |
| 592 |
( |
| 593 |
"sort_by_l", |
| 594 |
[ |
| 595 |
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0], |
| 596 |
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0], |
| 597 |
[50.0, 0.0, 0.0, 0.0, 0.0, 0.0], |
| 598 |
[25.0, 50.0, 25.0, 0.0, 0.0, 0.0], |
| 599 |
[50.0, 50.0, 25.0, 0.0, 0.0, 0.0], |
| 600 |
[50.0, 50.0, 100.0, 0.0, 0.0, 0.0], |
| 601 |
[100.0, 100.0, 100.0, 100.0, 100.0, 100.0], |
| 602 |
[50.0, 50.0, 50.0, 100.0, 100.0, 100.0], |
| 603 |
[50.0, 100.0, 100.0, 100.0, 100.0, 100.0], |
| 604 |
[80.0, 80.0, 80.0, 100.0, 100.0, 100.0], |
| 605 |
], |
| 606 |
), |
| 607 |
( |
| 608 |
"sort_by_rgb", |
| 609 |
[ |
| 610 |
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0], |
| 611 |
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0], |
| 612 |
[25.0, 50.0, 25.0, 0.0, 0.0, 0.0], |
| 613 |
[50.0, 0.0, 0.0, 0.0, 0.0, 0.0], |
| 614 |
[50.0, 50.0, 25.0, 0.0, 0.0, 0.0], |
| 615 |
[50.0, 50.0, 50.0, 100.0, 100.0, 100.0], |
| 616 |
[50.0, 50.0, 100.0, 0.0, 0.0, 0.0], |
| 617 |
[50.0, 100.0, 100.0, 100.0, 100.0, 100.0], |
| 618 |
[80.0, 80.0, 80.0, 100.0, 100.0, 100.0], |
| 619 |
[100.0, 100.0, 100.0, 100.0, 100.0, 100.0], |
| 620 |
], |
| 621 |
), |
| 622 |
( |
| 623 |
"sort_by_bgr", |
| 624 |
[ |
| 625 |
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0], |
| 626 |
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0], |
| 627 |
[50.0, 0.0, 0.0, 0.0, 0.0, 0.0], |
| 628 |
[25.0, 50.0, 25.0, 0.0, 0.0, 0.0], |
| 629 |
[50.0, 50.0, 25.0, 0.0, 0.0, 0.0], |
| 630 |
[50.0, 50.0, 50.0, 100.0, 100.0, 100.0], |
| 631 |
[80.0, 80.0, 80.0, 100.0, 100.0, 100.0], |
| 632 |
[50.0, 50.0, 100.0, 0.0, 0.0, 0.0], |
| 633 |
[50.0, 100.0, 100.0, 100.0, 100.0, 100.0], |
| 634 |
[100.0, 100.0, 100.0, 100.0, 100.0, 100.0], |
| 635 |
], |
| 636 |
), |
| 637 |
( |
| 638 |
"sort_by_rgb_pow_sum", |
| 639 |
[ |
| 640 |
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0], |
| 641 |
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0], |
| 642 |
[50.0, 0.0, 0.0, 0.0, 0.0, 0.0], |
| 643 |
[25.0, 50.0, 25.0, 0.0, 0.0, 0.0], |
| 644 |
[50.0, 50.0, 25.0, 0.0, 0.0, 0.0], |
| 645 |
[50.0, 50.0, 50.0, 100.0, 100.0, 100.0], |
| 646 |
[50.0, 50.0, 100.0, 0.0, 0.0, 0.0], |
| 647 |
[80.0, 80.0, 80.0, 100.0, 100.0, 100.0], |
| 648 |
[50.0, 100.0, 100.0, 100.0, 100.0, 100.0], |
| 649 |
[100.0, 100.0, 100.0, 100.0, 100.0, 100.0], |
| 650 |
], |
| 651 |
), |
| 652 |
( |
| 653 |
"sort_by_rgb_sum", |
| 654 |
[ |
| 655 |
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0], |
| 656 |
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0], |
| 657 |
[50.0, 0.0, 0.0, 0.0, 0.0, 0.0], |
| 658 |
[25.0, 50.0, 25.0, 0.0, 0.0, 0.0], |
| 659 |
[50.0, 50.0, 25.0, 0.0, 0.0, 0.0], |
| 660 |
[50.0, 50.0, 50.0, 100.0, 100.0, 100.0], |
| 661 |
[50.0, 50.0, 100.0, 0.0, 0.0, 0.0], |
| 662 |
[80.0, 80.0, 80.0, 100.0, 100.0, 100.0], |
| 663 |
[50.0, 100.0, 100.0, 100.0, 100.0, 100.0], |
| 664 |
[100.0, 100.0, 100.0, 100.0, 100.0, 100.0], |
| 665 |
], |
| 666 |
), |
| 667 |
( |
| 668 |
"sort_by_rec709_luma", |
| 669 |
[ |
| 670 |
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0], |
| 671 |
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0], |
| 672 |
[50.0, 0.0, 0.0, 0.0, 0.0, 0.0], |
| 673 |
[25.0, 50.0, 25.0, 0.0, 0.0, 0.0], |
| 674 |
[50.0, 50.0, 25.0, 0.0, 0.0, 0.0], |
| 675 |
[50.0, 50.0, 50.0, 100.0, 100.0, 100.0], |
| 676 |
[50.0, 50.0, 100.0, 0.0, 0.0, 0.0], |
| 677 |
[80.0, 80.0, 80.0, 100.0, 100.0, 100.0], |
| 678 |
[50.0, 100.0, 100.0, 100.0, 100.0, 100.0], |
| 679 |
[100.0, 100.0, 100.0, 100.0, 100.0, 100.0], |
| 680 |
], |
| 681 |
), |
| 682 |
], |
| 683 |
) |
| 684 |
def test_cgats_sorting_1(data_files, function: str, result: list[list[float]]) -> None: |
| 685 |
"""Test ``DisplayCAL.cgats.CGATS`` sorting methods except sort_RGB_to_top.""" |
| 686 |
path = data_files["0_16_for_sorting.ti1"].absolute() |
| 687 |
cgats = CGATS(cgats=path) |
| 688 |
with check_call(CGATS, "set_rgb_xyz_values") as calls: |
| 689 |
getattr(cgats, function)() |
| 690 |
assert calls[0][0][1] == result |
| 691 |
|
| 692 |
|
| 693 |
class ColorCombination(TypedDict): |
| 694 |
"""Color combination with sorted result list.""" |
| 695 |
|
| 696 |
red: bool |
| 697 |
green: bool |
| 698 |
blue: bool |
| 699 |
result: list[list[float]] |
| 700 |
|
| 701 |
|
| 702 |
COLOR_COMBINATIONS = [ |
| 703 |
ColorCombination( |
| 704 |
red=False, |
| 705 |
green=False, |
| 706 |
blue=False, |
| 707 |
result=[], |
| 708 |
), |
| 709 |
ColorCombination( |
| 710 |
red=True, |
| 711 |
green=True, |
| 712 |
blue=True, |
| 713 |
result=[ |
| 714 |
[100.0, 100.0, 100.0, 100.0, 100.0, 100.0], |
| 715 |
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0], |
| 716 |
[50.0, 50.0, 50.0, 100.0, 100.0, 100.0], |
| 717 |
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0], |
| 718 |
[80.0, 80.0, 80.0, 100.0, 100.0, 100.0], |
| 719 |
[50.0, 100.0, 100.0, 100.0, 100.0, 100.0], |
| 720 |
[50.0, 0.0, 0.0, 0.0, 0.0, 0.0], |
| 721 |
[25.0, 50.0, 25.0, 0.0, 0.0, 0.0], |
| 722 |
[50.0, 50.0, 25.0, 0.0, 0.0, 0.0], |
| 723 |
[50.0, 50.0, 100.0, 0.0, 0.0, 0.0], |
| 724 |
], |
| 725 |
), |
| 726 |
ColorCombination( |
| 727 |
red=False, |
| 728 |
green=True, |
| 729 |
blue=True, |
| 730 |
result=[ |
| 731 |
[50.0, 100.0, 100.0, 100.0, 100.0, 100.0], |
| 732 |
[100.0, 100.0, 100.0, 100.0, 100.0, 100.0], |
| 733 |
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0], |
| 734 |
[50.0, 50.0, 50.0, 100.0, 100.0, 100.0], |
| 735 |
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0], |
| 736 |
[50.0, 0.0, 0.0, 0.0, 0.0, 0.0], |
| 737 |
[80.0, 80.0, 80.0, 100.0, 100.0, 100.0], |
| 738 |
[25.0, 50.0, 25.0, 0.0, 0.0, 0.0], |
| 739 |
[50.0, 50.0, 25.0, 0.0, 0.0, 0.0], |
| 740 |
[50.0, 50.0, 100.0, 0.0, 0.0, 0.0], |
| 741 |
], |
| 742 |
), |
| 743 |
ColorCombination( |
| 744 |
red=False, |
| 745 |
green=False, |
| 746 |
blue=True, |
| 747 |
result=[ |
| 748 |
[50.0, 50.0, 100.0, 0.0, 0.0, 0.0], |
| 749 |
[100.0, 100.0, 100.0, 100.0, 100.0, 100.0], |
| 750 |
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0], |
| 751 |
[50.0, 50.0, 50.0, 100.0, 100.0, 100.0], |
| 752 |
[50.0, 100.0, 100.0, 100.0, 100.0, 100.0], |
| 753 |
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0], |
| 754 |
[50.0, 0.0, 0.0, 0.0, 0.0, 0.0], |
| 755 |
[80.0, 80.0, 80.0, 100.0, 100.0, 100.0], |
| 756 |
[25.0, 50.0, 25.0, 0.0, 0.0, 0.0], |
| 757 |
[50.0, 50.0, 25.0, 0.0, 0.0, 0.0], |
| 758 |
], |
| 759 |
), |
| 760 |
ColorCombination( |
| 761 |
red=True, |
| 762 |
green=False, |
| 763 |
blue=False, |
| 764 |
result=[ |
| 765 |
[50.0, 0.0, 0.0, 0.0, 0.0, 0.0], |
| 766 |
[100.0, 100.0, 100.0, 100.0, 100.0, 100.0], |
| 767 |
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0], |
| 768 |
[50.0, 50.0, 50.0, 100.0, 100.0, 100.0], |
| 769 |
[50.0, 100.0, 100.0, 100.0, 100.0, 100.0], |
| 770 |
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0], |
| 771 |
[80.0, 80.0, 80.0, 100.0, 100.0, 100.0], |
| 772 |
[25.0, 50.0, 25.0, 0.0, 0.0, 0.0], |
| 773 |
[50.0, 50.0, 25.0, 0.0, 0.0, 0.0], |
| 774 |
[50.0, 50.0, 100.0, 0.0, 0.0, 0.0], |
| 775 |
], |
| 776 |
), |
| 777 |
ColorCombination( |
| 778 |
red=False, |
| 779 |
green=True, |
| 780 |
blue=False, |
| 781 |
result=[ |
| 782 |
[25.0, 50.0, 25.0, 0.0, 0.0, 0.0], |
| 783 |
[100.0, 100.0, 100.0, 100.0, 100.0, 100.0], |
| 784 |
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0], |
| 785 |
[50.0, 50.0, 50.0, 100.0, 100.0, 100.0], |
| 786 |
[50.0, 100.0, 100.0, 100.0, 100.0, 100.0], |
| 787 |
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0], |
| 788 |
[50.0, 0.0, 0.0, 0.0, 0.0, 0.0], |
| 789 |
[80.0, 80.0, 80.0, 100.0, 100.0, 100.0], |
| 790 |
[50.0, 50.0, 25.0, 0.0, 0.0, 0.0], |
| 791 |
[50.0, 50.0, 100.0, 0.0, 0.0, 0.0], |
| 792 |
], |
| 793 |
), |
| 794 |
ColorCombination( |
| 795 |
red=True, |
| 796 |
green=True, |
| 797 |
blue=False, |
| 798 |
result=[ |
| 799 |
[50.0, 50.0, 25.0, 0.0, 0.0, 0.0], |
| 800 |
[100.0, 100.0, 100.0, 100.0, 100.0, 100.0], |
| 801 |
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0], |
| 802 |
[50.0, 50.0, 50.0, 100.0, 100.0, 100.0], |
| 803 |
[50.0, 100.0, 100.0, 100.0, 100.0, 100.0], |
| 804 |
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0], |
| 805 |
[50.0, 0.0, 0.0, 0.0, 0.0, 0.0], |
| 806 |
[80.0, 80.0, 80.0, 100.0, 100.0, 100.0], |
| 807 |
[25.0, 50.0, 25.0, 0.0, 0.0, 0.0], |
| 808 |
[50.0, 50.0, 100.0, 0.0, 0.0, 0.0], |
| 809 |
], |
| 810 |
), |
| 811 |
ColorCombination( |
| 812 |
red=True, |
| 813 |
green=False, |
| 814 |
blue=True, |
| 815 |
result=[ |
| 816 |
[100.0, 100.0, 100.0, 100.0, 100.0, 100.0], |
| 817 |
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0], |
| 818 |
[50.0, 50.0, 50.0, 100.0, 100.0, 100.0], |
| 819 |
[50.0, 100.0, 100.0, 100.0, 100.0, 100.0], |
| 820 |
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0], |
| 821 |
[50.0, 0.0, 0.0, 0.0, 0.0, 0.0], |
| 822 |
[80.0, 80.0, 80.0, 100.0, 100.0, 100.0], |
| 823 |
[25.0, 50.0, 25.0, 0.0, 0.0, 0.0], |
| 824 |
[50.0, 50.0, 25.0, 0.0, 0.0, 0.0], |
| 825 |
[50.0, 50.0, 100.0, 0.0, 0.0, 0.0], |
| 826 |
], |
| 827 |
), |
| 828 |
] |
| 829 |
|
| 830 |
|
| 831 |
def get_color_combination() -> ColorCombination: |
| 832 |
"""Return color combination from COLOR_COMBINATIONS.""" |
| 833 |
yield from COLOR_COMBINATIONS |
| 834 |
|
| 835 |
|
| 836 |
@pytest.fixture( |
| 837 |
scope="session", name="color_combination", params=get_color_combination() |
| 838 |
) |
| 839 |
def fixture_color_combination(request: SubRequest) -> ColorCombination: |
| 840 |
"""Return color combination.""" |
| 841 |
return request.param |
| 842 |
|
| 843 |
|
| 844 |
def test_cgats_sorting_2(data_files, color_combination: ColorCombination) -> None: |
| 845 |
"""Test ``DisplayCAL.cgats.CGATS`` sorting method sort_RGB_to_top.""" |
| 846 |
path = data_files["0_16_for_sorting.ti1"].absolute() |
| 847 |
cgats = CGATS(cgats=path) |
| 848 |
if not color_combination["result"]: |
| 849 |
assert not cgats.sort_rgb_to_top( |
| 850 |
color_combination["red"], |
| 851 |
color_combination["green"], |
| 852 |
color_combination["blue"], |
| 853 |
) |
| 854 |
else: |
| 855 |
with check_call(CGATS, "set_rgb_xyz_values") as calls: |
| 856 |
cgats.sort_rgb_to_top( |
| 857 |
color_combination["red"], |
| 858 |
color_combination["green"], |
| 859 |
color_combination["blue"], |
| 860 |
) |
| 861 |
assert calls[0][0][1] == color_combination["result"] |
| 862 |
|
| 863 |
|
| 864 |
@pytest.mark.parametrize( |
| 865 |
"split_grays,shift,result", |
| 866 |
[ |
| 867 |
( |
| 868 |
True, |
| 869 |
True, |
| 870 |
[ |
| 871 |
[100.0, 100.0, 100.0, 100.0, 100.0, 100.0], |
| 872 |
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0], |
| 873 |
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0], |
| 874 |
[50.0, 0.0, 0.0, 0.0, 0.0, 0.0], |
| 875 |
[25.0, 50.0, 25.0, 0.0, 0.0, 0.0], |
| 876 |
[50.0, 50.0, 50.0, 100.0, 100.0, 100.0], |
| 877 |
[50.0, 50.0, 25.0, 0.0, 0.0, 0.0], |
| 878 |
[50.0, 100.0, 100.0, 100.0, 100.0, 100.0], |
| 879 |
[50.0, 50.0, 100.0, 0.0, 0.0, 0.0], |
| 880 |
[80.0, 80.0, 80.0, 100.0, 100.0, 100.0], |
| 881 |
], |
| 882 |
), |
| 883 |
( |
| 884 |
False, |
| 885 |
False, |
| 886 |
[ |
| 887 |
[100.0, 100.0, 100.0, 100.0, 100.0, 100.0], |
| 888 |
[50.0, 50.0, 25.0, 0.0, 0.0, 0.0], |
| 889 |
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0], |
| 890 |
[50.0, 50.0, 100.0, 0.0, 0.0, 0.0], |
| 891 |
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0], |
| 892 |
[50.0, 50.0, 50.0, 100.0, 100.0, 100.0], |
| 893 |
[50.0, 0.0, 0.0, 0.0, 0.0, 0.0], |
| 894 |
[50.0, 100.0, 100.0, 100.0, 100.0, 100.0], |
| 895 |
[25.0, 50.0, 25.0, 0.0, 0.0, 0.0], |
| 896 |
[80.0, 80.0, 80.0, 100.0, 100.0, 100.0], |
| 897 |
], |
| 898 |
), |
| 899 |
( |
| 900 |
True, |
| 901 |
False, |
| 902 |
[ |
| 903 |
[100.0, 100.0, 100.0, 100.0, 100.0, 100.0], |
| 904 |
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0], |
| 905 |
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0], |
| 906 |
[50.0, 0.0, 0.0, 0.0, 0.0, 0.0], |
| 907 |
[50.0, 50.0, 50.0, 100.0, 100.0, 100.0], |
| 908 |
[25.0, 50.0, 25.0, 0.0, 0.0, 0.0], |
| 909 |
[50.0, 100.0, 100.0, 100.0, 100.0, 100.0], |
| 910 |
[50.0, 50.0, 25.0, 0.0, 0.0, 0.0], |
| 911 |
[80.0, 80.0, 80.0, 100.0, 100.0, 100.0], |
| 912 |
[50.0, 50.0, 100.0, 0.0, 0.0, 0.0], |
| 913 |
], |
| 914 |
), |
| 915 |
( |
| 916 |
False, |
| 917 |
True, |
| 918 |
[ |
| 919 |
[100.0, 100.0, 100.0, 100.0, 100.0, 100.0], |
| 920 |
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0], |
| 921 |
[50.0, 50.0, 100.0, 0.0, 0.0, 0.0], |
| 922 |
[50.0, 0.0, 0.0, 0.0, 0.0, 0.0], |
| 923 |
[50.0, 50.0, 50.0, 100.0, 100.0, 100.0], |
| 924 |
[25.0, 50.0, 25.0, 0.0, 0.0, 0.0], |
| 925 |
[50.0, 100.0, 100.0, 100.0, 100.0, 100.0], |
| 926 |
[0.0, 0.0, 0.0, 0.0, 0.0, 0.0], |
| 927 |
[50.0, 50.0, 25.0, 0.0, 0.0, 0.0], |
| 928 |
[80.0, 80.0, 80.0, 100.0, 100.0, 100.0], |
| 929 |
], |
| 930 |
), |
| 931 |
], |
| 932 |
ids=( |
| 933 |
"split grays - with shift", |
| 934 |
"dont split grays - without shift", |
| 935 |
"split grays - without shift", |
| 936 |
"dont split grays - with shift", |
| 937 |
), |
| 938 |
) |
| 939 |
def test_cgats_checkerboard( |
| 940 |
data_files, split_grays: bool, shift: bool, result: list[list[float]] |
| 941 |
) -> None: |
| 942 |
"""Test ``DisplayCAL.cgats.CGATS`` checkerboard method.""" |
| 943 |
path = data_files["0_16_for_sorting.ti1"].absolute() |
| 944 |
cgats = CGATS(cgats=path) |
| 945 |
with check_call(CGATS, "set_rgb_xyz_values") as calls: |
| 946 |
cgats.checkerboard(split_grays=split_grays, shift=shift) |
| 947 |
assert calls[0][0][1] == result |
| 948 |
|
| 949 |
|
| 950 |
@pytest.mark.parametrize( |
| 951 |
"name", ["fails_when_unstable", "ok_when_unstable", "large_set"] |
| 952 |
) |
| 953 |
def test_cgats_maximise_lightness_sort_is_invariant_to_input(data_files, name): |
| 954 |
path = data_files[f"{name}.ti1"].absolute() |
| 955 |
cgats = CGATS(cgats=path) |
| 956 |
results = [] |
| 957 |
|
| 958 |
for i in range(3): |
| 959 |
cgats.checkerboard(sort1=stable_sort_by_l) |
| 960 |
results.append(cgats.get_rgb_xyz_values()[1]) |
| 961 |
assert results |
| 962 |
for i in range(len(results[0])): |
| 963 |
last = None |
| 964 |
for r in results: |
| 965 |
if last is not None: |
| 966 |
assert r[i] == last[i] |
| 967 |
last = r |
| 968 |
|
| 969 |
|
| 970 |
@pytest.mark.parametrize( |
| 971 |
"weight", |
| 972 |
(True, False), |
| 973 |
ids=( |
| 974 |
"with weight", |
| 975 |
"without weight", |
| 976 |
), |
| 977 |
) |
| 978 |
@pytest.mark.parametrize( |
| 979 |
"file", |
| 980 |
("Monitor.cal", "0_16_proper.ti3"), |
| 981 |
) |
| 982 |
def test_cgats_apply_bpc( |
| 983 |
data_files, |
| 984 |
weight: bool, |
| 985 |
file: str, |
| 986 |
) -> None: |
| 987 |
"""Test ``DisplayCAL.cgats.CGATS`` black point compensation method.""" |
| 988 |
path = data_files[file].absolute() |
| 989 |
cgats = CGATS(cgats=path) |
| 990 |
assert cgats[0].apply_bpc(weight=weight) == 1 |
| 991 |
|
| 992 |
|
| 993 |
@pytest.mark.parametrize( |
| 994 |
"profile,result", |
| 995 |
( |
| 996 |
( |
| 997 |
"0_16_proper.ti3", |
| 998 |
{ |
| 999 |
0: b"SAMPLE_ID", |
| 1000 |
1: b"RGB_R", |
| 1001 |
2: b"RGB_G", |
| 1002 |
3: b"RGB_B", |
| 1003 |
4: b"XYZ_X", |
| 1004 |
5: b"XYZ_Y", |
| 1005 |
6: b"XYZ_Z", |
| 1006 |
}, |
| 1007 |
), |
| 1008 |
("Monitor.cal", None), |
| 1009 |
), |
| 1010 |
) |
| 1011 |
def test_cgats_get_cie_data_format( |
| 1012 |
data_files, profile: str, result: dict[int, bytes] | None |
| 1013 |
) -> None: |
| 1014 |
"""Test ``DisplayCAL.cgats.CGATS`` get_cie_data_format.""" |
| 1015 |
path = data_files[profile].absolute() |
| 1016 |
cgats = CGATS(cgats=path) |
| 1017 |
assert cgats.get_cie_data_format() == result |
| 1018 |
|
| 1019 |
|
| 1020 |
@pytest.mark.parametrize( |
| 1021 |
"profile,result", |
| 1022 |
( |
| 1023 |
( |
| 1024 |
"0_16_proper.ti3", |
| 1025 |
{"XYZ_X": 92.51826162624847, "XYZ_Y": 100.0, "XYZ_Z": 110.07025946041877}, |
| 1026 |
), |
| 1027 |
( |
| 1028 |
"Monitor.ti3", |
| 1029 |
{"XYZ_X": 95.28091210097986, "XYZ_Y": 100.0, "XYZ_Z": 108.01177927429806}, |
| 1030 |
), |
| 1031 |
("Monitor.cal", None), |
| 1032 |
), |
| 1033 |
) |
| 1034 |
def test_cgats_get_white_cie( |
| 1035 |
data_files, profile: str, result: dict[float] | None |
| 1036 |
) -> None: |
| 1037 |
"""Test ``DisplayCAL.cgats.CGATS`` get_white_cie.""" |
| 1038 |
path = data_files[profile].absolute() |
| 1039 |
cgats = CGATS(cgats=path) |
| 1040 |
assert cgats.get_white_cie() == result |
| 1041 |
|
| 1042 |
|
| 1043 |
@pytest.mark.parametrize( |
| 1044 |
"profile,result", |
| 1045 |
( |
| 1046 |
("0_16_proper.ti3", 1), |
| 1047 |
("Monitor.ti3", 1), |
| 1048 |
("multiple_sections.ti1", 3), |
| 1049 |
("Monitor.cal", 0), |
| 1050 |
), |
| 1051 |
) |
| 1052 |
def test_cgats_adapt(data_files, profile: str, result: int) -> None: |
| 1053 |
"""Test ``DisplayCAL.cgats.CGATS`` adapt method.""" |
| 1054 |
path = data_files[profile].absolute() |
| 1055 |
cgats = CGATS(cgats=path) |
| 1056 |
assert cgats.adapt() == result |
| 1057 |
|
| 1058 |
|
| 1059 |
def test_cgats_convert_XYZ_to_Lab(data_files) -> None: |
| 1060 |
"""Test ``DisplayCAL.cgats.CGATS`` convert_XYZ_to_Lab method.""" |
| 1061 |
path = data_files["0_16_proper.ti3"].absolute() |
| 1062 |
cgats = CGATS(cgats=path) |
| 1063 |
cgats.convert_xyz_to_lab() |
| 1064 |
assert all(key in cgats[0]["DATA"][0] for key in [b"LAB_L", b"LAB_A", b"LAB_B"]) |
| 1065 |
|
| 1066 |
|
| 1067 |
@pytest.mark.parametrize("warn", (True, False), ids=("warn only", "take action")) |
| 1068 |
@pytest.mark.parametrize( |
| 1069 |
"profile,filtered_sets,unfiltered_sets,result", |
| 1070 |
( |
| 1071 |
( |
| 1072 |
"Monitor.ti3", |
| 1073 |
175, |
| 1074 |
175, |
| 1075 |
{ |
| 1076 |
"SAMPLE_ID": 1, |
| 1077 |
"RGB_R": 100.0, |
| 1078 |
"RGB_G": 100.0, |
| 1079 |
"RGB_B": 100.0, |
| 1080 |
"XYZ_X": 95.28091, |
| 1081 |
"XYZ_Y": 100.0, |
| 1082 |
"XYZ_Z": 108.0118, |
| 1083 |
}, |
| 1084 |
), |
| 1085 |
( |
| 1086 |
"Monitor_FixableSet.ti3", |
| 1087 |
175, |
| 1088 |
175, |
| 1089 |
{ |
| 1090 |
"SAMPLE_ID": 1, |
| 1091 |
"RGB_R": 100.0, |
| 1092 |
"RGB_G": 100.0, |
| 1093 |
"RGB_B": 100.0, |
| 1094 |
"XYZ_X": 1e-06, |
| 1095 |
"XYZ_Y": 100.0, |
| 1096 |
"XYZ_Z": 108.0118, |
| 1097 |
}, |
| 1098 |
), |
| 1099 |
( |
| 1100 |
"Monitor_UnfixableSet.ti3", |
| 1101 |
174, |
| 1102 |
175, |
| 1103 |
{ |
| 1104 |
"SAMPLE_ID": 2, |
| 1105 |
"RGB_R": 100.0, |
| 1106 |
"RGB_G": 100.0, |
| 1107 |
"RGB_B": 75.0, |
| 1108 |
"XYZ_X": 86.58697, |
| 1109 |
"XYZ_Y": 97.50149, |
| 1110 |
"XYZ_Z": 61.68331, |
| 1111 |
}, |
| 1112 |
), |
| 1113 |
), |
| 1114 |
) |
| 1115 |
def test_fix_zero_measurements( |
| 1116 |
data_files, |
| 1117 |
profile: str, |
| 1118 |
filtered_sets: int, |
| 1119 |
unfiltered_sets: int, |
| 1120 |
result: dict[str, int | float], |
| 1121 |
warn: bool, |
| 1122 |
) -> None: |
| 1123 |
"""Test ``DisplayCAL.cgats.CGATS`` fix_zero_measurements method.""" |
| 1124 |
path = data_files[profile].absolute() |
| 1125 |
cgats = CGATS(cgats=path) |
| 1126 |
cgats.fix_zero_measurements(warn_only=warn) |
| 1127 |
assert len(cgats[0]["DATA"]) == unfiltered_sets if warn else filtered_sets |
| 1128 |
if not warn: |
| 1129 |
assert cgats[0]["DATA"][0] == result |