Skip to content

Improve Dimension.py documentation and input validation#50

Merged
pnorton-usgs merged 2 commits into
developmentfrom
refactor/dimension-improvements
May 11, 2026
Merged

Improve Dimension.py documentation and input validation#50
pnorton-usgs merged 2 commits into
developmentfrom
refactor/dimension-improvements

Conversation

@pnorton-usgs
Copy link
Copy Markdown
Member

Improve Dimension.py documentation and input validation

Summary

Improves Dimension.py with better documentation, corrected annotations, and hardened input validation for the size setter.

Changes

Documentation and annotations

  • Clarify __init__ docstring: document the meta parameter contract for strict vs non-strict modes
  • Fix __isub__ docstring typo: "ValeuError" → "ValueError"
  • Add -> bool return type annotation and docstring to is_fixed property

Bug fixes

  • Fix __repr__ to reflect the actual strict value used at construction instead of hardcoding False
  • Update corresponding test expectation

Input validation

  • Harden size setter with try/except around int() conversion
  • Non-numeric strings, None, lists, and other invalid types now produce clear error messages instead of raw Python conversion errors
  • numpy integer types (np.int32, np.int64) continue to work correctly
  • All invalid inputs still raise ValueError (backward compatible)

Testing

All 290 tests pass.

- Clarify __init__ docstring: document meta parameter contract for
  strict vs non-strict modes
- Fix __isub__ docstring typo: 'ValeuError' -> 'ValueError'
- Fix __repr__ to reflect actual strict value instead of hardcoding False
- Add return type annotation and docstring to is_fixed property
- Update test to match corrected repr output
- Wrap int() conversion in try/except to produce clear error messages
  for non-numeric strings, None, and other unconvertible types
- numpy integer types (int32, int64) continue to work correctly
- Maintains backward-compatible ValueError for all invalid inputs
- Update docstring to document accepted types and raised exceptions
@pnorton-usgs pnorton-usgs self-assigned this May 11, 2026
@pnorton-usgs pnorton-usgs merged commit 8e6373a into development May 11, 2026
7 checks passed
@pnorton-usgs pnorton-usgs deleted the refactor/dimension-improvements branch May 11, 2026 15:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant