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

Support optional arguments axis, dtype and out for numpy.cumsum #4624

Open
yujianll opened this issue Sep 27, 2019 · 16 comments
Open

Support optional arguments axis, dtype and out for numpy.cumsum #4624

yujianll opened this issue Sep 27, 2019 · 16 comments

Comments

@yujianll
Copy link

Reporting a bug

I somehow cannot use numpy.cumsum in no python mode.
Reproducer:

from numba import jit
import numpy as np

@jit(nopython=True)
def error():
    weights = np.ones((100, 100))
    np.cumsum(weights, 0, float, weights)

error()
@esc
Copy link
Member

esc commented Sep 27, 2019

@yujianll thanks for taking the time to report this and helping to improve Numba. As documented on:

https://numba.pydata.org/numba-doc/dev/reference/numpysupported.html

cumsum in Numba currently only supports the first argument. I.e. none of axis, dtype or out are implemented.

If you try the following it should work:

from numba import jit
import numpy as np

@jit(nopython=True)
def error():
    weights = np.ones((100, 100))
    np.cumsum(weights)

error()

@esc esc changed the title numpy.cumsum not working Support optional arguments axis, dtype and out for numpy.cumsum Sep 27, 2019
@esc esc changed the title Support optional arguments axis, dtype and out for numpy.cumsum Support optional arguments axis, dtype and out for numpy.cumsum Sep 27, 2019
@esc
Copy link
Member

esc commented Sep 27, 2019

I have rename the issues and labeled it as a feature request accordingly.

@esc
Copy link
Member

esc commented Sep 27, 2019

@yujianll if you need axis support immediately, I would suggest to implement it yourself for the given dimensionality in your case. Numba is great at optimizing for loops and a simple implementation should run in reasonable time.

@yujianll
Copy link
Author

@esc Thanks! Do you mean a for loop to each column of the array would be fast as well?

@esc
Copy link
Member

esc commented Sep 27, 2019

@yujianll hmmm, not sure, maybe with fortran order that would work well?

@yujianll
Copy link
Author

@esc OK, make sense! So convert the array to fortran order (numba supports np.asfortranarray), and then manipulate array on 0 axis?

@yujianll
Copy link
Author

@esc I cannot see this. But thanks!

@esc
Copy link
Member

esc commented Sep 28, 2019

@yujianll sorry, wrong link:

#4628

@yujianll
Copy link
Author

@esc Thanks!

@maxnoe
Copy link

maxnoe commented Mar 23, 2021

I also just ran into this, support for the axis keyword would be appreciated!

@AhmetCanSolak
Copy link

I would also appreciate axis keyword support

@ch3rn0v
Copy link

ch3rn0v commented Oct 29, 2021

+1 for axis support

@AhmetCanSolak
Copy link

I do not know the codebase in depth and how to implement this feature but if there can be some guidance I am more than happy to put work on this. @esc do you have any pointers about where to start?

@trevor-pope
Copy link

+1 for support on this

@sliemelela
Copy link

+1 for axis support

1 similar comment
@YuanJ-i
Copy link

YuanJ-i commented Sep 12, 2024

+1 for axis support

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

8 participants