Skip to content

Improve summary module#58

Merged
pnorton-usgs merged 11 commits into
developmentfrom
improve-summary-module
May 19, 2026
Merged

Improve summary module#58
pnorton-usgs merged 11 commits into
developmentfrom
improve-summary-module

Conversation

@pnorton-usgs
Copy link
Copy Markdown
Member

Improve summary module

Refactor and harden the pyPRMS/summary/ module (OutputCSV, OutputVariable, OutputVariables) with code quality improvements and initial test coverage.

Changes

Code quality

  • Modernize type hints to Python 3.10+ syntax (X | None, dict, list)
  • Remove redundant (object) inheritance from all summary classes
  • Add missing docstrings and return type annotations
  • Add __all__ export lists to each summary submodule
  • Add __repr__ methods to all summary classes

Error handling

  • Add file existence checks in OutputCSV and OutputVariable constructors (raise FileNotFoundError with descriptive message)
  • Use descriptive KeyError messages in OutputVariables.get() and write_netcdf()

Refactoring

  • Decompose OutputVariable.to_xarray() into focused helper methods (_resolve_dim_name, _build_data_array, _set_time_encoding, _set_variable_attrs) with module-level constants
  • Replace match statement with if for Python 3.10 compatibility
  • Move is_global metadata mutation out of cached_property into a dedicated _set_global_flags() method

Tests

  • Add functional tests for OutputCSV covering streamflow-only and combined basin+streamflow CSV formats
  • Add tests for OutputVariables reading and variable access
  • Add tests for FileNotFoundError handling in both OutputCSV and OutputVariable

Target branch

development

Testing

All 301 tests pass.

@pnorton-usgs pnorton-usgs self-assigned this May 19, 2026
@pnorton-usgs pnorton-usgs merged commit 5d801f4 into development May 19, 2026
14 checks passed
@pnorton-usgs pnorton-usgs deleted the improve-summary-module branch May 19, 2026 15:56
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