Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix argsort inside numba.jit using kind='mergesort' #721

Merged
merged 2 commits into from May 4, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion strax/processing/general.py
Expand Up @@ -49,7 +49,7 @@ def _sort_by_time_and_channel(x, channel, max_channel_plus_one):
# I couldn't get fast argsort on multiple keys to work in numba
# So, let's make a single key...
sort_key = (x['time'] - x['time'].min()) * max_channel_plus_one + channel
sort_i = np.argsort(sort_key)
sort_i = np.argsort(sort_key, kind='mergesort')
return x[sort_i]


Expand Down
2 changes: 1 addition & 1 deletion strax/processing/statistics.py
Expand Up @@ -40,7 +40,7 @@ def highest_density_region(data, fractions_desired, only_upper_part=False, _buff
'with a total probability of less-equal 0.')

# Need an index which sorted by amplitude
max_to_min = np.argsort(data)[::-1]
max_to_min = np.argsort(data, kind='mergesort')[::-1]

lowest_sample_seen = np.inf
for j in range(1, len(data)):
Expand Down
2 changes: 1 addition & 1 deletion strax/run_selection.py
Expand Up @@ -306,7 +306,7 @@ def define_run(self: strax.Context,
if isinstance(data, (pd.DataFrame, np.ndarray)):
if isinstance(data, np.ndarray):
data = pd.DataFrame.from_records(data)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is just to remove an unused line.


# strax.endtime does not work with DataFrames due to numba
if 'endtime' in data.columns:
end = data['endtime']
Expand Down
2 changes: 1 addition & 1 deletion strax/utils.py
Expand Up @@ -543,7 +543,7 @@ def multi_run(exec_function, run_ids, *args,
if throw_away_result:
continue
result = f.result()

# Append the run id column
if add_run_id_field:
ids = np.array([_run_id] * len(result),
Expand Down