Skip to content

Add stoch writing routine - #76

Merged
lispandfound merged 8 commits into
mainfrom
stoch_writing
Jul 22, 2026
Merged

Add stoch writing routine#76
lispandfound merged 8 commits into
mainfrom
stoch_writing

Conversation

@lispandfound

@lispandfound lispandfound commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Adds support for writing stoch files in an EMOD3D-compatible format. This is necessary for the Python port of srf2stoch. Necessary API change required to clean-up downstream implementation of srf2stoch tool.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds write support for stochastic slip model (“stoch”) files in an EMOD3D-compatible fixed-width format, and updates the StochFile API to support both parsing from disk and in-memory construction—needed to simplify the downstream Python port of srf2stoch.

Changes:

  • Refactors StochFile into a dataclass and introduces StochFile.from_file(...) for parsing.
  • Adds StochFile.dump(...) to write stoch files with fixed-width headers and arrays.
  • Expands/updates the stoch test suite to cover exact formatting and round-trip/idempotency behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
source_modelling/stoch.py Introduces from_file() + dump() and refactors StochFile to support writing EMOD3D-compatible output.
tests/test_stoch.py Updates construction to from_file() and adds comprehensive dump/round-trip/format tests.
Comments suppressed due to low confidence (1)

source_modelling/stoch.py:195

  • The from_file() docstring says it raises ValueError, but the implementation raises parse_utils.ParseError. This makes the public API documentation misleading for callers handling parse errors.
        ValueError
            If the number of planes specified in the file is not a positive integer.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread source_modelling/stoch.py
Comment thread tests/test_stoch.py
Comment thread source_modelling/stoch.py
Comment thread source_modelling/stoch.py
@lispandfound
lispandfound merged commit df65be6 into main Jul 22, 2026
7 checks passed
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.

4 participants