Re: Proposed feature: add custom lags parameters to correlate/convolve

Nathan via NumPy-Discussion <[email protected]> Thu, 7 May 2026 09:59:48 -0600
Newsgroups gmane.comp.python.numeric.general
Message-ID <CAJXewOkfX=q9N1NKMysFju6hPFMRKTpPo=nWrU7F-_3EQJtf+g@mail.gmail.com>
--===============1332769099764053574==
Content-Type: multipart/alternative; boundary="00000000000065d50906513c5fe4"

--00000000000065d50906513c5fe4
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Honi has come to the last few community meetings to advocate for this.

I think there=E2=80=99s a soft consensus to merge a new maxlag or maxlags a=
rgument
(spelling TBD) to the correlate and convolve python APIs and not change any
C API.

While normally we would say that this should go into SciPy, there are
certain classes of problems where improving performance via maxlag is
faster than using SciPy=E2=80=99s FFT approach. This will also allow matplo=
tlib to
eventually delete a workaround they have for this specific issue, and
matplotlib doesn=E2=80=99t depend on SciPy.

The array API isn=E2=80=99t a concern, because correlate and convolve were =
excluded
from the standardization process. Maybe they=E2=80=99ll be standardized in =
the
future.

Honi also reached out to SciPy and Jax and didn=E2=80=99t hear back. I=E2=
=80=99d appreciate
readers of this mailing list from downstream projects who attempt to
emulate NumPy=E2=80=99s API and might be affected to register any objection=
s they
might have.

On Tue, Apr 21, 2026 at 6:39=E2=80=AFAM Honi Sanders via NumPy-Discussion <
[email protected]> wrote:

