From adf02cfbb823d6b33b769243c85ac801118d513c Mon Sep 17 00:00:00 2001 From: TAU-Reinier <122060945+TAU-Reinier@users.noreply.github.com> Date: Thu, 7 Dec 2023 17:03:56 -0600 Subject: [PATCH] Use Field.copy on F in ZernikeFilter to prevent in-place modification The line `Fout = F` did not create a copy of F, just a second reference, and the line `Fout.field *= _np.exp(-1j * Ph)` modified the object referenced by both Fout and F, so the input Field also came out filtered. --- LightPipes/zernike.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/LightPipes/zernike.py b/LightPipes/zernike.py index 53d206d8..b325cb5b 100644 --- a/LightPipes/zernike.py +++ b/LightPipes/zernike.py @@ -204,10 +204,9 @@ def ZernikeFilter(F, j_terms, R): # Ph -= Ph_i Ph += Ph_i - Fout = F + Fout = Field.copy(F) Fout.field *= _np.exp(-1j * Ph) - # Fout = Field.copy(F) - # Fout = SubPhase(Ph, Fout) + return Fout