Proposed feature: add custom lags parameters to correlate/convolve
Honi Sanders via NumPy-Discussion <[email protected]> Mon, 20 Apr 2026 15:22:32 -0400
| Newsgroups | gmane.comp.python.numeric.general |
|---|---|
| Message-ID | <[email protected]> |
--===============9165057652115921547== Content-Type: multipart/alternative; boundary="Apple-Mail=_362F5810-DD64-411D-BFF2-E0C1FE3048B0" --Apple-Mail=_362F5810-DD64-411D-BFF2-E0C1FE3048B0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 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] = <mailto:[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] <mailto:[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 = an 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 = standards. 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-correlati= on-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/dde076379dad6a51374625dbaa72= 9a71958d4d88/lib/matplotlib/axes/_axes.pyi#L218 Its current implementation calls numpy.correlate(..., 'full') and = discards the unwanted entries =E2=80=94 wasting a lot of calculations. = NumPy implementing 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 = convolutions at every lag (e.g. = https://docs.pytorch.org/docs/stable/generated/torch.nn.modules.conv.Conv1= d.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]/thread/J= MXNOCFQRFJYISFKSRI7MRL7GPK5ZD4S/ = https://mail.python.org/archives/list/[email protected]/thread/6= FC27XPOD4SBH3KJ7VY5DDAPS5Q46GPO/ (several people chimed in with interest = in the feature) Open question:=20 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 = 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? Thanks for your time, Honi= --Apple-Mail=_362F5810-DD64-411D-BFF2-E0C1FE3048B0 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8 <html><head><meta http-equiv=3D"content-type" content=3D"text/html; = charset=3Dutf-8"></head><body style=3D"overflow-wrap: break-word; = -webkit-nbsp-mode: space; line-break: after-white-space;">Your message = to the NumPy-Discussion mailing-list was rejected for the = following<br>reasons:<br><br>The message is not from a list = member<br><br>The original message as received by Mailman is = attached.<br><br><div style=3D"margin: 0px;"><span style=3D"font-family: = -webkit-system-font, "Helvetica Neue", Helvetica, sans-serif; = color: rgb(127, 127, 127);"><b>From: </b></span><span = style=3D"font-family: -webkit-system-font, "Helvetica Neue", = Helvetica, sans-serif;">Honi Sanders <<a = href=3D"mailto:[email protected]">[email protected]</a>><br><= /span></div><div style=3D"margin: 0px;"><span style=3D"font-family: = -webkit-system-font, "Helvetica Neue", Helvetica, sans-serif; = color: rgb(127, 127, 127);"><b>Subject: </b></span><span = style=3D"font-family: -webkit-system-font, "Helvetica Neue", = 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-system-font, "Helvetica = Neue", Helvetica, sans-serif; color: rgb(127, 127, = 127);"><b>Date: </b></span><span style=3D"font-family: = -webkit-system-font, "Helvetica Neue", 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, "Helvetica Neue", = Helvetica, sans-serif; color: rgb(127, 127, = 127);"><b>To: </b></span><span style=3D"font-family: = -webkit-system-font, "Helvetica Neue", Helvetica, = sans-serif;"><a = href=3D"mailto:[email protected]">[email protected]</a= ><br></span></div><br><br><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-east-asian: normal; font-variant-position: normal; = vertical-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 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; font-variant-position: 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-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-east-asian: normal; = font-variant-position: normal; vertical-align: baseline; white-space: = pre-wrap;">I'd like to solve a missing feature in np.correlate and = np.convolve.</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-east-asian: normal; font-variant-position: normal; = vertical-align: baseline; white-space: pre-wrap;">Sometimes when = computing a cross-correlation or convolution you 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; padding-inline-start: = 48px;"><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; = font-variant-position: normal; vertical-align: baseline; white-space: = pre;"><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; color: rgb(0, 0, 0); = font-variant-ligatures: normal; font-variant-alternates: normal; = font-variant-numeric: normal; font-variant-east-asian: normal; = font-variant-position: normal; vertical-align: baseline; white-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 = 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; = font-variant-position: normal; vertical-align: baseline; white-space: = pre;"><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; color: rgb(0, 0, 0); = font-variant-ligatures: normal; font-variant-alternates: normal; = font-variant-numeric: normal; font-variant-east-asian: normal; = font-variant-position: normal; vertical-align: baseline; white-space: = pre-wrap;">Having millisecond-precision time series but 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: = 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-east-asian: normal; = font-variant-position: normal; vertical-align: baseline; white-space: = pre-wrap;">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;"><span 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; = font-variant-position: normal; text-decoration: underline; = text-decoration-skip-ink: none; vertical-align: baseline; white-space: = pre-wrap;">https://github.com/numpy/numpy/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; = font-variant-numeric: normal; font-variant-east-asian: normal; = font-variant-position: normal; vertical-align: baseline; 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-decoration: none;"><span 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; = font-variant-position: normal; text-decoration: underline; = text-decoration-skip-ink: none; vertical-align: baseline; white-space: = pre-wrap;">PR #5978</span></a><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; font-variant-position: normal; = vertical-align: baseline; white-space: pre-wrap;">) that attracted = significant interest but I couldn'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/numpy/numpy/issues/5954" = style=3D"text-decoration: none;"><span 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; = font-variant-position: normal; text-decoration: underline; = text-decoration-skip-ink: none; vertical-align: baseline; white-space: = pre-wrap;">#5954</span></a><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; font-variant-position: normal; = vertical-align: baseline; white-space: pre-wrap;">) and SciPy (</span><a = href=3D"https://github.com/scipy/scipy/issues/4940" = style=3D"text-decoration: none;"><span 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; = font-variant-position: normal; text-decoration: underline; = text-decoration-skip-ink: none; 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: normal; font-variant-numeric: normal; = font-variant-east-asian: normal; font-variant-position: normal; = vertical-align: 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-decoration: none;"><span 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; = font-variant-position: normal; text-decoration: underline; = text-decoration-skip-ink: none; vertical-align: baseline; white-space: = pre-wrap;"> scipy-dev list</span></a><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; font-variant-position: normal; = vertical-align: baseline; white-space: pre-wrap;">, and got attention = on</span><a = href=3D"https://stackoverflow.com/questions/30677241/how-to-limit-cross-co= rrelation-window-width-in-numpy/47893831#47893831" = style=3D"text-decoration: none;"><span 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; = font-variant-position: normal; text-decoration: underline; = text-decoration-skip-ink: none; 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-numeric: normal; = font-variant-east-asian: normal; font-variant-position: normal; = vertical-align: baseline; white-space: pre-wrap;"> at the time. The = current open issue it resolves is</span><a = href=3D"https://github.com/numpy/numpy/issues/17286" = style=3D"text-decoration: none;"><span 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; = font-variant-position: normal; text-decoration: underline; = text-decoration-skip-ink: none; vertical-align: baseline; white-space: = pre-wrap;"> #17286</span></a><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; font-variant-position: normal; = vertical-align: baseline; white-space: pre-wrap;">.</span></p><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-family: Arial, sans-serif; font-variant-ligatures: normal; = font-variant-alternates: normal; font-variant-numeric: normal; = font-variant-east-asian: normal; font-variant-position: normal; = vertical-align: baseline; white-space: pre-wrap;">Proposed = API</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-east-asian: normal; font-variant-position: normal; = vertical-align: baseline; white-space: pre-wrap;">np.correlate(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-east-asian: normal; = font-variant-position: normal; vertical-align: baseline; white-space: = pre-wrap;">np.convolve(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-east-asian: normal; font-variant-position: 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-variant-east-asian: normal; font-variant-position: normal; = vertical-align: baseline; white-space: pre-wrap;">Parameter = design</span></p><ul style=3D"margin-top: 0px; margin-bottom: 0px; = padding-inline-start: 48px;"><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; font-variant-position: normal; = vertical-align: baseline; white-space: pre;"><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; color: rgb(0, 0, 0); font-variant-ligatures: normal; = font-variant-alternates: normal; font-variant-numeric: normal; = font-variant-east-asian: normal; font-variant-position: normal; = vertical-align: baseline; white-space: pre-wrap;">maxlag=3DM (int): = symmetric inclusive window [-M, M] (2M+1 lags total). Matches MATLAB's = xcorr(x, y, M) convention.</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; font-variant-position: normal; = vertical-align: baseline; white-space: pre;"><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; color: rgb(0, 0, 0); font-variant-ligatures: normal; = font-variant-alternates: normal; font-variant-numeric: normal; = font-variant-east-asian: normal; font-variant-position: normal; = 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 arithmetic 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; font-variant-position: normal; = vertical-align: baseline; white-space: pre;"><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; color: rgb(0, 0, 0); font-variant-ligatures: normal; = font-variant-alternates: normal; font-variant-numeric: normal; = font-variant-east-asian: normal; font-variant-position: normal; = vertical-align: baseline; white-space: = pre-wrap;">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.</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-family: Arial, sans-serif; font-variant-ligatures: normal; = font-variant-alternates: normal; font-variant-numeric: normal; = font-variant-east-asian: normal; font-variant-position: normal; = vertical-align: baseline; white-space: pre-wrap;">Related library = notes</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-east-asian: normal; font-variant-position: normal; = vertical-align: baseline; white-space: pre-wrap;">Matplotlib 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"https://github.com/matplotlib/matplotlib/blob/dde076379dad6a513746= 25dbaa729a71958d4d88/lib/matplotlib/axes/_axes.pyi#L218" = style=3D"text-decoration: none;"><span 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; = font-variant-position: normal; text-decoration: underline; = text-decoration-skip-ink: none; vertical-align: baseline; white-space: = pre-wrap;">https://github.com/matplotlib/matplotlib/blob/dde076379dad6a513= 74625dbaa729a71958d4d88/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-variant-alternates: = normal; font-variant-numeric: normal; font-variant-east-asian: normal; = font-variant-position: normal; vertical-align: baseline; white-space: = pre-wrap;">Its current implementation calls numpy.correlate(..., 'full') = and discards the unwanted entries =E2=80=94 wasting a lot of = calculations. NumPy implementing this feature would allow Matplotlib to = immediately benefit in performance without changing their existing API = by just updating the numpy correlate call.</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-east-asian: normal; = font-variant-position: normal; vertical-align: baseline; white-space: = pre-wrap;">Neural network libraries like Pytorch and </span><span = style=3D"caret-color: rgb(31, 35, 40); color: rgb(31, 35, 40); = font-family: "Mona Sans VF", -apple-system, = BlinkMacSystemFont, "Segoe UI", "Noto Sans", = Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe = UI Emoji"; font-size: 14px; orphans: 2; widows: 2; = 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. </span><a = href=3D"https://docs.pytorch.org/docs/stable/generated/torch.nn.modules.co= nv.Conv1d.html" rel=3D"nofollow" style=3D"box-sizing: border-box; color: = rgb(0, 0, 0); text-underline-offset: 0.2rem; font-family: "Mona = Sans VF", -apple-system, BlinkMacSystemFont, "Segoe UI", = "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color = Emoji", "Segoe UI Emoji"; font-size: 14px; orphans: 2; = widows: = 2;">https://docs.pytorch.org/docs/stable/generated/torch.nn.modules.conv.C= onv1d.html</a><span style=3D"caret-color: rgb(31, 35, 40); color: = rgb(31, 35, 40); font-family: "Mona Sans VF", -apple-system, = BlinkMacSystemFont, "Segoe UI", "Noto Sans", = Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe = UI Emoji"; font-size: 14px; orphans: 2; widows: 2; = background-color: rgb(255, 255, 255);">), similar to the stride entry in = the range construction for the lags parameter proposed = here.</span></p><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-family: Arial, sans-serif; = font-variant-ligatures: normal; font-variant-alternates: normal; = font-variant-numeric: normal; font-variant-east-asian: normal; = font-variant-position: normal; vertical-align: baseline; white-space: = pre-wrap;">Previous discussions on this list</span></p><ul = style=3D"margin-top: 0px; margin-bottom: 0px; padding-inline-start: = 48px;"><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; = font-variant-position: normal; vertical-align: baseline; white-space: = pre;"><p dir=3D"ltr" role=3D"presentation" style=3D"line-height: 1.38; = margin-top: 0pt; margin-bottom: 0pt;"><a = href=3D"https://mail.python.org/archives/list/[email protected]/= thread/JMXNOCFQRFJYISFKSRI7MRL7GPK5ZD4S/" style=3D"text-decoration: = none;"><span 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; font-variant-position: normal; = text-decoration: underline; text-decoration-skip-ink: none; = vertical-align: baseline; white-space: = pre-wrap;">https://mail.python.org/archives/list/[email protected]= rg/thread/JMXNOCFQRFJYISFKSRI7MRL7GPK5ZD4S/</span></a></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; = font-variant-position: normal; vertical-align: baseline; white-space: = pre;"><p dir=3D"ltr" role=3D"presentation" style=3D"line-height: 1.38; = margin-top: 0pt; margin-bottom: 0pt;"><a = href=3D"https://mail.python.org/archives/list/[email protected]/= thread/6FC27XPOD4SBH3KJ7VY5DDAPS5Q46GPO/" style=3D"text-decoration: = none;"><span 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; font-variant-position: normal; = text-decoration: underline; text-decoration-skip-ink: none; = vertical-align: baseline; white-space: = pre-wrap;">https://mail.python.org/archives/list/[email protected]= rg/thread/6FC27XPOD4SBH3KJ7VY5DDAPS5Q46GPO/</span></a><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-variant-numeric: normal; font-variant-east-asian: normal; = font-variant-position: 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><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-family: Arial, sans-serif; = font-variant-ligatures: normal; font-variant-alternates: normal; = font-variant-numeric: normal; font-variant-east-asian: normal; = font-variant-position: 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-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-east-asian: normal; font-variant-position: normal; = vertical-align: baseline; white-space: pre-wrap;">Open = question: </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-east-asian: normal; font-variant-position: normal; = vertical-align: baseline; white-space: pre-wrap;">C API</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-east-asian: normal; = font-variant-position: normal; vertical-align: baseline; white-space: = pre-wrap;">The PR also adds PyArray_CorrelateLags to the C API. <span = style=3D"white-space: normal; caret-color: rgb(5, 12, 20); color: rgb(5, = 12, 20); font-family: "Mona Sans VF", -apple-system, = BlinkMacSystemFont, "Segoe UI", "Noto Sans", = Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe = UI Emoji"; font-size: 14px; orphans: 2; widows: 2;">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. = </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-variant-alternates: normal; = font-variant-numeric: normal; font-variant-east-asian: normal; = font-variant-position: normal; 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-variant-ligatures: normal; font-variant-alternates: normal; = font-variant-numeric: normal; font-variant-east-asian: normal; = font-variant-position: normal; vertical-align: baseline; white-space: = pre-wrap;">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-size: 11pt; font-family: = Arial, sans-serif; font-variant-ligatures: normal; = font-variant-alternates: normal; font-variant-numeric: normal; = font-variant-east-asian: normal; font-variant-position: 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-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-east-asian: normal; = font-variant-position: 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-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-east-asian: normal; font-variant-position: normal; = vertical-align: baseline; white-space: pre-wrap;">Thanks for your = time,</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-east-asian: normal; font-variant-position: normal; = vertical-align: baseline; white-space: = pre-wrap;">Honi</span></p></body></html>= --Apple-Mail=_362F5810-DD64-411D-BFF2-E0C1FE3048B0-- --===============9165057652115921547== 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] --===============9165057652115921547==--