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

Charles R Harris charlesr.harris@gmail....
Fri Mar 30 07:22:40 CDT 2012

On Fri, Mar 30, 2012 at 5:41 AM, Nathaniel Smith <njs@pobox.com> wrote:

> On Thu, Mar 29, 2012 at 6:53 PM, Tim Cera <tim@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 = pad(padwithzeros, a, 2)
> >
> > Would that have some goodness?
> I like the idea, but this interface feels undercooked to me. What is
> iaxis? (I couldn't figure that out from the docstrings in the pull
> request either.) If padding a matrix, do we need a way to do padding
> of all rows simultaneously? (Certainly that'd be just as easy for
> something like padwithzeros, and would let us avoid a python-level for
> loop.) 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.) If it's
> working with single rows at a time, then how will padwithconstant know
> which constant to pull out of kwargs["constant_value"] when it's an
> array?
> That's why I thought you might want to submit this as a second pull
> request, rather than letting it hold up the whole thing.
Would you suggest committing the current PR and then adding this interface

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

More information about the NumPy-Discussion mailing list