-
-
Notifications
You must be signed in to change notification settings - Fork 11k
BUG: Fixes #5184 gradient calculation behavior at boundaries #5186
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
BUG: Fixes #5184 gradient calculation behavior at boundaries #5186
Conversation
@@ -899,6 +899,9 @@ def gradient(f, *varargs): | |||
`*varargs` : scalars | |||
0, 1, or N scalars specifying the sample distances in each direction, | |||
that is: `dx`, `dy`, `dz`, ... The default distance is 1. | |||
edge_order : int, optional | |||
Default: 1. If 2, gradient is calculated using second order | |||
accurate one-sides (forward or backwards) differences at the boundaries. |
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.
needs .. versionadded:: 1.9.1
see e.g. np.outer for an example of the formatting
possible also add keyword-only to the type area
Just a couple of nitpicks. @juliantaylor Do you want to make specific mention of this in the 1.9.1 release notes? |
* Previous expected behavior was that the gradient is computed using central differences in the interior and first differences at the boundaries. * gradient was updated in v1.9.0 so that second-order accurate calculations are done at the boundaries, but this breaks expected behavior with old code, so `edge_order` keyword (Default: 1) is added to specify whether first or second order calculations at the boundaries should be used. * Since the second argument is *varargs, in order to maintain compatibility with old code and compatibility with python 2.6 & 2.7, **kwargs is used, and all kwargs that are not `edge_order` raise an error, listing the offending kwargs. * Tests and documentation updated to reflect this change. * Added `.. versionadded:: 1.9.1` to the new optional kwarg `edge_order` documentation, and specified supported `edge_order` kwarg values. * Clarified documentation for `varargs`. * Made indentation in docstring consistent with other docstring styles. * Examples corrected
I went back and checked all the examples to be sure |
…word BUG: Fixes #5184 gradient calculation behavior at boundaries
Merged, thanks. Looking at the documentation, ISTM that more explanation of which axis correspond to |
no rebase? |
I made sure that I rebased against master before the last change was pushed |
Oops, I think Julian means
Which makes it better for backporting. My bad. |
Previous expected behavior was that the gradient is computed using central differences in the interior and first differences at the boundaries.
gradient was updated in v1.9.0 so that second-order accurate calculations are done at the boundaries, but this breaks expected behavior with old code, so
edge_order
keyword (Default: 1) is added to specify whether first or second order calculations at the boundaries should be used.Tests and documentation updated to reflect this change.