Repository navigation
Add unit tests for Shaw-Dieterich probability graph helpers - #160
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #146
What was missing
shaw_dieterich_distance_model,prune_distance_graphandprobability_graphinsource_modelling/rupture_propagation.pyhad no direct unit tests. The only coverage came throughsample_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 atdistance == delta, returnsexp(-1)at 4 km withd0=3, delta=1, and is clipped to 1 belowdelta.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 ofexp(-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:
/ 1000<to<=Each one made the matching test fail, and I reverted the library code afterwards. The full suite passes (810 tests).
🤖 Generated with Claude Code