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

Tim Cera tim@cerazone....
Mon Apr 2 13:14:59 CDT 2012

> 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 should say that I can't type faster than
Travis since he has already responded....

Currently that '5' in the example above is the keyword argument 'pad_width'
which defaults to 1.  So really the only argument then is 'a'?  Everything
else is keywords?  I missed that in the discussion and I am not sure that
it is a good idea. In fact as I am typing this I am thinking that we should
have pad_width as an argument.  I hate to rely on this, because it tends to
get overused, but 'Explicit is better than implicit.'

'pad(a)' would carry a lot of implicit baggage that would mean it would be
very difficult to figure out what was going on if reading someone else's
code.  Someone unfamiliar with the pad routine must consult the
documentation to figure out what 'pad(a)' meant whereas "pad(a, 'mean',
1)", regardless of the order of the arguments, would actually read pretty

I defer to a 'consensus' - whatever that might mean, but I am actually
thinking that the input array, mode/method, and the pad_width should be
arguments.  The order of the arguments  - I don't care.

I realize that this thread is around 26 messages long now, but if everyone
who is interested in this could weigh in one more time about this one
issue.  To minimize discussion on the list, you can add a comment to the
pull request at https://github.com/numpy/numpy/pull/242

Kindest regards,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20120402/d20396d4/attachment.html 

More information about the NumPy-Discussion mailing list