> Your message to the NumPy-Discussion mailing-list was rejected for the
> following
> reasons:
>
> The message is not from a list member
>
> The original message as received by Mailman is attached.
>
> *From: *Honi Sanders <[email protected]>
> *Subject: **Proposed feature: add custom lags parameters to
> correlate/convolve*
> *Date: *April 20, 2026 at 3:16:43=E2=80=AFPM EDT
> *To: *[email protected]
>
>
> Hello all,
>
>
> I'd like to solve a missing feature in np.correlate and np.convolve.
>
> Sometimes when computing a cross-correlation or convolution you are only
> interested in the result at a small number of lags. For example:
>
>    -
>
>    Cross-correlating two long time series and wanting only the
>    correlation within a bounded window around lag 0.
>    -
>
>    Having millisecond-precision time series but only wanting convolution
>    outputs at minute-scale lags.
>
> The current implementation computes every lag unconditionally =E2=80=94 a=
n
> expensive operation =E2=80=94 even when most of the output is discarded. =
I wrote PR
> #31261 to address this:
>
> https://github.com/numpy/numpy/pull/31261
>
> This PR revives an attempt from ten years ago (PR #5978
> <https://github.com/numpy/numpy/pull/5978>) that attracted significant
> interest but I couldn't get it to Numpy=E2=80=99s high implementation sta=
ndards.
> The feature was also raised as issues on NumPy (#5954
> <https://github.com/numpy/numpy/issues/5954>) and SciPy (scipy/scipy#4940
> <https://github.com/scipy/scipy/issues/4940>), discussed on the scipy-dev
> list <http://mail.scipy.org/pipermail/scipy-dev/2015-June/020757.html>,
> and got attention on Stack Overflow
> <https://stackoverflow.com/questions/30677241/how-to-limit-cross-correlat=
ion-window-width-in-numpy/47893831#47893831>
> at the time. The current open issue it resolves is #17286
> <https://github.com/numpy/numpy/issues/17286>.
>
> ------------------------------
>
> Proposed API
>
> np.correlate(a, v, mode=3D..., *, maxlag=3DNone, lags=3DNone)
>
> np.convolve(a, v, mode=3D..., *, maxlag=3DNone, lags=3DNone)
>
> np.correlate_lags(a_len, v_len, mode=3D..., *, maxlag=3DNone, lags=3DNone=
)
>
> Parameter design
>
>    -
>
>    maxlag=3DM (int): symmetric inclusive window [-M, M] (2M+1 lags total)=
.
>    Matches MATLAB's xcorr(x, y, M) convention.
>    -
>
>    lags=3D: a range, a slice with explicit start/stop, or a 1-D integer
>    array-like containing an arithmetic progression.
>    -
>
>    np.correlate_lags(a_len, v_len, ...): a companion function (modeled on
>    scipy.signal.correlation_lags) that returns the array of lag indices
>    corresponding to a given correlate or convolve call, without requiring=
 the
>    arrays themselves.
>
> ------------------------------
>
> Related library notes
>
> Matplotlib already has a maxlags argument on Axes.xcorr:
>
>
> https://github.com/matplotlib/matplotlib/blob/dde076379dad6a51374625dbaa7=
29a71958d4d88/lib/matplotlib/axes/_axes.pyi#L218
>
> Its current implementation calls numpy.correlate(..., 'full') and discard=
s
> the unwanted entries =E2=80=94 wasting a lot of calculations. NumPy imple=
menting
> this feature would allow Matplotlib to immediately benefit in performance
> without changing their existing API by just updating the numpy correlate
> call.
>
> Neural network libraries like Pytorch and and mxnet rely on a stride
> parameter for their convolution functions to avoid calculating convolutio=
ns
> at every lag (e.g.
> https://docs.pytorch.org/docs/stable/generated/torch.nn.modules.conv.Conv=
1d.html),
> similar to the stride entry in the range construction for the lags
> parameter proposed here.
>
> ------------------------------
>
> Previous discussions on this list
>
>    -
>
>
>    https://mail.python.org/archives/list/[email protected]/thre=
ad/JMXNOCFQRFJYISFKSRI7MRL7GPK5ZD4S/
>    -
>
>
>    https://mail.python.org/archives/list/[email protected]/thre=
ad/6FC27XPOD4SBH3KJ7VY5DDAPS5Q46GPO/
>    (several people chimed in with interest in the feature)
>
> ------------------------------
>
>
> Open question:
>
> C API
>
> The PR also adds PyArray_CorrelateLags to the C API. I am not sure who
> the intended users of the C API are and whether they would be interested =
in
> this functionality as long as we are building it.   Feedback welcome.
>
> Companion function
>
> The companion function that returns the matching lagvector is based on th=
e
> scipy companion function that is called correlate_lags(). A name like
> generate_lagvector() would be more descriptive but inconsistent with
> scipy=E2=80=99s naming. Any thoughts on that?
>
>
>
> Thanks for your time,
>
> Honi
> _______________________________________________
> NumPy-Discussion mailing list -- [email protected]
> To unsubscribe send an email to [email protected]
> https://mail.python.org/mailman3//lists/numpy-discussion.python.org
> Member address: [email protected]
>

--00000000000065d50906513c5fe4
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"auto">Honi has come to the last few community meetings to advoc=
ate for this.</div><div dir=3D"auto"><br></div><div dir=3D"auto">I think th=
ere=E2=80=99s a soft consensus to merge a new maxlag or maxlags argument (s=
pelling TBD) to the correlate and convolve python APIs and not change any C=
 API.</div><div dir=3D"auto"><br></div><div dir=3D"auto">While normally we =
would say that this should go into SciPy, there are certain classes of prob=
lems where improving performance via maxlag is faster than using SciPy=E2=
=80=99s FFT approach. This will also allow matplotlib to eventually delete =
a workaround they have for this specific issue, and matplotlib doesn=E2=80=
=99t depend on SciPy.</div><div dir=3D"auto"><br></div><div dir=3D"auto">Th=
e array API isn=E2=80=99t a concern, because correlate and convolve were ex=
cluded from the standardization process. Maybe they=E2=80=99ll be standardi=
zed in the future.</div><div dir=3D"auto"><br></div><div dir=3D"auto">Honi =
also reached out to SciPy and Jax and didn=E2=80=99t hear back. I=E2=80=99d=
 appreciate readers of this mailing list from downstream projects who attem=
pt to emulate NumPy=E2=80=99s API and might be affected to register any obj=
ections they might have.</div><div dir=3D"auto"><br><div class=3D"gmail_quo=
te gmail_quote_container" dir=3D"auto"><div dir=3D"ltr" class=3D"gmail_attr=
">On Tue, Apr 21, 2026 at 6:39=E2=80=AFAM Honi Sanders via NumPy-Discussion=
 &lt;<a href=3D"mailto:[email protected]">numpy-discussion@python=
.org</a>&gt; wrote:<br></div><blockquote class=3D"gmail_quote" style=3D"mar=
gin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style=3D"l=
ine-break:after-white-space">Your message to the NumPy-Discussion mailing-l=
ist was rejected for the following<br>reasons:<br><br>The message is not fr=
om a list member<br><br>The original message as received by Mailman is atta=
ched.<br><br><div style=3D"margin:0px"><span style=3D"font-family:-webkit-s=
ystem-font,&quot;Helvetica Neue&quot;,Helvetica,sans-serif;color:rgb(127,12=
7,127)"><b>From:=C2=A0</b></span><span style=3D"font-family:-webkit-system-=
font,&quot;Helvetica Neue&quot;,Helvetica,sans-serif">Honi Sanders &lt;<a h=
ref=3D"mailto:[email protected]" target=3D"_blank">sandersh6000@gmail.=
com</a>&gt;<br></span></div><div style=3D"margin:0px"><span style=3D"font-f=
amily:-webkit-system-font,&quot;Helvetica Neue&quot;,Helvetica,sans-serif;c=
olor:rgb(127,127,127)"><b>Subject:=C2=A0</b></span><span style=3D"font-fami=
ly:-webkit-system-font,&quot;Helvetica Neue&quot;,Helvetica,sans-serif"><b>=
Proposed feature: add custom lags parameters to correlate/convolve</b><br><=
/span></div><div style=3D"margin:0px"><span style=3D"font-family:-webkit-sy=
stem-font,&quot;Helvetica Neue&quot;,Helvetica,sans-serif;color:rgb(127,127=
,127)"><b>Date:=C2=A0</b></span><span style=3D"font-family:-webkit-system-f=
ont,&quot;Helvetica Neue&quot;,Helvetica,sans-serif">April 20, 2026 at 3:16=
:43=E2=80=AFPM EDT<br></span></div><div style=3D"margin:0px"><span style=3D=
"font-family:-webkit-system-font,&quot;Helvetica Neue&quot;,Helvetica,sans-=
serif;color:rgb(127,127,127)"><b>To:=C2=A0</b></span><span style=3D"font-fa=
mily:-webkit-system-font,&quot;Helvetica Neue&quot;,Helvetica,sans-serif"><=
a href=3D"mailto:[email protected]" target=3D"_blank">numpy-discu=
[email protected]</a><br></span></div><br><br><p dir=3D"ltr" style=3D"line-h=
eight:1.38;margin-top:0pt;margin-bottom:0pt"><span style=3D"font-size:11pt;=
font-family:Arial,sans-serif;font-variant-ligatures:normal;font-variant-alt=
ernates:normal;font-variant-numeric:normal;font-variant-east-asian:normal;v=
ertical-align:baseline;white-space:pre-wrap">Hello all,</span></p><p dir=3D=
"ltr" style=3D"line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span sty=
le=3D"font-size:11pt;font-family:Arial,sans-serif;font-variant-ligatures:no=
rmal;font-variant-alternates:normal;font-variant-numeric:normal;font-varian=
t-east-asian:normal;vertical-align:baseline;white-space:pre-wrap"><br></spa=
n></p><p dir=3D"ltr" style=3D"line-height:1.38;margin-top:0pt;margin-bottom=
:0pt"><span style=3D"font-size:11pt;font-family:Arial,sans-serif;font-varia=
nt-ligatures:normal;font-variant-alternates:normal;font-variant-numeric:nor=
mal;font-variant-east-asian:normal;vertical-align:baseline;white-space:pre-=
wrap">I&#39;d like to solve a missing feature in np.correlate and np.convol=
ve.</span></p><p dir=3D"ltr" style=3D"line-height:1.38;margin-top:0pt;margi=
n-bottom:0pt"><span style=3D"font-size:11pt;font-family:Arial,sans-serif;fo=
nt-variant-ligatures:normal;font-variant-alternates:normal;font-variant-num=
eric:normal;font-variant-east-asian:normal;vertical-align:baseline;white-sp=
ace:pre-wrap">Sometimes when computing a cross-correlation or convolution y=
ou are only interested in the result at a small number of lags. For example=
:</span></p><ul style=3D"margin-top:0px;margin-bottom:0px"><li dir=3D"ltr" =
aria-level=3D"1" style=3D"list-style-type:disc;font-size:10pt;font-family:R=
oboto,sans-serif;color:rgb(204,204,204);font-variant-ligatures:normal;font-=
variant-alternates:normal;font-variant-numeric:normal;font-variant-east-asi=
an:normal;vertical-align:baseline;white-space:pre-wrap"><p dir=3D"ltr" role=
=3D"presentation" style=3D"line-height:1.38;margin-top:0pt;margin-bottom:0p=
t"><span style=3D"font-size:11pt;font-family:Arial,sans-serif;color:rgb(0,0=
,0);font-variant-ligatures:normal;font-variant-alternates:normal;font-varia=
nt-numeric:normal;font-variant-east-asian:normal;vertical-align:baseline;wh=
ite-space:pre-wrap">Cross-correlating two long time series and wanting only=
 the correlation within a bounded window around lag 0.</span></p></li><li d=
ir=3D"ltr" aria-level=3D"1" style=3D"list-style-type:disc;font-size:10pt;fo=
nt-family:Roboto,sans-serif;color:rgb(204,204,204);font-variant-ligatures:n=
ormal;font-variant-alternates:normal;font-variant-numeric:normal;font-varia=
nt-east-asian:normal;vertical-align:baseline;white-space:pre-wrap"><p dir=
=3D"ltr" role=3D"presentation" style=3D"line-height:1.38;margin-top:0pt;mar=
gin-bottom:0pt"><span style=3D"font-size:11pt;font-family:Arial,sans-serif;=
color:rgb(0,0,0);font-variant-ligatures:normal;font-variant-alternates:norm=
al;font-variant-numeric:normal;font-variant-east-asian:normal;vertical-alig=
n:baseline;white-space:pre-wrap">Having millisecond-precision time series b=
ut only wanting convolution outputs at minute-scale lags.</span></p></li></=
ul><p dir=3D"ltr" style=3D"line-height:1.38;margin-top:0pt;margin-bottom:0p=
t"><span style=3D"font-size:11pt;font-family:Arial,sans-serif;font-variant-=
ligatures:normal;font-variant-alternates:normal;font-variant-numeric:normal=
;font-variant-east-asian:normal;vertical-align:baseline;white-space:pre-wra=
p">The current implementation computes every lag unconditionally =E2=80=94 =
an expensive operation =E2=80=94 even when most of the output is discarded.=
 I wrote PR #31261 to address this:</span></p><p dir=3D"ltr" style=3D"line-=
height:1.38;margin-top:0pt;margin-bottom:0pt"><a href=3D"https://github.com=
/numpy/numpy/pull/31261" style=3D"text-decoration:none" target=3D"_blank"><=
span style=3D"font-size:11pt;font-family:Arial,sans-serif;color:rgb(17,85,2=
04);font-variant-ligatures:normal;font-variant-alternates:normal;font-varia=
nt-numeric:normal;font-variant-east-asian:normal;text-decoration:underline;=
vertical-align:baseline;white-space:pre-wrap">https://github.com/numpy/nump=
y/pull/31261</span></a></p><p dir=3D"ltr" style=3D"line-height:1.38;margin-=
top:0pt;margin-bottom:0pt"><span style=3D"font-size:11pt;font-family:Arial,=
sans-serif;font-variant-ligatures:normal;font-variant-alternates:normal;fon=
t-variant-numeric:normal;font-variant-east-asian:normal;vertical-align:base=
line;white-space:pre-wrap">This PR revives an attempt from ten years ago (<=
/span><a href=3D"https://github.com/numpy/numpy/pull/5978" style=3D"text-de=
coration:none" target=3D"_blank"><span style=3D"font-size:11pt;font-family:=
Arial,sans-serif;color:rgb(17,85,204);font-variant-ligatures:normal;font-va=
riant-alternates:normal;font-variant-numeric:normal;font-variant-east-asian=
:normal;text-decoration:underline;vertical-align:baseline;white-space:pre-w=
rap">PR #5978</span></a><span style=3D"font-size:11pt;font-family:Arial,san=
s-serif;font-variant-ligatures:normal;font-variant-alternates:normal;font-v=
ariant-numeric:normal;font-variant-east-asian:normal;vertical-align:baselin=
e;white-space:pre-wrap">) that attracted significant interest but I couldn&=
#39;t get it to Numpy=E2=80=99s high implementation standards. The feature =
was also raised as issues on NumPy (</span><a href=3D"https://github.com/nu=
mpy/numpy/issues/5954" style=3D"text-decoration:none" target=3D"_blank"><sp=
an style=3D"font-size:11pt;font-family:Arial,sans-serif;color:rgb(17,85,204=
);font-variant-ligatures:normal;font-variant-alternates:normal;font-variant=
-numeric:normal;font-variant-east-asian:normal;text-decoration:underline;ve=
rtical-align:baseline;white-space:pre-wrap">#5954</span></a><span style=3D"=
font-size:11pt;font-family:Arial,sans-serif;font-variant-ligatures:normal;f=
ont-variant-alternates:normal;font-variant-numeric:normal;font-variant-east=
-asian:normal;vertical-align:baseline;white-space:pre-wrap">) and SciPy (</=
span><a href=3D"https://github.com/scipy/scipy/issues/4940" style=3D"text-d=
ecoration:none" target=3D"_blank"><span style=3D"font-size:11pt;font-family=
:Arial,sans-serif;color:rgb(17,85,204);font-variant-ligatures:normal;font-v=
ariant-alternates:normal;font-variant-numeric:normal;font-variant-east-asia=
n:normal;text-decoration:underline;vertical-align:baseline;white-space:pre-=
wrap">scipy/scipy#4940</span></a><span style=3D"font-size:11pt;font-family:=
Arial,sans-serif;font-variant-ligatures:normal;font-variant-alternates:norm=
al;font-variant-numeric:normal;font-variant-east-asian:normal;vertical-alig=
n:baseline;white-space:pre-wrap">), discussed on the</span><a href=3D"http:=
//mail.scipy.org/pipermail/scipy-dev/2015-June/020757.html" style=3D"text-d=
ecoration:none" target=3D"_blank"><span style=3D"font-size:11pt;font-family=
:Arial,sans-serif;color:rgb(17,85,204);font-variant-ligatures:normal;font-v=
ariant-alternates:normal;font-variant-numeric:normal;font-variant-east-asia=
n:normal;text-decoration:underline;vertical-align:baseline;white-space:pre-=
wrap"> scipy-dev list</span></a><span style=3D"font-size:11pt;font-family:A=
rial,sans-serif;font-variant-ligatures:normal;font-variant-alternates:norma=
l;font-variant-numeric:normal;font-variant-east-asian:normal;vertical-align=
:baseline;white-space:pre-wrap">, and got attention on</span><a href=3D"htt=
ps://stackoverflow.com/questions/30677241/how-to-limit-cross-correlation-wi=
ndow-width-in-numpy/47893831#47893831" style=3D"text-decoration:none" targe=
t=3D"_blank"><span style=3D"font-size:11pt;font-family:Arial,sans-serif;col=
or:rgb(17,85,204);font-variant-ligatures:normal;font-variant-alternates:nor=
mal;font-variant-numeric:normal;font-variant-east-asian:normal;text-decorat=
ion:underline;vertical-align:baseline;white-space:pre-wrap"> Stack Overflow=
</span></a><span style=3D"font-size:11pt;font-family:Arial,sans-serif;font-=
variant-ligatures:normal;font-variant-alternates:normal;font-variant-numeri=
c:normal;font-variant-east-asian:normal;vertical-align:baseline;white-space=
:pre-wrap"> at the time. The current open issue it resolves is</span><a hre=
f=3D"https://github.com/numpy/numpy/issues/17286" style=3D"text-decoration:=
none" target=3D"_blank"><span style=3D"font-size:11pt;font-family:Arial,san=
s-serif;color:rgb(17,85,204);font-variant-ligatures:normal;font-variant-alt=
ernates:normal;font-variant-numeric:normal;font-variant-east-asian:normal;t=
ext-decoration:underline;vertical-align:baseline;white-space:pre-wrap"> #17=
286</span></a><span style=3D"font-size:11pt;font-family:Arial,sans-serif;fo=
nt-variant-ligatures:normal;font-variant-alternates:normal;font-variant-num=
eric:normal;font-variant-east-asian:normal;vertical-align:baseline;white-sp=
ace:pre-wrap">.</span></p><p dir=3D"ltr" style=3D"line-height:1.38;margin-t=
op:0pt;margin-bottom:0pt"></p><hr><p></p><p dir=3D"ltr" style=3D"line-heigh=
t:1.38;margin-top:0pt;margin-bottom:0pt"><span style=3D"font-size:11pt;font=
-family:Arial,sans-serif;font-variant-ligatures:normal;font-variant-alterna=
tes:normal;font-variant-numeric:normal;font-variant-east-asian:normal;verti=
cal-align:baseline;white-space:pre-wrap">Proposed API</span></p><p dir=3D"l=
tr" style=3D"line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style=
=3D"font-size:11pt;font-family:Arial,sans-serif;font-variant-ligatures:norm=
al;font-variant-alternates:normal;font-variant-numeric:normal;font-variant-=
east-asian:normal;vertical-align:baseline;white-space:pre-wrap">np.correlat=
e(a, v, mode=3D..., *, maxlag=3DNone, lags=3DNone)</span></p><p dir=3D"ltr"=
 style=3D"line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style=3D=
"font-size:11pt;font-family:Arial,sans-serif;font-variant-ligatures:normal;=
font-variant-alternates:normal;font-variant-numeric:normal;font-variant-eas=
t-asian:normal;vertical-align:baseline;white-space:pre-wrap">np.convolve(a,=
 v, mode=3D..., *, maxlag=3DNone, lags=3DNone)</span></p><p dir=3D"ltr" sty=
le=3D"line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style=3D"fon=
t-size:11pt;font-family:Arial,sans-serif;font-variant-ligatures:normal;font=
-variant-alternates:normal;font-variant-numeric:normal;font-variant-east-as=
ian:normal;vertical-align:baseline;white-space:pre-wrap">np.correlate_lags(=
a_len, v_len, mode=3D..., *, maxlag=3DNone, lags=3DNone)</span></p><p dir=
=3D"ltr" style=3D"line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span =
style=3D"font-size:11pt;font-family:Arial,sans-serif;font-variant-ligatures=
:normal;font-variant-alternates:normal;font-variant-numeric:normal;font-var=
iant-east-asian:normal;vertical-align:baseline;white-space:pre-wrap">Parame=
ter design</span></p><ul style=3D"margin-top:0px;margin-bottom:0px"><li dir=
=3D"ltr" aria-level=3D"1" style=3D"list-style-type:disc;font-size:10pt;font=
-family:Roboto,sans-serif;color:rgb(204,204,204);font-variant-ligatures:nor=
mal;font-variant-alternates:normal;font-variant-numeric:normal;font-variant=
-east-asian:normal;vertical-align:baseline;white-space:pre-wrap"><p dir=3D"=
ltr" role=3D"presentation" style=3D"line-height:1.38;margin-top:0pt;margin-=
bottom:0pt"><span style=3D"font-size:11pt;font-family:Arial,sans-serif;colo=
r:rgb(0,0,0);font-variant-ligatures:normal;font-variant-alternates:normal;f=
ont-variant-numeric:normal;font-variant-east-asian:normal;vertical-align:ba=
seline;white-space:pre-wrap">maxlag=3DM (int): symmetric inclusive window [=
-M, M] (2M+1 lags total). Matches MATLAB&#39;s xcorr(x, y, M) convention.</=
span></p></li><li dir=3D"ltr" aria-level=3D"1" style=3D"list-style-type:dis=
c;font-size:10pt;font-family:Roboto,sans-serif;color:rgb(204,204,204);font-=
variant-ligatures:normal;font-variant-alternates:normal;font-variant-numeri=
c:normal;font-variant-east-asian:normal;vertical-align:baseline;white-space=
:pre-wrap"><p dir=3D"ltr" role=3D"presentation" style=3D"line-height:1.38;m=
argin-top:0pt;margin-bottom:0pt"><span style=3D"font-size:11pt;font-family:=
Arial,sans-serif;color:rgb(0,0,0);font-variant-ligatures:normal;font-varian=
t-alternates:normal;font-variant-numeric:normal;font-variant-east-asian:nor=
mal;vertical-align:baseline;white-space:pre-wrap">lags=3D: a range, a slice=
 with explicit start/stop, or a 1-D integer array-like containing an arithm=
