Re: [Numpy-discussion] Added atleast_nd, request for clarification/cleanup of atleast_3d

2016-10-27 Thread Joseph Fox-Rabinovitz
Hi, I would like to revitalize the discussion on including PR#7804 (atleast_nd function) at Stephan Hoyer's request. atleast_nd has come up as a convenient workaround for #8206 (adding padding options to diff) to be able to do broadcasting with the required dimensions reversed. Regards,

Re: [Numpy-discussion] Added atleast_nd, request for clarification/cleanup of atleast_3d

2016-07-11 Thread Joseph Fox-Rabinovitz
I would like to follow up on my original PR (7804). While there appears to be some debate as to whether the PR is numpy material to begin with, there do not appear to be any technical issues with it. To make the decision more straightforward, I factored out the non-controversial bug fixes to

Re: [Numpy-discussion] Added atleast_nd, request for clarification/cleanup of atleast_3d

2016-07-07 Thread Joseph Fox-Rabinovitz
On Thu, Jul 7, 2016 at 4:34 AM, Sebastian Berg wrote: > On Mi, 2016-07-06 at 15:30 -0400, Benjamin Root wrote: >> I don't see how one could define a spec that would take an arbitrary >> array of indices at which to place new dimensions. By definition, you >> > > You

Re: [Numpy-discussion] Added atleast_nd, request for clarification/cleanup of atleast_3d

2016-07-07 Thread Sebastian Berg
On Mi, 2016-07-06 at 15:30 -0400, Benjamin Root wrote: > I don't see how one could define a spec that would take an arbitrary > array of indices at which to place new dimensions. By definition, you > You just give a reordered range, so that (1, 0, 2) would be the current 3D version. If 1D, fill

Re: [Numpy-discussion] Added atleast_nd, request for clarification/cleanup of atleast_3d

2016-07-06 Thread Nathaniel Smith
On Wed, Jul 6, 2016 at 1:56 PM, Ralf Gommers wrote: > > > On Wed, Jul 6, 2016 at 6:26 PM, Nathaniel Smith wrote: > >> On Jul 5, 2016 11:21 PM, "Ralf Gommers" wrote: >> > >> > >> > >> > On Wed, Jul 6, 2016 at 7:06 AM, Nathaniel

Re: [Numpy-discussion] Added atleast_nd, request for clarification/cleanup of atleast_3d

2016-07-06 Thread David
Joseph Fox-Rabinovitz gmail.com> writes: > > On Wed, Jul 6, 2016 at 2:57 PM, Eric Firing hawaii.edu> wrote: > > On 2016/07/06 8:25 AM, Benjamin Root wrote: > >> > >> I wouldn't have the keyword be "where", as that collides with the notion > >> of "where" elsewhere in numpy. > > > > > >

Re: [Numpy-discussion] Added atleast_nd, request for clarification/cleanup of atleast_3d

2016-07-06 Thread Joseph Fox-Rabinovitz
On Wed, Jul 6, 2016 at 4:56 PM, Ralf Gommers wrote: > > > On Wed, Jul 6, 2016 at 6:26 PM, Nathaniel Smith wrote: > >> On Jul 5, 2016 11:21 PM, "Ralf Gommers" wrote: >> > >> > >> > >> > On Wed, Jul 6, 2016 at 7:06 AM, Nathaniel

Re: [Numpy-discussion] Added atleast_nd, request for clarification/cleanup of atleast_3d

2016-07-06 Thread Ralf Gommers
On Wed, Jul 6, 2016 at 6:26 PM, Nathaniel Smith wrote: On Jul 5, 2016 11:21 PM, "Ralf Gommers" wrote: > > > > > > > > On Wed, Jul 6, 2016 at 7:06 AM, Nathaniel Smith wrote: > > > >> On Jul 5, 2016 9:09 PM, "Joseph Fox-Rabinovitz" < >

Re: [Numpy-discussion] Added atleast_nd, request for clarification/cleanup of atleast_3d

2016-07-06 Thread Benjamin Root
I don't see how one could define a spec that would take an arbitrary array of indices at which to place new dimensions. By definition, you don't know how many dimensions are going to be added. If you knew, then you wouldn't be calling this function. I can only imagine simple rules such as 'left'

Re: [Numpy-discussion] Added atleast_nd, request for clarification/cleanup of atleast_3d

