Skip to content

speed up last_instance in tcm by precomputing keys and vectorizing#653

Merged
gipert merged 2 commits intomainfrom
tcm-perf
Feb 20, 2026
Merged

speed up last_instance in tcm by precomputing keys and vectorizing#653
gipert merged 2 commits intomainfrom
tcm-perf

Conversation

@gipert
Copy link
Member

@gipert gipert commented Feb 20, 2026

  • chore: add debug logging for tcm progress in generate_tcm_cols
  • perf: speed up last_instance in tcm by precomputing keys and vectorizing

gipert and others added 2 commits February 20, 2026 15:35
Co-authored-by: aider (gpt-5.2) <aider@aider.chat>
Co-authored-by: aider (gpt-5.2) <aider@aider.chat>
@codecov
Copy link

codecov bot commented Feb 20, 2026

Codecov Report

❌ Patch coverage is 93.75000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 52.56%. Comparing base (e26fd48) to head (c2f1eb6).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
src/pygama/evt/tcm.py 93.75% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #653      +/-   ##
==========================================
+ Coverage   52.51%   52.56%   +0.04%     
==========================================
  Files          60       60              
  Lines        8270     8274       +4     
==========================================
+ Hits         4343     4349       +6     
+ Misses       3927     3925       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@gipert gipert marked this pull request as ready for review February 20, 2026 15:06
@gipert gipert requested a review from Copilot February 20, 2026 15:06
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves the performance and observability of TCM generation in pygama.evt, focusing on speeding up the “last instance” computation during coincidence clustering and adding debug-level progress logging.

Changes:

  • Precompute and cache table_keys mapping helpers to support faster per-iteration processing.
  • Vectorize “last occurrence per table_key” computation using NumPy (searchsorted + maximum.at) instead of a per-hit Python loop.
  • Add debug logging summarizing TCM progress per iteration and remove some noisier debug statements.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@gipert gipert merged commit a22f667 into main Feb 20, 2026
19 checks passed
@gipert gipert deleted the tcm-perf branch February 20, 2026 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants