Skip to content

Box, Position: Fix validation of shade_offset and refpoint - #4963

Merged
seisman merged 3 commits into
GenericMappingTools:mainfrom
tashakaggarwal:box-position-fix
Oct 25, 2026
Merged

seisman merged 3 commits into
GenericMappingTools:mainfrom
tashakaggarwal:box-position-fix

Conversation

@tashakaggarwal

Copy link
Copy Markdown
Contributor

Description of proposed changes

Two validation bugs in the new pygmt.params classes:

  1. Box(shade_offset=np.array([1, 2])) raises ValueError: The truth value of an array with more than one element is ambiguous, because shade_offset is tested with plain truthiness
    (if self.shade_offset and ..., self.shade_offset or []). The same truthiness test makes
    Box(shade_offset=[]) silently ignored rather than rejected as "not a sequence of two values".
    Now uses is not None.
  2. Position(["T", "L"], cstype="inside") (or "outside") raises TypeError: unhashable type: 'list' from the in _valid_anchors set lookup, instead of the intended GMTValueError. Now
    checks isinstance(refpoint, str) first.

Tests added for both.

@seisman

seisman commented Oct 24, 2026

Copy link
Copy Markdown
Member

@tashakaggarwal Thanks for your contributions. It seems this PR contains the commit 5ef9f4e, which is not relevant to this PR. Please discard that commit first.

This reverts commit 5ef9f4e.
@tashakaggarwal

Copy link
Copy Markdown
Contributor Author

@seisman commit discarded

@seisman seisman left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.

@seisman seisman added this to the 0.20.0 milestone Oct 24, 2026
@seisman seisman added maintenance Boring but important stuff for the core devs bug Something isn't working final review call This PR requires final review and approval from a second reviewer skip-changelog Skip adding Pull Request to changelog and removed maintenance Boring but important stuff for the core devs final review call This PR requires final review and approval from a second reviewer bug Something isn't working labels Oct 24, 2026
@seisman
seisman merged commit e96f272 into GenericMappingTools:main Oct 25, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintenance Boring but important stuff for the core devs skip-changelog Skip adding Pull Request to changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants