Skip to content

Test magnitude scaling boundaries, warnings and random coefficients - #162

Merged
lispandfound merged 1 commit into
mainfrom
ai/tests
Oct 21, 2026
Merged

lispandfound merged 1 commit into
mainfrom
ai/tests

Conversation

@claude

@claude claude Bot commented Oct 21, 2026

Copy link
Copy Markdown

Tests-only change to tests/test_magnitude_scaling.py, covering source_modelling/magnitude_scaling.py.

What the new tests check

  • Leonard rake boundaries: leonard_area_to_magnitude uses the strike-slip constant (3.99) at exactly ±45° and ±135°, and the dip-slip constant (4.0) at ±46° and ±134°.

  • Leonard random coefficients: with a fixed seed, 2000 samples have the mean and standard deviation from Table 4 of the paper. That is 3.99 ± 0.26 for strike-slip and 4.03 ± 0.3 for dip-slip. The existing test only checked that the samples were normally distributed.

  • Contreras interface sign convention: the normal sample is mocked to a fixed deviation. contreras_interface_area_to_magnitude must then invert contreras_interface_magnitude_to_area exactly, and the area must equal exp(a1 + a2·M + δ).

  • Range warnings and boundaries:

    • Contreras interface area: no warning at 137.76 or 138; an exact message match below that.
    • Contreras interface magnitude, in both the area and aspect-ratio functions: warns at 5.9, not at 6.0.
    • Strasser slab area: no warning at 130 or 5212; warns at 129.9 and 5212.5.
    • Strasser slab magnitude: warns at 5.8 and 7.9.
    • Contreras slab aspect ratio: warns below magnitude 5.
    • Leonard width: warns outside the strike-slip range (3.4 to 19 km) and at or below the dip-slip limit of 5.4 km.

    Each of these tests also checks the value returned.

  • Aspect ratio values: the ratio is 1 below the hinge magnitude and exp(a3·(M − m1)) above it, for both the interface and slab relations.

  • Missing rake: magnitude_to_length_width, magnitude_to_area and area_to_magnitude raise ValueError for LEONARD2014 when no rake is given.

Coverage of magnitude_scaling.py

Before: 94%. Lines 250, 256, 400, 437, 522, 572, 613, 690, 735 and 773 were not covered.
After: 100%.

Surviving mutants

Killed (23):

  • leonard_area_to_magnitude mutants 6–11 and 13: the rake boundary comparisons and constants.
  • Mutants 20–23 and 32–35: loc or scale dropped or changed by 1. Caught by the sample mean and standard deviation test.
  • contreras_interface_area_to_magnitude mutants 2 and 3: the threshold changed to <= or 138.76.
  • Mutants 4–7: the warning message changed. Caught by the exact message match.
  • Mutant 28: - sigma_a changed to + sigma_a. Caught by the inversion test with a fixed deviation.
  • strasser_slab_area_to_magnitude mutants 3 and 5: the area bounds changed to 131 and 5213.

Equivalent (1):

  • contreras_interface_area_to_magnitude mutant 13 removes loc=0 from sp.stats.norm(loc=0, ...). The default loc is already 0, so the behaviour cannot change.

No issues filed.

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@claude claude Bot added ai-generated Opened by the scheduled Claude jobs ai-tests AI-written tests that need review labels Oct 21, 2026
@claude
claude Bot requested a review from lispandfound October 21, 2026 13:44
@lispandfound
lispandfound merged commit 1738e8a 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 ai-tests AI-written tests that need review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant