Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use list comprehension where possible #262

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/highdicom/pr/content.py
Original file line number Diff line number Diff line change
Expand Up @@ -1486,15 +1486,15 @@ def _get_softcopy_voi_lut_transformations(
)].append(ref_im)
elif has_lut:
# Create a unique identifier for this list of LUTs
lut_info = []
for voi_lut in ref_im.VOILUTSequence:
lut_info.append((
lut_id = (
(
voi_lut.LUTDescriptor[1],
voi_lut.LUTDescriptor[2],
getattr(voi_lut, 'LUTExplanation', None),
voi_lut.LUTData
))
lut_id = tuple(lut_info)
)
for voi_lut in ref_im.VOILUTSequence
)
by_lut[lut_id].append(ref_im)

for (width, center, exp, func), im_list in by_window.items():
Expand Down
18 changes: 6 additions & 12 deletions src/highdicom/seg/sop.py
Original file line number Diff line number Diff line change
Expand Up @@ -2595,12 +2595,9 @@ def segmented_property_categories(self) -> List[CodedConcept]:
descriptions in this SEG image.

"""
categories = []
for desc in self.SegmentSequence:
if desc.segmented_property_category not in categories:
categories.append(desc.segmented_property_category)

return categories
return list(
{desc.segmented_property_category for desc in self.SegmentSequence}
)
DimitriPapadopoulos marked this conversation as resolved.
Show resolved Hide resolved

@property
def segmented_property_types(self) -> List[CodedConcept]:
Expand All @@ -2613,12 +2610,9 @@ def segmented_property_types(self) -> List[CodedConcept]:
descriptions in this SEG image.

"""
types = []
for desc in self.SegmentSequence:
if desc.segmented_property_type not in types:
types.append(desc.segmented_property_type)

return types
return list(
{desc.segmented_property_type for desc in self.SegmentSequence}
)
DimitriPapadopoulos marked this conversation as resolved.
Show resolved Hide resolved

def _get_pixels_by_seg_frame(
self,
Expand Down