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

Skip to content

BUG: numpy.argsort #22020

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
MrTheyosyos opened this issue Jul 21, 2022 · 1 comment
Closed

BUG: numpy.argsort #22020

MrTheyosyos opened this issue Jul 21, 2022 · 1 comment

Comments

@MrTheyosyos
Copy link

Describe the issue:

wrong output.

Reproduce the code example:

import numpy as np

mat = np.array([[7,5,1,6],[1,9,8,2],[2,7,3,8]])

mat
>>array([[7, 5, 1, 6],
         [1, 9, 8, 2],
         [2, 7, 3, 8]])

np.argsort(mat, axis=1)
>>array([[2, 1, 3, 0],
         [0, 3, 2, 1],
         [0, 2, 1, 3]])


# expected:
array([[3, 1, 0, 2],
       [0, 3, 2, 1],
       [0, 2, 1, 3]])

Error message:

No response

NumPy/Python version information:

Name: numpy
Version: 1.22.3
Summary: NumPy is the fundamental package for array computing with Python.
Home-page: https://www.numpy.org
Author: Travis E. Oliphant et al.
Author-email:
License: BSD

@WarrenWeckesser
Copy link
Member

This is a duplicate of #8757 (and several other issues reporting the same "problem").

@MrTheyosyos, argsort does not rank the values. For ranking, you can use a function such as scipy.stats.rankdata.

@WarrenWeckesser WarrenWeckesser closed this as not planned Won't fix, can't repro, duplicate, stale Jul 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants