Skip to content

Commit

Permalink
Merge pull request #2692 from cta-observatory/fix_tel_grouping
Browse files Browse the repository at this point in the history
Fix telescope grouping for uint telescope id
  • Loading branch information
maxnoe authored Feb 6, 2025
2 parents 17062d4 + 03b639d commit f6953ee
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions docs/changes/2692.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix the function grouping telescope ids into ranges for
the case of unsigned integer telescope ids.
2 changes: 1 addition & 1 deletion src/ctapipe/instrument/subarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def _group_consecutives(sequence):
from https://codereview.stackexchange.com/questions/214820/codewars-range-extraction
"""
sequence = sorted(sequence)
for _, g in groupby(enumerate(sequence), lambda i_x: i_x[0] - i_x[1]):
for _, g in groupby(enumerate(sequence), lambda i_x: int(i_x[0]) - int(i_x[1])):
r = [x for _, x in g]
if len(r) > 2:
yield f"{r[0]}-{r[-1]}"
Expand Down

0 comments on commit f6953ee

Please sign in to comment.