fix: correct misplaced parentheses in _Spatialslip zeta corrections#2743
Open
steps-re wants to merge 1 commit into
Open
fix: correct misplaced parentheses in _Spatialslip zeta corrections#2743steps-re wants to merge 1 commit into
steps-re wants to merge 1 commit into
Conversation
In the 3D branch of _Spatialslip, the four vertical (zeta) slip corrections
had a misplaced closing parenthesis, e.g.:
is_land(0, 0, 1, 0 & is_land(0, 0, 1, 1) & (zeta > 0))
so the `& is_land(...) & (zeta > 0)` mask meant to gate np.where was instead
swallowed into is_land's 4th positional argument (the x-index). Both the land
test and the zeta position gate were therefore wrong, breaking the vertical
free-/partial-slip boundary correction for 3D C-grid velocities.
Fixed to match the analogous, correctly-formed eta/xsi corrections in the same
function:
is_land(0, 0, 1, 0) & is_land(0, 0, 1, 1) & (zeta > 0)
Existing interpolation and convert tests pass.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
In the 3D branch of
_Spatialslip(src/parcels/interpolators/_xinterpolators.py), the four vertical (zeta) slip corrections have a misplaced closing parenthesis:The
)afteris_land(0, 0, 1, 0is missing, so0 & is_land(0, 0, 1, 1) & (zeta > 0)is passed asis_land's 4th positional argument (the x-index) instead of0. The& is_land(...) & (zeta > 0)mask that should gatenp.whereis swallowed into that argument, so both the land test and thezetaposition gate are wrong. This breaks the vertical free-/partial-slip boundary correction for 3D C-grid velocities.Fix
Move the parenthesis so each line matches the analogous, correctly-formed
eta/xsicorrections in the same function:Same correction applied to all four affected lines (the
zeta > 0andzeta < 1gates forf_uandf_v).Testing
pytest tests/test_interpolation.py tests/test_convert.pypasses (29 passed, 1 xfailed) with the change. Note thecgrid_velocitycase intest_interpolation.pyis currently commented out, which is likely why this went unnoticed.