etic progression.</span></p></li><li dir=3D"ltr" aria-level=3D"1" style=3D"=
list-style-type:disc;font-size:10pt;font-family:Roboto,sans-serif;color:rgb=
(204,204,204);font-variant-ligatures:normal;font-variant-alternates:normal;=
font-variant-numeric:normal;font-variant-east-asian:normal;vertical-align:b=
aseline;white-space:pre-wrap"><p dir=3D"ltr" role=3D"presentation" style=3D=
"line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style=3D"font-siz=
e:11pt;font-family:Arial,sans-serif;color:rgb(0,0,0);font-variant-ligatures=
:normal;font-variant-alternates:normal;font-variant-numeric:normal;font-var=
iant-east-asian:normal;vertical-align:baseline;white-space:pre-wrap">np.cor=
relate_lags(a_len, v_len, ...): a companion function (modeled on scipy.sign=
al.correlation_lags) that returns the array of lag indices corresponding to=
 a given correlate or convolve call, without requiring the arrays themselve=
s.</span></p></li></ul><p dir=3D"ltr" style=3D"line-height:1.38;margin-top:=
0pt;margin-bottom:0pt"></p><hr><p></p><p dir=3D"ltr" style=3D"line-height:1=
.38;margin-top:0pt;margin-bottom:0pt"><span style=3D"font-size:11pt;font-fa=
mily:Arial,sans-serif;font-variant-ligatures:normal;font-variant-alternates=
:normal;font-variant-numeric:normal;font-variant-east-asian:normal;vertical=
-align:baseline;white-space:pre-wrap">Related library notes</span></p><p di=
r=3D"ltr" style=3D"line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span=
 style=3D"font-size:11pt;font-family:Arial,sans-serif;font-variant-ligature=
s:normal;font-variant-alternates:normal;font-variant-numeric:normal;font-va=
riant-east-asian:normal;vertical-align:baseline;white-space:pre-wrap">Matpl=
otlib already has a maxlags argument on Axes.xcorr:</span></p><p dir=3D"ltr=
" style=3D"line-height:1.38;margin-top:0pt;margin-bottom:0pt"><a href=3D"ht=
tps://github.com/matplotlib/matplotlib/blob/dde076379dad6a51374625dbaa729a7=
1958d4d88/lib/matplotlib/axes/_axes.pyi#L218" style=3D"text-decoration:none=
" target=3D"_blank"><span style=3D"font-size:11pt;font-family:Arial,sans-se=
rif;color:rgb(17,85,204);font-variant-ligatures:normal;font-variant-alterna=
tes:normal;font-variant-numeric:normal;font-variant-east-asian:normal;text-=
decoration:underline;vertical-align:baseline;white-space:pre-wrap">https://=
github.com/matplotlib/matplotlib/blob/dde076379dad6a51374625dbaa729a71958d4=
d88/lib/matplotlib/axes/_axes.pyi#L218</span></a></p><p dir=3D"ltr" style=
=3D"line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style=3D"font-=
size:11pt;font-family:Arial,sans-serif;font-variant-ligatures:normal;font-v=
ariant-alternates:normal;font-variant-numeric:normal;font-variant-east-asia=
n:normal;vertical-align:baseline;white-space:pre-wrap">Its current implemen=
tation calls numpy.correlate(..., &#39;full&#39;) and discards the unwanted=
 entries =E2=80=94 wasting a lot of calculations. NumPy implementing this f=
eature would allow Matplotlib to immediately benefit in performance without=
 changing their existing API by just updating the numpy correlate call.</sp=
an></p><p dir=3D"ltr" style=3D"line-height:1.38;margin-top:0pt;margin-botto=
m:0pt"><span style=3D"font-size:11pt;font-family:Arial,sans-serif;font-vari=
ant-ligatures:normal;font-variant-alternates:normal;font-variant-numeric:no=
rmal;font-variant-east-asian:normal;vertical-align:baseline;white-space:pre=
-wrap">Neural network libraries like Pytorch and </span><span style=3D"colo=
r:rgb(31,35,40);font-family:&quot;Mona Sans VF&quot;,-apple-system,BlinkMac=
SystemFont,&quot;Segoe UI&quot;,&quot;Noto Sans&quot;,Helvetica,Arial,sans-=
serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;;font-size:14=
px;background-color:rgb(255,255,255)">and mxnet rely on a stride parameter =
for their convolution functions to avoid calculating convolutions at every =
lag (e.g.=C2=A0</span><a href=3D"https://docs.pytorch.org/docs/stable/gener=
ated/torch.nn.modules.conv.Conv1d.html" rel=3D"nofollow" style=3D"box-sizin=
g:border-box;color:rgb(0,0,0);font-family:&quot;Mona Sans VF&quot;,-apple-s=
ystem,BlinkMacSystemFont,&quot;Segoe UI&quot;,&quot;Noto Sans&quot;,Helveti=
ca,Arial,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot=
;;font-size:14px" target=3D"_blank">https://docs.pytorch.org/docs/stable/ge=
nerated/torch.nn.modules.conv.Conv1d.html</a><span style=3D"color:rgb(31,35=
,40);font-family:&quot;Mona Sans VF&quot;,-apple-system,BlinkMacSystemFont,=
&quot;Segoe UI&quot;,&quot;Noto Sans&quot;,Helvetica,Arial,sans-serif,&quot=
;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;;font-size:14px;backgrou=
nd-color:rgb(255,255,255)">), similar to the stride entry in the range cons=
truction for the lags parameter proposed here.</span></p><p dir=3D"ltr" sty=
le=3D"line-height:1.38;margin-top:0pt;margin-bottom:0pt"></p><hr><p></p><p =
dir=3D"ltr" style=3D"line-height:1.38;margin-top:0pt;margin-bottom:0pt"><sp=
an style=3D"font-size:11pt;font-family:Arial,sans-serif;font-variant-ligatu=
res:normal;font-variant-alternates:normal;font-variant-numeric:normal;font-=
variant-east-asian:normal;vertical-align:baseline;white-space:pre-wrap">Pre=
vious discussions on this list</span></p><ul style=3D"margin-top:0px;margin=
-bottom:0px"><li dir=3D"ltr" aria-level=3D"1" style=3D"list-style-type:disc=
;font-size:10pt;font-family:Roboto,sans-serif;color:rgb(204,204,204);font-v=
ariant-ligatures:normal;font-variant-alternates:normal;font-variant-numeric=
:normal;font-variant-east-asian:normal;vertical-align:baseline;white-space:=
pre-wrap"><p dir=3D"ltr" role=3D"presentation" style=3D"line-height:1.38;ma=
rgin-top:0pt;margin-bottom:0pt"><a href=3D"https://mail.python.org/archives=
/list/[email protected]/thread/JMXNOCFQRFJYISFKSRI7MRL7GPK5ZD4S/"=
 style=3D"text-decoration:none" target=3D"_blank"><span style=3D"font-size:=
11pt;font-family:Arial,sans-serif;color:rgb(17,85,204);font-variant-ligatur=
es:normal;font-variant-alternates:normal;font-variant-numeric:normal;font-v=
ariant-east-asian:normal;text-decoration:underline;vertical-align:baseline;=
white-space:pre-wrap">https://mail.python.org/archives/list/numpy-discussio=
[email protected]/thread/JMXNOCFQRFJYISFKSRI7MRL7GPK5ZD4S/</span></a></p></li><l=
i dir=3D"ltr" aria-level=3D"1" style=3D"list-style-type:disc;font-size:10pt=
;font-family:Roboto,sans-serif;color:rgb(204,204,204);font-variant-ligature=
s:normal;font-variant-alternates:normal;font-variant-numeric:normal;font-va=
riant-east-asian:normal;vertical-align:baseline;white-space:pre-wrap"><p di=
r=3D"ltr" role=3D"presentation" style=3D"line-height:1.38;margin-top:0pt;ma=
rgin-bottom:0pt"><a href=3D"https://mail.python.org/archives/list/numpy-dis=
[email protected]/thread/6FC27XPOD4SBH3KJ7VY5DDAPS5Q46GPO/" style=3D"text-=
decoration:none" target=3D"_blank"><span style=3D"font-size:11pt;font-famil=
y:Arial,sans-serif;color:rgb(17,85,204);font-variant-ligatures:normal;font-=
variant-alternates:normal;font-variant-numeric:normal;font-variant-east-asi=
an:normal;text-decoration:underline;vertical-align:baseline;white-space:pre=
-wrap">https://mail.python.org/archives/list/[email protected]/th=
read/6FC27XPOD4SBH3KJ7VY5DDAPS5Q46GPO/</span></a><span style=3D"font-size:1=
1pt;font-family:Arial,sans-serif;color:rgb(0,0,0);font-variant-ligatures:no=
rmal;font-variant-alternates:normal;font-variant-numeric:normal;font-varian=
t-east-asian:normal;vertical-align:baseline;white-space:pre-wrap"> (several=
 people chimed in with interest in the feature)</span></p></li></ul><p dir=
=3D"ltr" style=3D"line-height:1.38;margin-top:0pt;margin-bottom:0pt"></p><h=
r><p></p><p dir=3D"ltr" style=3D"line-height:1.38;margin-top:0pt;margin-bot=
tom:0pt"><span style=3D"font-size:11pt;font-family:Arial,sans-serif;font-va=
riant-ligatures:normal;font-variant-alternates:normal;font-variant-numeric:=
normal;font-variant-east-asian:normal;vertical-align:baseline;white-space:p=
re-wrap"><br></span></p><p dir=3D"ltr" style=3D"line-height:1.38;margin-top=
:0pt;margin-bottom:0pt"><span style=3D"font-size:11pt;font-family:Arial,san=
s-serif;font-variant-ligatures:normal;font-variant-alternates:normal;font-v=
ariant-numeric:normal;font-variant-east-asian:normal;vertical-align:baselin=
e;white-space:pre-wrap">Open question:=C2=A0</span></p><p dir=3D"ltr" style=
=3D"line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style=3D"font-=
size:11pt;font-family:Arial,sans-serif;font-variant-ligatures:normal;font-v=
ariant-alternates:normal;font-variant-numeric:normal;font-variant-east-asia=
n:normal;vertical-align:baseline;white-space:pre-wrap">C API</span></p><p d=
ir=3D"ltr" style=3D"line-height:1.38;margin-top:0pt;margin-bottom:0pt"><spa=
n style=3D"font-size:11pt;font-family:Arial,sans-serif;font-variant-ligatur=
es:normal;font-variant-alternates:normal;font-variant-numeric:normal;font-v=
ariant-east-asian:normal;vertical-align:baseline;white-space:pre-wrap">The =
PR also adds PyArray_CorrelateLags to the C API. <span style=3D"white-space=
:normal;color:rgb(5,12,20);font-family:&quot;Mona Sans VF&quot;,-apple-syst=
em,BlinkMacSystemFont,&quot;Segoe UI&quot;,&quot;Noto Sans&quot;,Helvetica,=
Arial,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;;f=
ont-size:14px">I am not sure who the intended users of the C API are and wh=
ether they would be interested in this functionality as long as we are buil=
ding it. =C2=A0</span> Feedback welcome.</span></p><p dir=3D"ltr" style=3D"=
line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style=3D"font-size=
:11pt;font-family:Arial,sans-serif;font-variant-ligatures:normal;font-varia=
nt-alternates:normal;font-variant-numeric:normal;font-variant-east-asian:no=
rmal;vertical-align:baseline;white-space:pre-wrap">Companion function</span=
></p><p dir=3D"ltr" style=3D"line-height:1.38;margin-top:0pt;margin-bottom:=
0pt"><span style=3D"font-size:11pt;font-family:Arial,sans-serif;font-varian=
t-ligatures:normal;font-variant-alternates:normal;font-variant-numeric:norm=
al;font-variant-east-asian:normal;vertical-align:baseline;white-space:pre-w=
rap">The companion function that returns the matching lagvector is based on=
 the scipy companion function that is called correlate_lags().  A name like=
 generate_lagvector() would be more descriptive but inconsistent with scipy=
