Re: [Numpy-discussion] padding options for diff

2016-10-28 Thread Marten van Kerkwijk
Matthew has made what looks like a very nice implementation of padding in np.diff in https://github.com/numpy/numpy/pull/8206. I raised two general questions about desired behaviour there that Matthew thought we should put out on the mailiing list as well. This indeed seemed a good opportunity to

Re: [Numpy-discussion] padding options for diff

2016-10-26 Thread Peter Creasey
> Date: Wed, 26 Oct 2016 16:18:05 -0400 > From: Matthew Harrigan > > Would it be preferable to have to_begin='first' as an option under the > existing kwarg to avoid overlapping? > >> if keep_left: >> if to_begin is None: >> to_begin = np.take(a, [0],

Re: [Numpy-discussion] padding options for diff

2016-10-26 Thread Matthew Harrigan
Would it be preferable to have to_begin='first' as an option under the existing kwarg to avoid overlapping? On Wed, Oct 26, 2016 at 3:35 PM, Peter Creasey < p.e.creasey...@googlemail.com> wrote: > > Date: Wed, 26 Oct 2016 09:05:41 -0400 > > From: Matthew Harrigan > >

Re: [Numpy-discussion] padding options for diff

2016-10-26 Thread Peter Creasey
> Date: Wed, 26 Oct 2016 09:05:41 -0400 > From: Matthew Harrigan > > np.cumsum(np.diff(x, to_begin=x.take([0], axis=axis), axis=axis), axis=axis) > > That's certainly not going to win any beauty contests. The 1d case is > clean though: > > np.cumsum(np.diff(x,

Re: [Numpy-discussion] padding options for diff

2016-10-26 Thread Matthew Harrigan
The inverse of cumsum is actually a little more unweildy since you can't drop a dimension with take. This returns the original array (numerical caveats aside): np.cumsum(np.diff(x, to_begin=x.take([0], axis=axis), axis=axis), axis=axis) That's certainly not going to win any beauty contests.

Re: [Numpy-discussion] padding options for diff

2016-10-25 Thread Peter Creasey
> Date: Mon, 24 Oct 2016 08:44:46 -0400 > From: Matthew Harrigan > > I posted a pull request which > adds optional padding kwargs "to_begin" and "to_end" to diff. Those > options are based on what's available in ediff1d. It

Re: [Numpy-discussion] padding options for diff

2016-10-24 Thread Stephan Hoyer
This looks like a welcome addition in functionality! It will be nice to be able to finally (soft) deprecate ediff1d. On Mon, Oct 24, 2016 at 5:44 AM, Matthew Harrigan < harrigan.matt...@gmail.com> wrote: > I posted a pull request which > adds optional

[Numpy-discussion] padding options for diff

2016-10-24 Thread Matthew Harrigan
I posted a pull request which adds optional padding kwargs "to_begin" and "to_end" to diff. Those options are based on what's available in ediff1d. It closes this issue