Skip to content

Commit e8ba583

Browse files
committed
Fix complaints on unit test
Signed-off-by: M Q <[email protected]>
1 parent b34bb8b commit e8ba583

File tree

1 file changed

+48
-46
lines changed

1 file changed

+48
-46
lines changed

tests/unit/test_decoder_nvimgcodec.py

Lines changed: 48 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
unregister_as_decoder_plugin,
1414
)
1515

16-
1716
# The JPEG 8-bit standard allows a maximum 1 bit of difference for each pixel component.
1817
# It is normal for slight differences to exist due to varying internal precision in the
1918
# decoders' inverse Discrete Cosine Transform (IDCT) implementations
@@ -26,55 +25,55 @@
2625

2726
# Files that cannot be decoded with the default decoders
2827
SKIPPING_DEFAULT_ERRORED_FILES = {
29-
'UN_sequence.dcm': '1.2.840.10008.1.2.4.70',
30-
'JPEG-lossy.dcm': '1.2.840.10008.1.2.4.51',
31-
'JPEG2000-embedded-sequence-delimiter.dcm': '1.2.840.10008.1.2.4.91',
32-
'emri_small_jpeg_2k_lossless_too_short.dcm': '1.2.840.10008.1.2.4.90',
28+
"UN_sequence.dcm": "1.2.840.10008.1.2.4.70",
29+
"JPEG-lossy.dcm": "1.2.840.10008.1.2.4.51",
30+
"JPEG2000-embedded-sequence-delimiter.dcm": "1.2.840.10008.1.2.4.91",
31+
"emri_small_jpeg_2k_lossless_too_short.dcm": "1.2.840.10008.1.2.4.90",
3332
}
3433

3534
# Files that have unequal pixel values between default and nvimgcodec decoders
3635
SKIPPING_UNEQUAL_PIXEL_FILES = {
37-
'SC_rgb_jpeg_lossy_gdcm.dcm': '1.2.840.10008.1.2.4.50',
38-
'SC_rgb_dcmtk_+eb+cr.dcm': '1.2.840.10008.1.2.4.50',
39-
'SC_rgb_jpeg_dcmtk.dcm': '1.2.840.10008.1.2.4.50',
40-
'SC_rgb_dcmtk_+eb+cy+n1.dcm': '1.2.840.10008.1.2.4.50',
41-
'SC_rgb_dcmtk_+eb+cy+s2.dcm': '1.2.840.10008.1.2.4.50',
42-
'examples_ybr_color.dcm': '1.2.840.10008.1.2.4.50',
43-
'SC_rgb_dcmtk_+eb+cy+n2.dcm': '1.2.840.10008.1.2.4.50',
44-
'SC_rgb_dcmtk_+eb+cy+s4.dcm': '1.2.840.10008.1.2.4.50',
45-
'SC_rgb_jpeg.dcm': '1.2.840.10008.1.2.4.50',
46-
'SC_rgb_jpeg_app14_dcmd.dcm': '1.2.840.10008.1.2.4.50',
47-
'SC_jpeg_no_color_transform.dcm': '1.2.840.10008.1.2.4.50',
48-
'SC_jpeg_no_color_transform_2.dcm': '1.2.840.10008.1.2.4.50',
49-
'SC_rgb_small_odd_jpeg.dcm': '1.2.840.10008.1.2.4.50',
50-
'SC_rgb_dcmtk_+eb+cy+np.dcm': '1.2.840.10008.1.2.4.50',
51-
'color3d_jpeg_baseline.dcm': '1.2.840.10008.1.2.4.50',
52-
'MR2_J2KI.dcm': '1.2.840.10008.1.2.4.91',
53-
'RG3_J2KI.dcm': '1.2.840.10008.1.2.4.91',
54-
'US1_J2KI.dcm': '1.2.840.10008.1.2.4.91'
36+
"SC_rgb_jpeg_lossy_gdcm.dcm": "1.2.840.10008.1.2.4.50",
37+
"SC_rgb_dcmtk_+eb+cr.dcm": "1.2.840.10008.1.2.4.50",
38+
"SC_rgb_jpeg_dcmtk.dcm": "1.2.840.10008.1.2.4.50",
39+
"SC_rgb_dcmtk_+eb+cy+n1.dcm": "1.2.840.10008.1.2.4.50",
40+
"SC_rgb_dcmtk_+eb+cy+s2.dcm": "1.2.840.10008.1.2.4.50",
41+
"examples_ybr_color.dcm": "1.2.840.10008.1.2.4.50",
42+
"SC_rgb_dcmtk_+eb+cy+n2.dcm": "1.2.840.10008.1.2.4.50",
43+
"SC_rgb_dcmtk_+eb+cy+s4.dcm": "1.2.840.10008.1.2.4.50",
44+
"SC_rgb_jpeg.dcm": "1.2.840.10008.1.2.4.50",
45+
"SC_rgb_jpeg_app14_dcmd.dcm": "1.2.840.10008.1.2.4.50",
46+
"SC_jpeg_no_color_transform.dcm": "1.2.840.10008.1.2.4.50",
47+
"SC_jpeg_no_color_transform_2.dcm": "1.2.840.10008.1.2.4.50",
48+
"SC_rgb_small_odd_jpeg.dcm": "1.2.840.10008.1.2.4.50",
49+
"SC_rgb_dcmtk_+eb+cy+np.dcm": "1.2.840.10008.1.2.4.50",
50+
"color3d_jpeg_baseline.dcm": "1.2.840.10008.1.2.4.50",
51+
"MR2_J2KI.dcm": "1.2.840.10008.1.2.4.91",
52+
"RG3_J2KI.dcm": "1.2.840.10008.1.2.4.91",
53+
"US1_J2KI.dcm": "1.2.840.10008.1.2.4.91",
5554
}
5655

