Cythonize get_coinc_indices #5180
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This continues work in #5148 by Cythonizing the get_coinc_indices function. For now this is still draft, and I put it here to demonstrate how this might work (especially if anyone in the GRB team is interested in learning some Cython, it would be great to have more people with that knowledge).
Particular things that need doing
Standard information about the request
This is a: efficiency update
This change affects: PyGRB
This change changes: Core scientific code, but only optimization.
This change: has appropriate unit tests, follows style guidelines (See e.g. PEP8), has been proposed using the contribution guidelines
Motivation
#5148 has all the motivation. PyGRB can be slow in some cases. This function was written in "nice" python, but not "fast" python.
Contents
For the 2-detector case this is just finding duplicated values in 2 sorted arrays. There's a well known algorithm for that problem, and I implement it here.
Additional notes
Profile (for test case 2) with this PR. It's not as great as I would like, but the dominant cost of get_coinc_indexes remains outside of the Cython function (even though it's doing very little!)