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

Auto-conversion to NumPy arrays within a Numbafied function #509

Open
jpivarski opened this issue Nov 3, 2020 · 3 comments
Open

Auto-conversion to NumPy arrays within a Numbafied function #509

jpivarski opened this issue Nov 3, 2020 · 3 comments
Assignees
Labels
feature New feature or request

Comments

@jpivarski
Copy link
Member

jpivarski commented Nov 3, 2020

Inside a Numba-JITed function, users might want to call NumPy functions (np.*) on Awkward Arrays that happen to be 1D/simple/flat. Right now, they have to cast such an array with np.asarray and then call the NumPy function, which they don't have to do outside of Numba. And that's surprising. It may be possible to register Awkward Arrays (or just NumpyArrayType) as "array-like" in Numba, so that it does this conversion automatically.

@jpivarski jpivarski added the feature New feature or request label Nov 3, 2020
@jpivarski
Copy link
Member Author

This could go either way, "bug" or "feature," because it's highly expected, but I'm not certain how or how generally it can be implemented.

@jpivarski
Copy link
Member Author

@jpivarski
Copy link
Member Author

A few notes:

First, there's a @lower_cast decorator that might be what I need: https://numba.pydata.org/numba-doc/dev/extending/low-level.html#lower_cast

Secondly, there's an example of an ArrayCompatible in Numba's unit tests. The lowering of the __array__ method is here:

https://github.com/numba/numba/blob/13ece9b97e6f01f750e870347f231282325f60c3/numba/tests/pdlike_usecase.py#L180-L188

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants