From 33e92630e832b94f5c3539f110a9c22846dbc850 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 18 May 2026 21:04:40 +0000 Subject: [PATCH 1/2] Initial plan From b5405a1c25f1b9082714d8ed5925aed01554b584 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 18 May 2026 21:08:28 +0000 Subject: [PATCH 2/2] Fix GPU S2N validation: shape mismatch and inverted threshold logic Agent-Logs-Url: https://github.com/OpenPIV/openpiv-python-gpu/sessions/fd3e43b8-3215-44e6-83fc-1b78b7dc77c7 Co-authored-by: alexlib <747110+alexlib@users.noreply.github.com> --- openpiv/gpu/process.py | 2 +- openpiv/gpu/validation.py | 6 ++++-- openpiv/test/gpu/test_validation.py | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/openpiv/gpu/process.py b/openpiv/gpu/process.py index 7d68413..68a0a4c 100755 --- a/openpiv/gpu/process.py +++ b/openpiv/gpu/process.py @@ -1146,7 +1146,7 @@ def _validate_fields(self, u, v, dp_u, dp_v): if self.num_validation_iters == 0: return u, v, val_locations if "s2n" in self.validation_method: - s2n_ratio = self._corr_gpu.s2n_ratio + s2n_ratio = self._corr_gpu.s2n_ratio.reshape(u.shape) # Create the validation object. self._validation_gpu = Validation( diff --git a/openpiv/gpu/validation.py b/openpiv/gpu/validation.py index e129f63..6d8e646 100644 --- a/openpiv/gpu/validation.py +++ b/openpiv/gpu/validation.py @@ -448,8 +448,10 @@ def _s2n_validation(self, s2n_ratio): return s2n_tol = log10(self.s2n_tol) - sig2noise_tol = s2n_ratio / DTYPE_f(s2n_tol) - self.val_locations = _local_validation(sig2noise_tol, 1, self.val_locations) + # Mark invalid where s2n_ratio < s2n_tol, i.e. (s2n_tol - s2n_ratio) > 0. + self.val_locations = _local_validation( + DTYPE_f(s2n_tol) - s2n_ratio, 0, self.val_locations + ) def _mask_val_locations(self): """Removes masked locations from the validation locations.""" diff --git a/openpiv/test/gpu/test_validation.py b/openpiv/test/gpu/test_validation.py index 3dfbe40..1749941 100644 --- a/openpiv/test/gpu/test_validation.py +++ b/openpiv/test/gpu/test_validation.py @@ -205,7 +205,7 @@ def test_validation_median_num_validation_locations(validation_gpu, peaks_reshap def test_validation_s2n_validation(validation_gpu, s2n_ratio): tol = log10(validation.S2N_TOL) - val_locations = validation._local_validation(s2n_ratio / tol, 1).get() + val_locations = validation._local_validation(DTYPE_f(tol) - s2n_ratio, 0).get() validation_gpu._s2n_validation(s2n_ratio) val_locations_gpu = validation_gpu.val_locations.get()