Skip to content

Commit 54955e4

Browse files
refactor: improved segment coordinate finding with list comprehension and walrus operator
1 parent 0b00baa commit 54955e4

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/ursina_proteins/protein.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -241,11 +241,11 @@ def compute_helices_and_coils_meshes(
241241
for segment_type, segments in chain_segments.items():
242242
for start, end in segments:
243243
# Get coordinates of the segment's carbon alpha atoms
244-
coords = []
245-
for i in range(start, end + 1):
246-
coord = carbon_alpha_coords.get(i)
247-
if coord is not None:
248-
coords.append(coord)
244+
coords = [
245+
coord
246+
for i in range(start, end + 1)
247+
if (coord := carbon_alpha_coords.get(i)) is not None
248+
]
249249

250250
tris_start = len(verts[segment_type])
251251

0 commit comments

Comments
 (0)