Re: [Numpy-discussion] Style for pad implementation in 'pad' namespace or functions under np.lib

2012-04-03 Thread Nathaniel Smith
On Mon, Apr 2, 2012 at 7:14 PM, Tim Cera t...@cerazone.net wrote: I think the suggestion is pad(a, 5, mode='mean'), which would be consistent with common numpy signatures. The mode keyword should probably have a default, something commonly used. I'd suggest 'mean', Nathaniel suggests 'zero',

Re: [Numpy-discussion] Style for pad implementation in 'pad' namespace or functions under np.lib

2012-04-02 Thread Travis Oliphant
The idea of using constants instead of strings throughout NumPy is an interesting one, but should be pushed to another thread and not hold up this particular PR. I like the suggestion of Nathaniel. Let's get the PR committed with a single-function interface. I like having the array as the

Re: [Numpy-discussion] Style for pad implementation in 'pad' namespace or functions under np.lib

2012-04-02 Thread Tim Cera
On Mon, Apr 2, 2012 at 12:09 PM, Travis Oliphant tra...@continuum.iowrote: The idea of using constants instead of strings throughout NumPy is an interesting one, but should be pushed to another thread and not hold up this particular PR. I like the suggestion of Nathaniel. Let's get the PR

Re: [Numpy-discussion] Style for pad implementation in 'pad' namespace or functions under np.lib

2012-04-02 Thread Charles R Harris
On Mon, Apr 2, 2012 at 10:36 AM, Tim Cera t...@cerazone.net wrote: On Mon, Apr 2, 2012 at 12:09 PM, Travis Oliphant tra...@continuum.iowrote: The idea of using constants instead of strings throughout NumPy is an interesting one, but should be pushed to another thread and not hold up this

Re: [Numpy-discussion] Style for pad implementation in 'pad' namespace or functions under np.lib

2012-04-02 Thread Travis Oliphant
I like the strings, maybe that is not the best, but yes I would like to defer that discussion. Having the string representation does allow 'pad()' to make some checks on inputs to the built in functions. About whether to have pad('mean', a, 5) or pad(a, 'mean', 5) - I don't care. It

Re: [Numpy-discussion] Style for pad implementation in 'pad' namespace or functions under np.lib

2012-04-02 Thread Tim Cera
I think the suggestion is pad(a, 5, mode='mean'), which would be consistent with common numpy signatures. The mode keyword should probably have a default, something commonly used. I'd suggest 'mean', Nathaniel suggests 'zero', I think either would be fine. I can't type fast enough. :-) I

Re: [Numpy-discussion] Style for pad implementation in 'pad' namespace or functions under np.lib

2012-04-02 Thread Travis Oliphant
On the one hand it is nice to be explicit. On the other hand it is nice to have keyword arguments. In this case it is very true that pad(a) would not be very clear. Most clear, though, would be: pad(a, width=5, mode='mean'). You could use keyword arguments with None as the default and

Re: [Numpy-discussion] Style for pad implementation in 'pad' namespace or functions under np.lib

2012-03-31 Thread Richard Hattersley
1) The use of string constants to identify NumPy processes. It would seem better to use library defined constants (ufuncs?) for better future-proofing, maintenance, etc. I don't see how this would help with future-proofing or maintenance -- can you elaborate? If this were C, I'd agree;

Re: [Numpy-discussion] Style for pad implementation in 'pad' namespace or functions under np.lib

2012-03-30 Thread Richard Hattersley
I like where this is going. Driven by a desire to avoid a million different methods on a single class, we've done something similar in our library. So instead of thing.mean() thing.max(...) etc. we have: thing.scrunch(MEAN, ...) thing.scrunch(MAX, ...) etc. Where the

Re: [Numpy-discussion] Style for pad implementation in 'pad' namespace or functions under np.lib

2012-03-30 Thread Nathaniel Smith
On Fri, Mar 30, 2012 at 8:35 AM, Richard Hattersley rhatters...@gmail.com wrote: I like where this is going. Driven by a desire to avoid a million different methods on a single class, we've done something similar in our library. So instead of   thing.mean()   thing.max(...)   etc. we

Re: [Numpy-discussion] Style for pad implementation in 'pad' namespace or functions under np.lib

