Skip to content

Solve closest points once per fault pair in rupture propagation - #161

Merged
lispandfound merged 1 commit into
mainfrom
ai/issue-147
Oct 21, 2026
Merged

lispandfound merged 1 commit into
mainfrom
ai/issue-147

Conversation

@claude

@claude claude Bot commented Oct 21, 2026

Copy link
Copy Markdown

Closes #147

What was wrong: sample_rupture_propagation built its distance graph with a nested comprehension over ordered fault pairs, so sources.closest_point_between_sources (a least_squares solve) ran N·(N−1) times even though distance is symmetric and the result goes into an undirected nx.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_once wraps closest_point_between_sources to 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, where a comes first in sources_map order.

🤖 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:39
@lispandfound
lispandfound merged commit 8bed3b9 into main Oct 21, 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: sample_rupture_propagation solves closest points twice for every fault pair

1 participant