Skip to content

Add unit tests for Shaw-Dieterich probability graph helpers - #160

Merged
lispandfound merged 1 commit into
mainfrom
ai/issue-146
Oct 23, 2026
Merged

lispandfound merged 1 commit into
mainfrom
ai/issue-146

Conversation

@claude

@claude claude Bot commented Oct 21, 2026

Copy link
Copy Markdown

Closes #146

What was missing

shaw_dieterich_distance_model, prune_distance_graph and probability_graph in source_modelling/rupture_propagation.py had no direct unit tests. The only coverage came through sample_rupture_propagation, which checks tree structure and never looks at edge probabilities. So dropping the metres-to-km / 1000 (the same kind of units bug as #124), loosening the strict < cutoff, or removing the 0.99 cap would all have passed the suite.

What changed

Tests only. I added nine tests to tests/test_rupture_propagation.py, following the issue's suggestions:

  • shaw_dieterich_distance_model: returns 1 at distance == delta, returns exp(-1) at 4 km with d0=3, delta=1, and is clipped to 1 below delta.
  • prune_distance_graph: removes edges beyond the cutoff, also removes an edge exactly at the cutoff (the comparison is strict), and keeps faults with no remaining neighbours as empty dicts.
  • probability_graph: a distance of 4000 m gives a weight of exp(-1) (the model is evaluated in km), a distance of 0 m gives 0.99 rather than 1, and a node with no neighbours is still in the graph.

Verification

The library code is unchanged, so the new tests pass against it. To check they actually catch regressions, I made each of the three changes the issue names to the library code locally:

  • dropping / 1000
  • changing < to <=
  • changing the 0.99 cap to 1.0

Each one made the matching test fail, and I reverted the library code afterwards. The full suite passes (810 tests).

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@claude claude Bot added the ai-generated Opened by the scheduled Claude jobs label Oct 21, 2026
@claude
claude Bot requested a review from lispandfound October 21, 2026 13:34
@lispandfound
lispandfound merged commit 95ea446 into main Oct 23, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-generated Opened by the scheduled Claude jobs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rupture_propagation.py: add unit tests for shaw_dieterich_distance_model, prune_distance_graph and probability_graph (me

1 participant