[Numpy-discussion] Style for pad implementation in 'pad' namespace or functions under np.lib
Charles R Harris
Thu Mar 29 19:19:51 CDT 2012
On Thu, Mar 29, 2012 at 11:53 AM, Tim Cera <email@example.com> 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 = np.arange(10)
> b = pad('mean', a, 2, stat_length=3)
> where if the first argument is a string, use one of the built in functions.
I like Nathaniel's idea of making the string an optional argument, that way
you can also give it a default value ('mean' ?).
> If instead you passed in a function:
> def padwithzeros(vector, pad_width, iaxis, **kwargs):
> bvector = np.zeros(pad_width)
> avector = np.zeros(pad_width)
> return bvector, avector
> b = pad(padwithzeros, a, 2)
> Would that have some goodness?
Yeah, I think we're converging on something nice.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the NumPy-Discussion