Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

Merged
merged 1 commit into from
Oct 16, 2014
Merged

BUG: Fixes #5184 gradient calculation behavior at boundaries #5186

merged 1 commit into from
Oct 16, 2014

Conversation

pseudocubic
Copy link

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.

@@ -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.
Copy link
Contributor

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

@charris
Copy link
Member

charris commented Oct 16, 2014

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
@pseudocubic
Copy link
Author

I went back and checked all the examples to be sure

charris added a commit that referenced this pull request Oct 16, 2014
…word

BUG: Fixes #5184 gradient calculation behavior at boundaries
@charris charris merged commit 4c0747d into numpy:master Oct 16, 2014
@charris
Copy link
Member

charris commented Oct 16, 2014

Merged, thanks. Looking at the documentation, ISTM that more explanation of which axis correspond to dx, dy, dz would be helpful.

@juliantaylor
Copy link
Contributor

no rebase?

@pseudocubic
Copy link
Author

I made sure that I rebased against master before the last change was pushed

@pseudocubic pseudocubic deleted the gradient-boundary-order-keyword branch October 16, 2014 17:22
@charris
Copy link
Member

charris commented Oct 16, 2014

Oops, I think Julian means

git rebase --onto $(git merge-base master maintenance/1.9.x) HEAD^

Which makes it better for backporting. My bad.

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

Successfully merging this pull request may close these issues.

3 participants