33
44import numpy as np
55import pytest
6- from pydicom import config as pydicom_config
76from pydicom import dcmread
87from pydicom .data import get_testdata_files
98
7978
8079
8180@pytest .mark .skipif (
82- (not _is_nvimgcodec_available ()) or ( not pydicom_config . have_gdcm ) ,
81+ (not _is_nvimgcodec_available ()),
8382 reason = "nvimgcodec (with CUDA) and GDCM must be available" ,
8483)
8584def test_nvimgcodec_decoder_matches_default () -> None :
@@ -113,8 +112,8 @@ def test_nvimgcodec_decoder_matches_default() -> None:
113112 print (f"Skipping: unsupported transfer syntax DICOM file { path } : { transfer_syntax } " )
114113 continue
115114
116- baseline_pixels = None
117- nv_pixels = None
115+ baseline_pixels : np . ndarray = np . array ([])
116+ nv_pixels : np . ndarray = np . array ([])
118117
119118 # Baseline (default pydicom) decode
120119 try :
@@ -159,8 +158,8 @@ def test_nvimgcodec_decoder_matches_default() -> None:
159158 if not np .allclose (
160159 baseline_compare ,
161160 nv_compare ,
162- rtol = _rtol ,
163- atol = _atol ,
161+ rtol = rtol ,
162+ atol = atol ,
164163 ):
165164 if transfer_syntax in TRANSFER_SYNTAXES_WITH_UNEQUAL_PIXEL_VALUES :
166165 diff = baseline_compare .astype (np .float32 ) - nv_compare .astype (np .float32 )
@@ -172,9 +171,9 @@ def test_nvimgcodec_decoder_matches_default() -> None:
172171 "mean_squared_error" : mean_squared_error ,
173172 }
174173 else :
175- unequal_pixel_files [Path (path ).name ] = { "transfer_syntax" : transfer_syntax }
174+ unequal_pixel_files [Path (path ).name ] = f "transfer_syntax: { transfer_syntax } "
176175 else :
177- confirmed_equal_pixel_files [Path (path ).name ] = transfer_syntax
176+ confirmed_equal_pixel_files [Path (path ).name ] = f" transfer_syntax: { transfer_syntax } "
178177
179178 compared += 1
180179
@@ -183,8 +182,8 @@ def test_nvimgcodec_decoder_matches_default() -> None:
183182 print (f"Total tested DICOM files: { compared } " )
184183 print (f"Default errored files: { default_errored_files } " )
185184 print (f"nvimgcodec errored files: { nvimgcodec_errored_files } " )
186- print (f"Unequal files (tolerance: { _rtol } , { _atol } ): { unequal_pixel_files } " )
187- print (f"Inspected unequal files (tolerance: { _rtol } , { _atol } ): { inspected_unequal_files } " )
185+ print (f"Unequal files (tolerance: { rtol } , { atol } ): { unequal_pixel_files } " )
186+ print (f"Inspected unequal files (tolerance: { rtol } , { atol } ): { inspected_unequal_files } " )
188187 print (f"Confirmed tested files: { confirmed_equal_pixel_files } " )
189188
190189 assert compared > 0 , "No compatible DICOM files found for nvimgcodec decoder test."
0 commit comments