5756
CONFIRMED_EQUAL_PIXEL_FILES = {
58-
'JPGExtended.dcm': '1.2.840.10008.1.2.4.51',
59-
'examples_jpeg2k.dcm': '1.2.840.10008.1.2.4.90',
60-
'J2K_pixelrep_mismatch.dcm': '1.2.840.10008.1.2.4.90',
61-
'SC_rgb_gdcm_KY.dcm': '1.2.840.10008.1.2.4.91',
62-
'GDCMJ2K_TextGBR.dcm': '1.2.840.10008.1.2.4.90',
63-
'SC_rgb_jpeg_gdcm.dcm': '1.2.840.10008.1.2.4.70',
64-
'MR_small_jp2klossless.dcm': '1.2.840.10008.1.2.4.90',
65-
'JPEG2000.dcm': '1.2.840.10008.1.2.4.91',
66-
'693_J2KI.dcm': '1.2.840.10008.1.2.4.91',
67-
'693_J2KR.dcm': '1.2.840.10008.1.2.4.90',
68-
'bad_sequence.dcm': '1.2.840.10008.1.2.4.70',
69-
'emri_small_jpeg_2k_lossless.dcm': '1.2.840.10008.1.2.4.90',
70-
'explicit_VR-UN.dcm': '1.2.840.10008.1.2.4.90',
71-
'JPEG-LL.dcm': '1.2.840.10008.1.2.4.70',
72-
'JPGLosslessP14SV1_1s_1f_8b.dcm': '1.2.840.10008.1.2.4.70',
73-
'MR2_J2KR.dcm': '1.2.840.10008.1.2.4.90',
74-
'RG1_J2KI.dcm': '1.2.840.10008.1.2.4.91',
75-
'RG1_J2KR.dcm': '1.2.840.10008.1.2.4.90',
76-
'RG3_J2KR.dcm': '1.2.840.10008.1.2.4.90',
77-
'US1_J2KR.dcm': '1.2.840.10008.1.2.4.90'
57+
"JPGExtended.dcm": "1.2.840.10008.1.2.4.51",
58+
"examples_jpeg2k.dcm": "1.2.840.10008.1.2.4.90",
59+
"J2K_pixelrep_mismatch.dcm": "1.2.840.10008.1.2.4.90",
60+
"SC_rgb_gdcm_KY.dcm": "1.2.840.10008.1.2.4.91",
61+
"GDCMJ2K_TextGBR.dcm": "1.2.840.10008.1.2.4.90",
62+
"SC_rgb_jpeg_gdcm.dcm": "1.2.840.10008.1.2.4.70",
63+
"MR_small_jp2klossless.dcm": "1.2.840.10008.1.2.4.90",
64+
"JPEG2000.dcm": "1.2.840.10008.1.2.4.91",
65+
"693_J2KI.dcm": "1.2.840.10008.1.2.4.91",
66+
"693_J2KR.dcm": "1.2.840.10008.1.2.4.90",
67+
"bad_sequence.dcm": "1.2.840.10008.1.2.4.70",
68+
"emri_small_jpeg_2k_lossless.dcm": "1.2.840.10008.1.2.4.90",
69+
"explicit_VR-UN.dcm": "1.2.840.10008.1.2.4.90",
70+
"JPEG-LL.dcm": "1.2.840.10008.1.2.4.70",
71+
"JPGLosslessP14SV1_1s_1f_8b.dcm": "1.2.840.10008.1.2.4.70",
72+
"MR2_J2KR.dcm": "1.2.840.10008.1.2.4.90",
73+
"RG1_J2KI.dcm": "1.2.840.10008.1.2.4.91",
74+
"RG1_J2KR.dcm": "1.2.840.10008.1.2.4.90",
75+
"RG3_J2KR.dcm": "1.2.840.10008.1.2.4.90",
76+
"US1_J2KR.dcm": "1.2.840.10008.1.2.4.90",
7877
}
7978

8079

@@ -158,7 +157,7 @@ def test_nvimgcodec_decoder_matches_default():
158157
if transfer_syntax in TRANSFER_SYNTAXES_WITH_UNEQUAL_PIXEL_VALUES:
159158
diff = baseline_compare.astype(np.float32) - nv_compare.astype(np.float32)
160159
peak_absolute_error = float(np.max(np.abs(diff)))
161-
mean_squared_error = float(np.mean(diff ** 2))
160+
mean_squared_error = float(np.mean(diff**2))
162161
inspected_unequal_files[Path(path).name] = {
163162
"transfer_syntax": transfer_syntax,
164163
"peak_absolute_error": peak_absolute_error,
@@ -181,9 +180,12 @@ def test_nvimgcodec_decoder_matches_default():
181180
print(f"Confirmed tested files: {confirmed_equal_pixel_files}")
182181

183182
assert compared > 0, "No compatible DICOM files found for nvimgcodec decoder test."
184-
assert (x in default_errored_files.keys() for x in (nvimgcodec_errored_files.keys())), "nvimgcodec decoder errored files found."
183+
assert (
184+
x in default_errored_files.keys() for x in (nvimgcodec_errored_files.keys())
185+
), "nvimgcodec decoder errored files found."
185186
assert len(unequal_pixel_files) == 0, "Unequal files found."
186187
assert len(confirmed_equal_pixel_files) > 0, "No files with equal pixel values after decoding with both decoders."
187188

189+
188190
if __name__ == "__main__":
189-
test_nvimgcodec_decoder_matches_default()
191+
test_nvimgcodec_decoder_matches_default()

0 commit comments

Comments
 (0)