2016-07-06 Thread Joseph Fox-Rabinovitz
On Wed, Jul 6, 2016 at 2:57 PM, Eric Firing wrote: > On 2016/07/06 8:25 AM, Benjamin Root wrote: >> >> I wouldn't have the keyword be "where", as that collides with the notion >> of "where" elsewhere in numpy. > > > Agreed. Maybe "side"? I have tentatively changed it to

Re: [Numpy-discussion] Added atleast_nd, request for clarification/cleanup of atleast_3d

2016-07-06 Thread Joseph Fox-Rabinovitz
On Wed, Jul 6, 2016 at 3:01 PM, Juan Nunez-Iglesias wrote: > at_leastnd would be useful for nd image processing in a very analogous way > to how at_least2d is used by scikit-image, assuming it prepends. The > at_least3d choice is baffling, seems analogous to the 0.5-based

Re: [Numpy-discussion] Added atleast_nd, request for clarification/cleanup of atleast_3d

2016-07-06 Thread Juan Nunez-Iglesias
at_leastnd would be useful for nd image processing in a very analogous way to how at_least2d is used by scikit-image, assuming it prepends. The at_least3d choice is baffling, seems analogous to the 0.5-based indexing presented at PyCon, and should be "fun" to deprecate. =P On 6 July 2016 at

Re: [Numpy-discussion] Added atleast_nd, request for clarification/cleanup of atleast_3d

2016-07-06 Thread Eric Firing
On 2016/07/06 8:25 AM, Benjamin Root wrote: I wouldn't have the keyword be "where", as that collides with the notion of "where" elsewhere in numpy. Agreed. Maybe "side"? (I find atleast_1d and atleast_2d to be very helpful for handling inputs, as Ben noted; I'm skeptical as to the value of

Re: [Numpy-discussion] Added atleast_nd, request for clarification/cleanup of atleast_3d

2016-07-06 Thread Joseph Fox-Rabinovitz
Agreed. I was originally going with "side", but I want something that can be changed to accepting arbitrary specs without changing the word. Perhaps "pos"? I am open to suggestion. -Joe On Wed, Jul 6, 2016 at 2:25 PM, Benjamin Root wrote: > I wouldn't have the keyword

Re: [Numpy-discussion] Added atleast_nd, request for clarification/cleanup of atleast_3d

2016-07-06 Thread Benjamin Root
I wouldn't have the keyword be "where", as that collides with the notion of "where" elsewhere in numpy. On Wed, Jul 6, 2016 at 2:21 PM, Joseph Fox-Rabinovitz < jfoxrabinov...@gmail.com> wrote: > I still think this function is useful. I have made a change so that it > only accepts one array, as

Re: [Numpy-discussion] Added atleast_nd, request for clarification/cleanup of atleast_3d

2016-07-06 Thread Joseph Fox-Rabinovitz
I still think this function is useful. I have made a change so that it only accepts one array, as Marten suggested, making the API much cleaner than that of its siblings. The side on which the new dimensions will be added is configurable via the `where` parameter, which currently accepts 'before'

Re: [Numpy-discussion] Added atleast_nd, request for clarification/cleanup of atleast_3d

2016-07-06 Thread Stephan Hoyer
On Tue, Jul 5, 2016 at 10:06 PM, Nathaniel Smith wrote: > I don't know how typical I am in this. But it does make me wonder if the > atleast_* functions act as an attractive nuisance, where new users take > their presence as an implicit recommendation that they are actually a >

Re: [Numpy-discussion] Added atleast_nd, request for clarification/cleanup of atleast_3d

2016-07-06 Thread Joseph Fox-Rabinovitz
I was using "reduce" in an abstract sense. I put in a 4D array in, get a 1-3D array out, depending on some other parameters (not strictly just by reduction, although that is the net effect). The placement of the dimensions is irrelevant, I just need to make the output 4D again for further

Re: [Numpy-discussion] Added atleast_nd, request for clarification/cleanup of atleast_3d

2016-07-06 Thread Nathaniel Smith
On Jul 6, 2016 6:12 AM, "Joseph Fox-Rabinovitz" wrote: > > I can add a keyword-only argument that lets you put the new dims > before or after the existing ones. I am not sure how to specify > arbitrary patterns for the new dimensions, but that should take care > of most

Re: [Numpy-discussion] Added atleast_nd, request for clarification/cleanup of atleast_3d

