Thanks to visit codestin.com
Credit goes to github.com

Skip to content

BUG: argsort return the wrong order!!!!!!!!!! #22402

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

Closed
IkeYang opened this issue Oct 7, 2022 · 3 comments
Closed

BUG: argsort return the wrong order!!!!!!!!!! #22402

IkeYang opened this issue Oct 7, 2022 · 3 comments
Labels
33 - Question Question about NumPy usage or development

Comments

@IkeYang
Copy link

IkeYang commented Oct 7, 2022

Describe the issue:

numpy version 1.17.0
python version 3.6.9
windows 10

the argsort function returns the wrong result.

np.argsort(np.array([3, 1, 2]))
array([1, 2, 0], dtype=int64)

Reproduce the code example:

import numpy as np

print(np.argsort(np.array([3, 1, 2])))

Error message:

No response

NumPy/Python version information:

numpy version 1.17.0
python version 3.6.9
windows 10

Context for the issue:

No response

@seberg seberg added 33 - Question Question about NumPy usage or development and removed 00 - Bug labels Oct 7, 2022
@mattip
Copy link
Member

mattip commented Oct 7, 2022

Why is this wrong? The way to sort [3, 1, 2] is to put 1 first (index 1), then 2 (index 2), then 3 (index 0), so the correct answer is [1, 2, 0]. What answer did you expect and why? Maybe you are confusing np.argsort with np.sort?

@rkern
Copy link
Member

rkern commented Oct 7, 2022

argsort's behavior is subtle, and many people expect it to do something different than what it is documented to do (see #8757 and other closed issues). But it is behaving as designed and documented.

@rkern rkern closed this as completed Oct 7, 2022
@IkeYang
Copy link
Author

IkeYang commented Oct 8, 2022

I am so sorry to misunderstand the code and the documents. Sorry for that.

@IkeYang IkeYang closed this as completed Oct 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
33 - Question Question about NumPy usage or development
Projects
None yet
Development

No branches or pull requests

4 participants