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

Implement np.gradient #6302

Closed
holymonson opened this issue Oct 5, 2020 · 1 comment
Closed

Implement np.gradient #6302

holymonson opened this issue Oct 5, 2020 · 1 comment

Comments

@holymonson
Copy link

holymonson commented Oct 5, 2020

Feature request

Implement np.gradient, it mainly depends on np.diff.


A simplest overload:

@numba.extending.overload(np.gradient)
def np_gradient(f):
    def np_gradient_impl(f):
        out = np.empty_like(f, np.float64)
        out[1:-1] = (f[2:] - f[:-2]) / 2.0
        out[0] = f[1] - f[0]
        out[-1] = f[-1] - f[-2]
        return out

    return np_gradient_impl
@esc
Copy link
Member

esc commented Oct 5, 2020

@holymonson thanks for submitting this request to the Numba issue tracker. This is a duplicate of: #4074 so I will be closing this in favor of that PR. Feel free add some tests and submit the suggested overload as a PR.

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