[Numpy-discussion] Changed behavior of np.gradient

Matthew Brett matthew.brett at gmail.com
Thu Oct 16 22:25:41 EDT 2014


Hi,

On Thu, Oct 16, 2014 at 6:38 PM, Benjamin Root <ben.root at ou.edu> wrote:
> That isn't what I meant. Higher order doesn't "necessarily" mean more
> accurate. The results simply have different properties. The user needs to
> choose the differentiation order that they need. One interesting effect in
> data assimilation/modeling is that even-order differentiation can often have
> detrimental effects while higher odd order differentiation are better, but
> it is highly dependent upon the model.
>
> This change in gradient broke a unit test in matplotlib (for a new feature,
> so it isn't *that* critical). We didn't notice it at first because we
> weren't testing numpy 1.9 at the time. I want the feature (I have need for
> it elsewhere), but I don't want the change in default behavior.

I think it would be a bad idea to revert now.

I suspect, if you revert, then a lot of other code will assume the <
1.9.0, >= 1.9.1  behavior.  In that case, the code will work as
expected most of the time, except when combined with 1.9.0, which
could be seriously surprising, and often missed.   If you keep the new
behavior, then it will be clearer that other code will have to adapt
to this change >= 1.9.0 - surprise, but predictable surprise, if you
see what I mean...

Matthew



More information about the NumPy-Discussion mailing list