2016-07-06 Thread Nathaniel Smith
On Jul 5, 2016 11:21 PM, "Ralf Gommers" wrote: > > > > On Wed, Jul 6, 2016 at 7:06 AM, Nathaniel Smith wrote: > >> On Jul 5, 2016 9:09 PM, "Joseph Fox-Rabinovitz" wrote: >> > >> > Hi, >> > >> > I have generalized np.atleast_1d,

Re: [Numpy-discussion] Added atleast_nd, request for clarification/cleanup of atleast_3d

2016-07-06 Thread Sebastian Berg
On Mi, 2016-07-06 at 10:22 -0400, Marten van Kerkwijk wrote: > Hi All, > > I'm with Nathaniel here, in that I don't really see the point of > these routines in the first place: broadcasting takes care of many of > the initial use cases one might think of, and others are generally > not all that

Re: [Numpy-discussion] Added atleast_nd, request for clarification/cleanup of atleast_3d

2016-07-06 Thread Juan Nunez-Iglesias
We use np.at_least2d extensively in scikit-image, and I also use it in a *lot* of my own code now that scikit-learn stopped accepting 1D arrays as feature vectors. > what is the advantage of np.at_leastnd` over `np.array(a, copy=False, ndim=n)` Readability, clearly. My only concern is the

Re: [Numpy-discussion] Added atleast_nd, request for clarification/cleanup of atleast_3d

2016-07-06 Thread Marten van Kerkwijk
Hi All, I'm with Nathaniel here, in that I don't really see the point of these routines in the first place: broadcasting takes care of many of the initial use cases one might think of, and others are generally not all that well served by them: the examples from scipy to me do not really support

Re: [Numpy-discussion] Added atleast_nd, request for clarification/cleanup of atleast_3d

2016-07-06 Thread Benjamin Root
While atleast_1d/2d/3d predates my involvement in numpy, I am probably partly to blame for popularizing them as I helped to fix them up a fair amount. I wouldn't call its use "guessing". Rather, I would treat them as useful input sanitizers. If your function is going to be doing 2d indexing on an

Re: [Numpy-discussion] Added atleast_nd, request for clarification/cleanup of atleast_3d

2016-07-06 Thread Joseph Fox-Rabinovitz
I can add a keyword-only argument that lets you put the new dims before or after the existing ones. I am not sure how to specify arbitrary patterns for the new dimensions, but that should take care of most use cases. The use case that motivated this function in the first place is that I am doing

Re: [Numpy-discussion] Added atleast_nd, request for clarification/cleanup of atleast_3d

2016-07-06 Thread josef . pktd
On Wed, Jul 6, 2016 at 3:29 AM, wrote: > > > On Wed, Jul 6, 2016 at 2:21 AM, Ralf Gommers > wrote: > >> >> >> On Wed, Jul 6, 2016 at 7:06 AM, Nathaniel Smith wrote: >> >> On Jul 5, 2016 9:09 PM, "Joseph Fox-Rabinovitz"

Re: [Numpy-discussion] Added atleast_nd, request for clarification/cleanup of atleast_3d

2016-07-06 Thread josef . pktd
On Wed, Jul 6, 2016 at 2:21 AM, Ralf Gommers wrote: > > > On Wed, Jul 6, 2016 at 7:06 AM, Nathaniel Smith wrote: > > On Jul 5, 2016 9:09 PM, "Joseph Fox-Rabinovitz" >> wrote: >> > >> > Hi, >> > >> > I have generalized

Re: [Numpy-discussion] Added atleast_nd, request for clarification/cleanup of atleast_3d

2016-07-06 Thread Ralf Gommers
On Wed, Jul 6, 2016 at 7:06 AM, Nathaniel Smith wrote: On Jul 5, 2016 9:09 PM, "Joseph Fox-Rabinovitz" > wrote: > > > > Hi, > > > > I have generalized np.atleast_1d, np.atleast_2d, np.atleast_3d with a > > function np.atleast_nd in PR#7804 > >

Re: [Numpy-discussion] Added atleast_nd, request for clarification/cleanup of atleast_3d

2016-07-05 Thread Nathaniel Smith
On Jul 5, 2016 9:09 PM, "Joseph Fox-Rabinovitz" wrote: > > Hi, > > I have generalized np.atleast_1d, np.atleast_2d, np.atleast_3d with a > function np.atleast_nd in PR#7804 > (https://github.com/numpy/numpy/pull/7804). > > As a result of this PR, I have a couple of