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

Fix SubarrayDescription.info for non-unique telescope description strings #2673

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
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
Loading