Repository navigation
Add tests for NaturalCubicFitting and reject negative knot times - #3063
Merged
lballabio merged 2 commits intoNov 14, 2026
Merged
Conversation
|
Thanks for opening this pull request! It might take a while before we look at it, so don't worry if there seems to be no feedback. We'll get to it. |
Allan-dq
force-pushed
the
natural-cubic-fitting-tests
branch
from
November 13, 2026 19:15
bc938ae to
a49ed03
Compare
|
Congratulations on your first merged pull request! |
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.
NaturalCubicFitting(#2378) has no tests in the suite. This adds three cases tofittedbonddiscountcurve.cpp:CubicNaturalSplinebetween them and is flat after the last one; knots can be passed unsorted and with duplicates;While writing them I found that a negative knot time was accepted. The constructor adds t = 0, sorts the knots and pins the discount factor at the first one to 1, so with knots
{-1, 1, 2}the constraint moved to t = -1 andd(0)became a free parameter. The constructor now rejects negative knot times.I also updated the class comment: it mentioned a
constrainAtZeroargument that the class does not have, and did not say that the curve is flat after the last knot.The calibration tolerances leave room over what I measured (2.7e-4 and 0.011 at most over 450 evaluation dates between 2015 and 2030).
I used an AI assistant while preparing this and have reviewed and run all of it myself.