Skip to content

Commit

Permalink
Merge pull request #2418 from LukasBeiske/no_hidden_attr
Browse files Browse the repository at this point in the history
Do not use hidden attribute `reconstructor._models` in `ctapipe-apply-models`
  • Loading branch information
maxnoe authored Oct 23, 2023
2 parents a987cc8 + 92cba52 commit 4b7f8e0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
13 changes: 7 additions & 6 deletions ctapipe/tools/apply_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,13 @@ def _apply(self, reconstructor, tel_tables, start, stop):
for tel_id, table in tel_tables.items():
tel = self.loader.subarray.tel[tel_id]

if tel not in reconstructor._models:
if len(table) == 0:
self.log.info("No events for telescope %d", tel_id)
continue

try:
predictions = reconstructor.predict_table(tel, table)
except KeyError:
self.log.warning(
"No model in %s for telescope type %s, skipping tel %d",
reconstructor,
Expand All @@ -186,11 +192,6 @@ def _apply(self, reconstructor, tel_tables, start, stop):
)
continue

if len(table) == 0:
self.log.info("No events for telescope %d", tel_id)
continue

predictions = reconstructor.predict_table(tel, table)
for prop, prediction_table in predictions.items():
# copy/overwrite columns into full feature table
new_columns = prediction_table.colnames
Expand Down
1 change: 1 addition & 0 deletions docs/changes/2418.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Do not use a hidden attribute of ``SKLearnReconstructor`` in ``ctapipe-apply-models``.

0 comments on commit 4b7f8e0

Please sign in to comment.