2012-03-30 Thread Nathaniel Smith
On Thu, Mar 29, 2012 at 6:53 PM, Tim Cera t...@cerazone.net wrote: If instead you passed in a function:     def padwithzeros(vector, pad_width, iaxis, **kwargs):         bvector = np.zeros(pad_width[0])         avector = np.zeros(pad_width[1])         return bvector, avector     b =

Re: [Numpy-discussion] Style for pad implementation in 'pad' namespace or functions under np.lib

2012-03-30 Thread Charles R Harris
On Fri, Mar 30, 2012 at 5:41 AM, Nathaniel Smith n...@pobox.com wrote: On Thu, Mar 29, 2012 at 6:53 PM, Tim Cera t...@cerazone.net wrote: If instead you passed in a function: def padwithzeros(vector, pad_width, iaxis, **kwargs): bvector = np.zeros(pad_width[0])

Re: [Numpy-discussion] Style for pad implementation in 'pad' namespace or functions under np.lib

2012-03-30 Thread Nathaniel Smith
On Fri, Mar 30, 2012 at 1:22 PM, Charles R Harris charlesr.har...@gmail.com wrote: On Fri, Mar 30, 2012 at 5:41 AM, Nathaniel Smith n...@pobox.com wrote: On Thu, Mar 29, 2012 at 6:53 PM, Tim Cera t...@cerazone.net wrote: If instead you passed in a function:     def padwithzeros(vector,

Re: [Numpy-discussion] Style for pad implementation in 'pad' namespace or functions under np.lib

2012-03-30 Thread Tim Cera
I rearranged your questions. Why is this function allocating new arrays that will just be copied into the big array and then discarded, instead of filling in the big array directly? (Again, this is a speed issue.) My example in the e-mail was incorrect (sorry about that). The way it actually

Re: [Numpy-discussion] Style for pad implementation in 'pad' namespace or functions under np.lib

2012-03-30 Thread Tim Cera
My suggestion is: Step 1: Change the current PR so that it has only one user-exposed function, something like pad(..., mode=foo), and commit that. Everyone seems to pretty much like that interface, implementing it would take 1 hour of work, and then the basic functionality would be landed

Re: [Numpy-discussion] Style for pad implementation in 'pad' namespace or functions under np.lib

2012-03-30 Thread Nathaniel Smith
On Fri, Mar 30, 2012 at 2:20 PM, Tim Cera t...@cerazone.net wrote: My suggestion is: Step 1: Change the current PR so that it has only one user-exposed function, something like pad(..., mode=foo), and commit that. Everyone seems to pretty much like that interface, implementing it would take 1

Re: [Numpy-discussion] Style for pad implementation in 'pad' namespace or functions under np.lib

2012-03-29 Thread Tim Cera
On Wed, Mar 28, 2012 at 6:08 PM, Charles R Harris charlesr.har...@gmail.com wrote: I think there is also a question of using a prefix pad_xxx for the function names as opposed to pad.xxx. If I had it as pad.mean, pad.median, ...etc. then someone could from numpy.pad import * a =

Re: [Numpy-discussion] Style for pad implementation in 'pad' namespace or functions under np.lib

2012-03-29 Thread Chris Barker
On Thu, Mar 29, 2012 at 7:55 AM, Tim Cera I think there is also a question of using a prefix pad_xxx for the function names as opposed to pad.xxx. Namespaces are one honking great idea -- let's do more of those! If I had it as pad.mean, pad.median, ...etc. then someone could     from

Re: [Numpy-discussion] Style for pad implementation in 'pad' namespace or functions under np.lib

2012-03-29 Thread Travis Oliphant
While namespaces are a really good idea, I'm not a big fan of both module namespaces and underscore namespaces. It seems pretty redundant to me to have pad.pad_mean. On the other hand, one could argue that pad.mean could be confused with calculating the mean of a padded array. So, it

Re: [Numpy-discussion] Style for pad implementation in 'pad' namespace or functions under np.lib

2012-03-29 Thread Nathaniel Smith
On Thu, Mar 29, 2012 at 5:13 PM, Travis Oliphant tra...@continuum.io wrote: While namespaces are a really good idea, I'm not a big fan of both module namespaces and underscore namespaces.   It seems pretty redundant to me to have pad.pad_mean. On the other hand, one could argue that pad.mean

Re: [Numpy-discussion] Style for pad implementation in 'pad' namespace or functions under np.lib

2012-03-29 Thread Charles R Harris
On Thu, Mar 29, 2012 at 10:38 AM, Nathaniel Smith n...@pobox.com wrote: On Thu, Mar 29, 2012 at 5:13 PM, Travis Oliphant tra...@continuum.io wrote: While namespaces are a really good idea, I'm not a big fan of both module namespaces and underscore namespaces. It seems pretty redundant to

Re: [Numpy-discussion] Style for pad implementation in 'pad' namespace or functions under np.lib

2012-03-29 Thread Nathaniel Smith
On Thu, Mar 29, 2012 at 5:38 PM, Nathaniel Smith n...@pobox.com wrote: On Thu, Mar 29, 2012 at 5:13 PM, Travis Oliphant tra...@continuum.io wrote: While namespaces are a really good idea, I'm not a big fan of both module namespaces and underscore namespaces.   It seems pretty redundant to me to

Re: [Numpy-discussion] Style for pad implementation in 'pad' namespace or functions under np.lib

2012-03-29 Thread Nathaniel Smith
On Thu, Mar 29, 2012 at 5:45 PM, Charles R Harris charlesr.har...@gmail.com wrote: On Thu, Mar 29, 2012 at 10:38 AM, Nathaniel Smith n...@pobox.com wrote: On Thu, Mar 29, 2012 at 5:13 PM, Travis Oliphant tra...@continuum.io wrote: While namespaces are a really good idea, I'm not a big fan

Re: [Numpy-discussion] Style for pad implementation in 'pad' namespace or functions under np.lib

2012-03-29 Thread Travis Oliphant
On Mar 29, 2012, at 11:52 AM, Nathaniel Smith wrote: On Thu, Mar 29, 2012 at 5:38 PM, Nathaniel Smith n...@pobox.com wrote: On Thu, Mar 29, 2012 at 5:13 PM, Travis Oliphant tra...@continuum.io wrote: While namespaces are a really good idea, I'm not a big fan of both module namespaces and

Re: [Numpy-discussion] Style for pad implementation in 'pad' namespace or functions under np.lib

2012-03-29 Thread Tim Cera
I was hoping pad would get finished some day. Maybe 1.9? Alright - I do like the idea of passing a function to pad, with a bunch of pre-made functions in place. Maybe something like: a = np.arange(10) b = pad('mean', a, 2, stat_length=3) where if the first argument is a string, use

Re: [Numpy-discussion] Style for pad implementation in 'pad' namespace or functions under np.lib

2012-03-29 Thread Charles R Harris
On Thu, Mar 29, 2012 at 11:53 AM, Tim Cera t...@cerazone.net wrote: I was hoping pad would get finished some day. Maybe 1.9? Well, you *did* ask ;-) Alright - I do like the idea of passing a function to pad, with a bunch of pre-made functions in place. Maybe something like: a =

