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

np.argsort cannot work for matrix more than 1D #4636

Closed
isaac-you opened this issue Sep 30, 2019 · 5 comments
Closed

np.argsort cannot work for matrix more than 1D #4636

isaac-you opened this issue Sep 30, 2019 · 5 comments

Comments

@isaac-you
Copy link

import numpy as np
from numba import jit 

@jit(nopython=True)
def f1(m1):
    return np.argsort(np.argsort(m1)) + 1.0

m1 = np.random.randint(10,size=(5,3))

f1(m1)

TypingError: Failed in nopython mode pipeline (step: nopython frontend)
Invalid use of Function(<function argsort at 0x7f5abc2cce18>) with argument(s) of type(s): (array(int64, 2d, C))
 * parameterized
In definition 0:
    All templates rejected with literals.
In definition 1:
    All templates rejected without literals.
This error is usually caused by passing an argument of a type that is unsupported by the named function.
[1] During: resolving callee type: Function(<function argsort at 0x7f5abc2cce18>)
[2] During: typing of call at <ipython-input-4-0ce306685c59> (3)


File "<ipython-input-4-0ce306685c59>", line 3:
def f1(m1):
    return np.argsort(np.argsort(m1)) + 1.0
    ^

This is not usually a problem with Numba itself but instead often caused by
the use of unsupported features or an issue in resolving types.

np.version:'1.17.2'
numba.version:'0.45.1'

@esc
Copy link
Member

esc commented Sep 30, 2019

@isaac-you thanks for reporting this. I can confirm that this doesn't work and have converted the issue into a feature-request.

@EPronovost
Copy link
Contributor

I've started working on this. I'm most of the way done of an implementation that works for IntegerLiteral axis arguments. From there I plan to extend it to support a limited range of Integer arguments (similar to np.sum). I'll put up a PR within a few days.

@esc
Copy link
Member

esc commented Nov 11, 2019

@EPronovost 👍

@ucasiggcas
Copy link

hi,could you help me ?
#6285

@stuartarchibald
Copy link
Contributor

Closing as duplicate of #4479.

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

5 participants