=E2=80=99s naming.  Any thoughts on that?</span></p><p dir=3D"ltr" style=3D=
"line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style=3D"font-siz=
e:11pt;font-family:Arial,sans-serif;font-variant-ligatures:normal;font-vari=
ant-alternates:normal;font-variant-numeric:normal;font-variant-east-asian:n=
ormal;vertical-align:baseline;white-space:pre-wrap"><br></span></p><p dir=
=3D"ltr" style=3D"line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span =
style=3D"font-size:11pt;font-family:Arial,sans-serif;font-variant-ligatures=
:normal;font-variant-alternates:normal;font-variant-numeric:normal;font-var=
iant-east-asian:normal;vertical-align:baseline;white-space:pre-wrap"><br></=
span></p><p dir=3D"ltr" style=3D"line-height:1.38;margin-top:0pt;margin-bot=
tom:0pt"><span style=3D"font-size:11pt;font-family:Arial,sans-serif;font-va=
riant-ligatures:normal;font-variant-alternates:normal;font-variant-numeric:=
normal;font-variant-east-asian:normal;vertical-align:baseline;white-space:p=
re-wrap">Thanks for your time,</span></p><p dir=3D"ltr" style=3D"line-heigh=
t:1.38;margin-top:0pt;margin-bottom:0pt"><span style=3D"font-size:11pt;font=
-family:Arial,sans-serif;font-variant-ligatures:normal;font-variant-alterna=
tes:normal;font-variant-numeric:normal;font-variant-east-asian:normal;verti=
cal-align:baseline;white-space:pre-wrap">Honi</span></p></div>_____________=
__________________________________<br>
NumPy-Discussion mailing list -- <a href=3D"mailto:numpy-discussion@python.=
org" target=3D"_blank">[email protected]</a><br>
To unsubscribe send an email to <a href=3D"mailto:numpy-discussion-leave@py=
thon.org" target=3D"_blank">[email protected]</a><br>
<a href=3D"https://mail.python.org/mailman3//lists/numpy-discussion.python.=
org" rel=3D"noreferrer" target=3D"_blank">https://mail.python.org/mailman3/=
/lists/numpy-discussion.python.org</a><br>
Member address: <a href=3D"mailto:[email protected]" target=3D"_blank">=
[email protected]</a><br>
</blockquote></div></div>

--00000000000065d50906513c5fe4--

--===============1332769099764053574==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
NumPy-Discussion mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/numpy-discussion.python.org
Member address: [email protected]

--===============1332769099764053574==--