Skip to content

Commit 7b4c779

Browse files
committed
Create copies of args to avoid in-place updates
1 parent 6acb140 commit 7b4c779

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

s2fft/transforms/spherical.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,9 @@ def inverse_numpy(
155155
m_start_ind = L - 1 if reality else 0
156156
L0 = L_lower
157157

158+
# Copy flm argument to avoid in-place updates being propagated back to caller
159+
flm = flm.copy()
160+
158161
# Apply harmonic normalisation
159162
flm[L0:] = np.einsum(
160163
"lm,l->lm", flm[L0:], np.sqrt((2 * np.arange(L0, L) + 1) / (4 * np.pi))

s2fft/transforms/wigner.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,9 @@ def inverse_numpy(
156156
)
157157
fban = np.zeros(samples.f_shape(L, N, sampling, nside), dtype=np.complex128)
158158

159+
# Copy flm argument to avoid in-place updates being propagated back to caller
160+
flmn = flmn.copy()
161+
159162
flmn[:, L_lower:] = np.einsum(
160163
"...nlm,...l->...nlm",
161164
flmn[:, L_lower:],

0 commit comments

Comments
 (0)