<div dir="ltr"><br><div class="gmail_extra"><div class="gmail_quote">On Tue, Feb 18, 2014 at 11:27 AM, Sebastian Berg <span dir="ltr"><<a href="mailto:sebastian@sipsolutions.net" target="_blank">sebastian@sipsolutions.net</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class=""><div class="h5">On Di, 2014-02-18 at 09:05 -0700, Charles R Harris wrote:<br>
> Hi All,<br>
><br>
><br>
> There is an old ticket, #1499, that suggest adding a segment_axis<br>
> function.<br>
><br>
> def segment_axis(a, length, overlap=0, axis=None, end='cut', endvalue=0):<br>
>     """Generate a new array that chops the given array along the given axis<br>
>     into overlapping frames.<br>
><br>
>     Parameters<br>
>     ----------<br>
>     a : array-like<br>
>         The array to segment<br>
>     length : int<br>
>         The length of each frame<br>
>     overlap : int, optional<br>
>         The number of array elements by which the frames should overlap<br>
>     axis : int, optional<br>
>         The axis to operate on; if None, act on the flattened array<br>
>     end : {'cut', 'wrap', 'end'}, optional<br>
>         What to do with the last frame, if the array is not evenly<br>
>         divisible into pieces.<br>
><br>
>             - 'cut'   Simply discard the extra values<br>
>             - 'wrap'  Copy values from the beginning of the array<br>
>             - 'pad'   Pad with a constant value<br>
><br>
>     endvalue : object<br>
>         The value to use for end='pad'<br>
><br>
><br>
>     Examples<br>
>     --------<br>
>     >>> segment_axis(arange(10), 4, 2)<br>
>     array([[0, 1, 2, 3],<br>
>            [2, 3, 4, 5],<br>
>            [4, 5, 6, 7],<br>
>            [6, 7, 8, 9]])<br>
><br>
><br>
> Is there and interest in having this function available?<br>
><br>
<br>
</div></div>Just to note, there have been similar proposals with a rolling_window<br>
function. It could be made ND aware, too (though maybe this one is<br>
also).<br></blockquote><div><br></div><div><br></div><div>For example:  <a href="https://github.com/numpy/numpy/pull/31">https://github.com/numpy/numpy/pull/31</a><br><br></div><div>Warren<br><br><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">

<div class=""><div class="h5"><br>
><br>
> Chuck<br>
><br>
> _______________________________________________<br>
> NumPy-Discussion mailing list<br>
> <a href="mailto:NumPy-Discussion@scipy.org">NumPy-Discussion@scipy.org</a><br>
> <a href="http://mail.scipy.org/mailman/listinfo/numpy-discussion" target="_blank">http://mail.scipy.org/mailman/listinfo/numpy-discussion</a><br>
<br>
<br>
_______________________________________________<br>
NumPy-Discussion mailing list<br>
<a href="mailto:NumPy-Discussion@scipy.org">NumPy-Discussion@scipy.org</a><br>
<a href="http://mail.scipy.org/mailman/listinfo/numpy-discussion" target="_blank">http://mail.scipy.org/mailman/listinfo/numpy-discussion</a><br>
</div></div></blockquote></div><br></div></div>