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

Charles R Harris charlesr.harris@gmail....
Mon Apr 2 12:38:49 CDT 2012

On Mon, Apr 2, 2012 at 10:36 AM, Tim Cera <tim@cerazone.net> wrote:

> On Mon, Apr 2, 2012 at 12:09 PM, Travis Oliphant <travis@continuum.io>wrote:
>> 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 first argument
>> to that function (it is more consistent).   They keyword can be called mode
>> or method
>> Tim, what do you think of that?   Further developments can happen in a
>> separate PR.
> Current pull request has a single pad function with the
> mode/method/whatever you call it as a string OR function as the first
> argument.
> pad('mean', a, 5)
> pad('median', a, 7)
> pad(paddingfunction, a, 2)
> ...etc.
> 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 seems like we have two votes for the later form (Travis and
> Nathaniel) and unless others weigh in, I will make the change soonish.
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.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20120402/27c4dfc6/attachment.html 

More information about the NumPy-Discussion mailing list