[Numpy-discussion] Style for pad implementation in 'pad' namespace or functions under np.lib
Travis Oliphant
travis@continuum...
Mon Apr 2 14:49:09 CDT 2012
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 raise an error if a correct value is not passed in.
-Travis
On Apr 2, 2012, at 1:14 PM, Tim Cera 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', 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 well.
>
> 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,
> Tim
>
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20120402/39c2b88d/attachment-0001.html
More information about the NumPy-Discussion
mailing list