Repository navigation
Test NORTA correlation bounds and the doubly truncated normal fit - #35
Merged
Merged
Conversation
…mal fit Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Benchmarks
Kernels
End to endEach round is the command line in a fresh interpreter, start-up included. Peak RSS is the largest the child process reached over the rounds.
|
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.
Adds
tests/test_norta.py, which testsrupture_generator/sampling/norta.py. Only test files are changed.What the new tests check
NORMAL.applyreturns its input unchanged as float64, and integer input comes back as floats.latent_correlation(NORMAL, NORMAL, t)returnstunchanged.g(rho) = rho * corr(Z, h(Z)). The test computescorr(Z, h(Z))for a gamma(0.75) marginal with its ownscipy.integrate.quadand checkslatent_correlationagainsttarget / corrat several points. It also checks that swapping the two marginals gives the same answer.RuptureGeneratorError; both the ceiling and the floor side are tested. A target past the edge by less thanNORTA_CORRELATION_SLACKis clipped to latent correlation ±1.ValueErrorthe first time it is transformed. This is thecase unknownbranch._doubly_truncated_normal_locationgives a cut normal with mean 1, computed by direct quadrature of the normal pdf on[0, maximum];_doubly_truncated_normal_spreadmatches the quadrature coefficient of variation;apply. Its output is monotone and stays within[0, maximum], and the transformed standard normal has unit mean and the requested spread (Gauss-Hermite).Coverage of
norta.pyBoth remaining lines are left uncovered on purpose:
_distributionfornormal) can't be reached through the public API, becauseMarginal.applyreturns early for the normal marginal.Surviving mutants
_doubly_truncated_normalmutants 1–12 (dropping or garblinga,b,locorscale) are killed by the new tests. I checked each variant by patching it in through a scratch pytest plugin; every one fails 6–8 of the new doubly truncated normal tests. The existing tests intest_numerics.py(mean 1, support(0, maximum)) look like they should also have caught these. Mutmut's run reported 107 of 221 mutants as timeouts, so its test mapping for this module looks unreliable._doubly_truncated_normal_locationmutants:Noneor drop an argument. They crash inside SciPy or the root finder.+ 1.0) never brackets the root, so the search never ends.- 2.0) moves the cut mean to 2, which the quadrature mean check rejects.invalid="XXignoreXX"/"IGNORE") raiseValueErrorinnp.errstate.invalid=None) only stops a warning being silenced. With botherrstateguards removed, the fits for maxima 1.5, 2, 4.3 and 10 raised no floating-point warnings, so it changes nothing that can be observed.Issues filed
None. An unknown family string gets past
Marginal.__post_init__and only fails later, with aValueError(whose message has a typo, "Unimplementhed"). It can only arrive by going against theMarginalFamilytype hint, so I didn't file it as a bug.🤖 Generated with Claude Code