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

Bug of argsort with arrays of size 3 #9669

Closed
juanmabelda opened this issue Sep 8, 2017 · 3 comments
Closed

Bug of argsort with arrays of size 3 #9669

juanmabelda opened this issue Sep 8, 2017 · 3 comments

Comments

@juanmabelda
Copy link

It seems as argsort has a bug for dimension 3 arrays in an specific order.

For instance if I wrote

import numpy as np

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

The returned value is:
array([2, 0, 1])

If I change the order of the numbers (i.e. [1,2,3]) the function works well.

I have cross checked the malfunction in python 2.7.6 with numpy 1.8.2 and python 3.5.2 with numpy version 1.11.1 both in windows and linux.

@seberg
Copy link
Member

seberg commented Sep 8, 2017

And why do you expect something else? Seems like the right answer to me:

In [5]: np.array([2,3,1])[np.argsort(np.array([2,3,1]))]
Out[5]: array([1, 2, 3])

In [6]: np.argsort(np.array([2,3,1]))
Out[6]: array([2, 0, 1])

EDIT: Copied the second thing wrong, fixed

@seberg seberg closed this as completed Sep 8, 2017
@juanmabelda
Copy link
Author

'got it. Sorry. I misanderstood the help documentation.

@eric-wieser
Copy link
Member

Duplicate of #8757

@eric-wieser eric-wieser marked this as a duplicate of #8757 Oct 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants