Skip to content

Commit 7848764

Browse files
committed
Avoid unnecessary copies in _compute_wQISA_predictions()
1 parent eeb1363 commit 7848764

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/stripepy/utils/regressions.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33
# SPDX-License-Identifier: MIT
44

55
import numpy as np
6+
import numpy.typing as npt
67

78

8-
def _compute_wQISA_predictions(Y, k):
9-
9+
def _compute_wQISA_predictions(Y: npt.NDArray, k: int) -> npt.NDArray[float]:
10+
assert k >= 1
1011
# Control points of a weighted quasi-interpolant spline approximation with a k-NN weight function:
11-
kernel = np.full((k,), 1 / k)
12+
kernel = np.full(k, 1 / k)
1213
radius = (k - 1) // 2
13-
Y_ext = np.pad(Y.tolist(), (radius, radius), mode="edge")
14+
Y_ext = np.pad(Y, (radius, radius), mode="edge")
1415
predictions = np.convolve(Y_ext, kernel, "valid")
1516

1617
return predictions

0 commit comments

Comments
 (0)