Conversation
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
pygmt/src/grdmask.py
Outdated
| edge, description="edge", reason=f"edge={edge!r} requires inside={edge!r}." | ||
| ) | ||
|
|
||
| if inside in _inside_modes and edge in _inside_modes and inside != edge: |
There was a problem hiding this comment.
I feel this check is the same as the one above. Am I misunderstanding something?
There was a problem hiding this comment.
You understood correctly; the code you're writing now does contain duplicates. It's likely a mistake made while trying to solve formatting issues. The real intention was to check that when inside is a character pattern (like z or id), edge must be None or exactly the same as inside, preventing users from sending arbitrary numbers to edge.
There was a problem hiding this comment.
Actually, I meant if we should delete this check.
There was a problem hiding this comment.
No. The first protection is that edge has a special value ("z"/"id"), but inside doesn't match.
The second protection is that inside has a special value, but edge provides a value that doesn't match.
There was a problem hiding this comment.
Why not just check both cases like below:
if (inside in _inside_modes or edge in _inside_modes) and inside != edge:
...
There was a problem hiding this comment.
But it will rejects a valid case: inside set to z/id with edge unset (None).
There was a problem hiding this comment.
Let me think of a simpler and clearer way to express it.
Replace #4428