From 0f173e47853931565b83cab2c7164e654302f111 Mon Sep 17 00:00:00 2001 From: Chris Bridge Date: Tue, 30 Jan 2024 22:20:51 +0000 Subject: [PATCH] Style fixes --- src/highdicom/seg/sop.py | 29 +++++++++++++++-------------- src/highdicom/utils.py | 6 +++++- tests/test_seg.py | 7 +++++-- 3 files changed, 25 insertions(+), 17 deletions(-) diff --git a/src/highdicom/seg/sop.py b/src/highdicom/seg/sop.py index 84a8de4d..eecca404 100644 --- a/src/highdicom/seg/sop.py +++ b/src/highdicom/seg/sop.py @@ -1191,7 +1191,9 @@ def __init__( tile_size: Union[Sequence[int], None] = None, pyramid_uid: Optional[str] = None, pyramid_label: Optional[str] = None, - palette_color_lut_transformation: Optional[PaletteColorLUTTransformation] = None, + palette_color_lut_transformation: Optional[ + PaletteColorLUTTransformation + ] = None, icc_profile: Optional[bytes] = None, **kwargs: Any ) -> None: @@ -1718,8 +1720,8 @@ def __init__( PaletteColorLUTTransformation ): raise TypeError( - 'Argument "palette_color_lut_transformation" must be of type ' - 'PaletteColorLUTTransformation.' + 'Argument "palette_color_lut_transformation" must be ' + 'of type highdicom.PaletteColorLUTTransformation.' ) lut = palette_color_lut_transformation.red_lut @@ -2180,16 +2182,13 @@ def __init__( # Even though completely empty planes were removed earlier, # there may still be planes in which this specific segment is # absent. Such frames should be removed - if ( - segment_number is not None - and omit_empty_frames - and not np.any(segment_array) - ): - logger.debug( - f'skip empty plane {plane_index} of segment ' - f'#{segment_number}' - ) - continue + if segment_number is not None: + if omit_empty_frames and not np.any(segment_array): + logger.debug( + f'skip empty plane {plane_index} of segment ' + f'#{segment_number}' + ) + continue # Log a debug message if segment_number is None: @@ -3506,7 +3505,9 @@ def _build_luts(self) -> None: n_expected_dim_ind_pointers = len(self._dim_ind_pointers) else: # (+1 because referenced segment number is ignored) - n_expected_dim_ind_pointers = len(self._dim_ind_pointers) + 1 + n_expected_dim_ind_pointers = ( + len(self._dim_ind_pointers) + 1 + ) if len(indices) != n_expected_dim_ind_pointers: raise RuntimeError( 'Unexpected mismatch between dimension index values in ' diff --git a/src/highdicom/utils.py b/src/highdicom/utils.py index e345d925..a9d0dba8 100644 --- a/src/highdicom/utils.py +++ b/src/highdicom/utils.py @@ -242,7 +242,11 @@ def compute_plane_position_tiled_full( def iter_tiled_full_frame_data( dataset: Dataset, -) -> Generator[Tuple[Union[int, None], int, int, int, float, float, float], None, None]: +) -> Generator[ + Tuple[Union[int, None], int, int, int, float, float, float], + None, + None, +]: """Get data on the position of each tile in a TILED_FULL image. This works only with images with Dimension Organization Type of diff --git a/tests/test_seg.py b/tests/test_seg.py index db01f579..023fe145 100644 --- a/tests/test_seg.py +++ b/tests/test_seg.py @@ -822,8 +822,11 @@ def check_dimension_index_vals(seg): # DimensionIndexValues has VM=1 in this case so returns int posn_index = f.FrameContentSequence[0].DimensionIndexValues else: - # DimensionIndexValues has VM>1 in this case so returns list - posn_index = f.FrameContentSequence[0].DimensionIndexValues[1] + # DimensionIndexValues has VM>1 in this case so returns + # list + posn_index = ( + f.FrameContentSequence[0].DimensionIndexValues[1] + ) # This is not general, but all the tests run here use axial # images so just check the z coordinate posn_val = f.PlanePositionSequence[0].ImagePositionPatient[2]