Re: [Numpy-discussion] Style for pad implementation in 'pad' namespace or functions under np.lib

2012-03-29 Thread Travis Oliphant
On Mar 29, 2012, at 12:53 PM, Tim Cera wrote: I was hoping pad would get finished some day. Maybe 1.9? You have been a great sport about this process. I think it will result in something quite nice. Alright - I do like the idea of passing a function to pad, with a bunch of

[Numpy-discussion] Style for pad implementation in 'pad' namespace or functions under np.lib

2012-03-28 Thread Tim Cera
I have been developing a set of pad functions to pad arrays in different ways. Really close to having it accepted into numpy, but I want to revisit an implementation issue that I have become worried about. Should these functions be collected into a 'pad' namespace or put raw into np.lib? Do I

Re: [Numpy-discussion] Style for pad implementation in 'pad' namespace or functions under np.lib

2012-03-28 Thread Ralf Gommers
On Wed, Mar 28, 2012 at 9:31 PM, Tim Cera t...@cerazone.net wrote: I have been developing a set of pad functions to pad arrays in different ways. Really close to having it accepted into numpy, but I want to revisit an implementation issue that I have become worried about. Should these

Re: [Numpy-discussion] Style for pad implementation in 'pad' namespace or functions under np.lib

2012-03-28 Thread Charles R Harris
On Wed, Mar 28, 2012 at 1:57 PM, Ralf Gommers ralf.gomm...@googlemail.comwrote: On Wed, Mar 28, 2012 at 9:31 PM, Tim Cera t...@cerazone.net wrote: I have been developing a set of pad functions to pad arrays in different ways. Really close to having it accepted into numpy, but I want to