Skip to content

Commit

Permalink
Fix argsort inside numba.jit using kind='mergesort' (#1176)
Browse files Browse the repository at this point in the history
* Fix argsort inside numba.jit using kind='mergesort'

See https://numba.readthedocs.io/en/stable/reference/numpysupported.html#other-methods

* Bump merged_s2s version

* Provide `sort_kind` as an argument of get_merge_instructions
  • Loading branch information
dachengx committed May 4, 2023
1 parent 9f71df5 commit 306d98e
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions straxen/plugins/merged_s2s/merged_s2s.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class MergedS2s(strax.OverlapWindowPlugin):
Merge together peaklets if peak finding favours that they would
form a single peak instead.
"""
__version__ = '1.0.0'
__version__ = '1.0.1'

depends_on = ('peaklets', 'peaklet_classification', 'lone_hits')
data_kind = 'merged_s2s'
Expand Down Expand Up @@ -133,7 +133,8 @@ def compute(self, peaklets, lone_hits):
@numba.njit(cache=True, nogil=True)
def get_merge_instructions(
peaklet_starts, peaklet_ends, areas, types,
gap_thresholds, max_duration, max_gap, max_area):
gap_thresholds, max_duration, max_gap, max_area,
sort_kind='mergesort'):
"""
Finding the group of peaklets to merge. To do this start with the
smallest gaps and keep merging until the new, merged S2 has such a
Expand All @@ -149,7 +150,7 @@ def get_merge_instructions(
peaklet_start_index = np.arange(len(peaklet_starts))
peaklet_end_index = np.arange(len(peaklet_starts))

for gap_i in np.argsort(peaklet_gaps):
for gap_i in np.argsort(peaklet_gaps, kind=sort_kind):
start_idx = peaklet_start_index[gap_i]
inclusive_end_idx = peaklet_end_index[gap_i + 1]
sum_area = np.sum(areas[start_idx:inclusive_end_idx + 1])
Expand Down

0 comments on commit 306d98e

Please sign in to comment.