Repository navigation
Solve closest points once per fault pair in rupture propagation - #161
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 #147
What was wrong:
sample_rupture_propagationbuilt its distance graph with a nested comprehension over ordered fault pairs, sosources.closest_point_between_sources(aleast_squaressolve) ran N·(N−1) times even though distance is symmetric and the result goes into an undirectednx.Graph. Independent solves of (a, b) and (b, a) could also return slightly different distances, so near the jump cutoff one direction could be pruned and the other kept.What changed: the distance graph is now built over
itertools.combinations(sources_map.items(), 2), computing each distance once and storing it under both[a][b]and[b][a]. It is initialised as{name: {} for name in sources_map}, so faults with no neighbours still appear as nodes. The probability model is unchanged. The only numerical difference is that the (a, b) and (b, a) distances are now exactly equal.Tests:
test_sample_rupture_propagation_solves_each_pair_oncewrapsclosest_point_between_sourcesto count calls, using four sources. Before the fix it saw 12 calls instead of the expected 6. It now passes, and so does the full suite (802 passed).Reviewer notes: for each pair, the closest points are now solved only in
(a, b)order, whereacomes first insources_maporder.🤖 Generated with Claude Code