Skip to content

Commit

Permalink
Fix SubarrayDescription.info for non-unique telescope description str…
Browse files Browse the repository at this point in the history
…ings
  • Loading branch information
maxnoe committed Jan 9, 2025
1 parent d0ab1d1 commit 3ba1f4b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
2 changes: 2 additions & 0 deletions docs/changes/2673.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix ``SubarrayDescription.info()`` in cases
of different ``TelescopeDescription`` with the same string representation.
13 changes: 7 additions & 6 deletions src/ctapipe/instrument/subarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Description of Arrays or Subarrays of telescopes
"""
import warnings
from collections import defaultdict
from collections.abc import Iterable
from contextlib import ExitStack
from copy import copy
Expand Down Expand Up @@ -135,19 +136,19 @@ def info(self, printer=print):
printer("")

# print the per-telescope-type informatino:
n_tels = {}
tel_ids = {}

tel_ids = defaultdict(list)
for tel_type in self.telescope_types:
ids = self.get_tel_ids_for_type(tel_type)
tel_ids[str(tel_type)] = _range_extraction(ids)
n_tels[str(tel_type)] = len(ids)
tel_ids[str(tel_type)].extend(ids)

n_tels = {tel_type: len(ids) for tel_type, ids in tel_ids.items()}
id_ranges = [_range_extraction(ids) for ids in tel_ids.values()]

out_table = Table(
{
"Type": list(n_tels.keys()),
"Count": list(n_tels.values()),
"Tel IDs": list(tel_ids.values()),
"Tel IDs": id_ranges,
}
)
out_table["Tel IDs"].format = "<s"
Expand Down

0 comments on commit 3ba1f4b

Please sign in to comment.