Skip to content

Commit

Permalink
Improve test
Browse files Browse the repository at this point in the history
  • Loading branch information
maxnoe committed Jun 20, 2023
1 parent bb272a5 commit b8181e7
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions ctapipe/instrument/tests/test_trigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@
from ctapipe.io import EventSource


def assert_all_tel_keys(event, expected):
def assert_all_tel_keys(event, expected, ignore=None):
if ignore is None:
ignore = set()

expected = tuple(expected)
for name, container in event.items():
if hasattr(container, "tel"):
actual = tuple(container.tel.keys())
if len(actual) > 0 and actual != expected:
if name not in ignore and actual != expected:
raise AssertionError(
f"Unexpected tel_ids in container {name}:" f"{actual} != {expected}"
)
Expand Down Expand Up @@ -115,7 +118,7 @@ def test_software_trigger_simtel(allowed_tels):
for e, expected_tels in zip(source, expected):
trigger(e)
assert_equal(e.trigger.tels_with_trigger, expected_tels)
assert_all_tel_keys(e, expected_tels)
assert_all_tel_keys(e, expected_tels, ignore={"dl0", "dl1", "dl2", "muon"})


def test_software_trigger_simtel_single_lsts():
Expand Down Expand Up @@ -164,7 +167,7 @@ def test_software_trigger_simtel_single_lsts():
trigger(e)
print(e.trigger.tels_with_trigger, expected_tels)
assert_equal(e.trigger.tels_with_trigger, expected_tels)
assert_all_tel_keys(e, expected_tels)
assert_all_tel_keys(e, expected_tels, ignore={"dl0", "dl1", "dl2", "muon"})


def test_software_trigger_simtel_process(tmp_path):
Expand Down

0 comments on commit b8181e7

Please sign in to comment.