-
Notifications
You must be signed in to change notification settings - Fork 23
add gradient function #503
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
Conversation
@@ -294,6 +294,27 @@ cpdef dparray dpnp_fmod(dparray x1, dparray x2): | |||
return call_fptr_2in_1out(DPNP_FN_FMOD, x1, x2, x1.shape) | |||
|
|||
|
|||
cpdef dparray dpnp_gradient(dparray y1, int dx=1): | |||
|
|||
len = y1.size |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
len
is built-in name. Let's rename the variable, e.g. size
.
dpnp/dpnp_iface_mathematical.py
Outdated
if not use_origin_backend(y1) and not kwargs: | ||
if not isinstance(y1, dparray): | ||
pass | ||
elif len(varargs) != 0 and not isinstance(varargs[0], int): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if len(varargs) = 2 and varargs[0] = 2
? Don't we need to fallback to numpy
in this case?
@pytest.mark.parametrize("array", [[2, 3, 6, 8, 4, 9], | ||
[3., 4., 7.5, 9.], | ||
[2, 6, 8, 10]]) | ||
def test_gradient_y1(self, array): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both tests are named the same.
|
||
result._setitem_scalar(size - 1, cur) | ||
|
||
for i in range(1, len - 1): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for i in range(1, len - 1): | |
for i in range(1, size-1): |
Could you please rebase on master? |
error in tests:
|
No description provided.