Summary
In openpiv/gpu/validation.py, scalar mean validation appears to use the wrong tolerance parameter. The _mean_validation() method computes the local mean residual, but passes self.median_tol to _neighbour_validation() instead of self.mean_tol.
Current behaviour
Current code in Validation._mean_validation():
def _mean_validation(self):
for k in range(self._num_fields):
f_mean_residual = _gpu_residual(
self._mean[k],
self._neighbours[k],
self._neighbours_present,
"mean_residual",
)
self.val_locations = _neighbour_validation(
self._f[k],
self._mean[k],
f_mean_residual,
self.median_tol,
self.val_locations,
)
Expected Behaviour
Scalar mean validation should use self.mean_tol:
self.val_locations = _neighbour_validation(
self._f[k],
self._mean[k],
f_mean_residual,
self.mean_tol,
self.val_locations,
)
Why this looks like a bug
Validation.__init__ exposes separate median_tol and mean_tol parameters.
_median_validation() correctly uses self.median_tol.
_mean_validation_vec2d() correctly uses self.mean_tol.
_rms_validation() correctly uses self.rms_tol.
- The scalar
_mean_validation() path is the only path using another validation method's tolerance.
Impact
Users who configure mean_tol separately from median_tol get unexpected validation masks.
For example:
validation_method = "mean_velocity"
median_tol = 2
mean_tol = 5
The scalar validation still uses 2, not 5, making mean validation stricter than requested.
Suggested fix
Change this line in _mean_validation():
to:
Suggested test
Add a test where median_tol and mean_tol differ, then assert scalar mean validation matches a direct _neighbour_validation(..., tol=mean_tol) reference.
Current tests use default equal values (MEDIAN_TOL == MEAN_TOL == 2) in the direct mean-validation test, so the bug is masked.
Summary
In
openpiv/gpu/validation.py, scalar mean validation appears to use the wrong tolerance parameter. The_mean_validation()method computes the local mean residual, but passesself.median_tolto_neighbour_validation()instead ofself.mean_tol.Current behaviour
Current code in
Validation._mean_validation():Expected Behaviour
Scalar mean validation should use
self.mean_tol:Why this looks like a bug
Validation.__init__exposes separatemedian_tolandmean_tolparameters._median_validation()correctly usesself.median_tol._mean_validation_vec2d()correctly usesself.mean_tol._rms_validation()correctly usesself.rms_tol._mean_validation()path is the only path using another validation method's tolerance.Impact
Users who configure
mean_tolseparately frommedian_tolget unexpected validation masks.For example:
The scalar validation still uses
2, not5, making mean validation stricter than requested.Suggested fix
Change this line in
_mean_validation():to:
Suggested test
Add a test where
median_tolandmean_toldiffer, then assert scalar mean validation matches a direct_neighbour_validation(..., tol=mean_tol)reference.Current tests use default equal values (
MEDIAN_TOL == MEAN_TOL == 2) in the direct mean-validation test, so the bug is masked.