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

Check if all argsort use mergesort #916

Open
dachengx opened this issue Oct 19, 2024 · 2 comments
Open

Check if all argsort use mergesort #916

dachengx opened this issue Oct 19, 2024 · 2 comments
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@dachengx
Copy link
Collaborator

dachengx commented Oct 19, 2024

We must ensure that the numpy.argsort gives deterministic results, as well as in https://github.com/XENONnT/straxen.

This issue is closely related to XENONnT/straxen#1176.

@dachengx dachengx added enhancement New feature or request good first issue Good for newcomers labels Oct 19, 2024
@yuema137
Copy link
Collaborator

I checked the source code of numpy and confirmed that argsort is a more fundamental method while sort is a higher-level API based on it. The algorithms are defined in cpp files like https://github.com/numpy/numpy/blob/main/numpy/_core/src/npysort/mergesort.cpp

With the mergesort method, the relative order is preserved:
https://github.com/numpy/numpy/blob/020e78cc3a4c7283bbe83290f0be5de3bc842f07/numpy/_core/src/npysort/mergesort.cpp#L67

So as long as we use mergesort I think we are good here.

@dachengx
Copy link
Collaborator Author

dachengx commented Oct 23, 2024

So as long as we use mergesort I think we are good here.

Yes! So would you please check whether we always use mergesort?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants