-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pass extrapolate to constructor #2049
Conversation
That's because passing the function argument is a way to override the setting only for that particular call. |
The disadvantage of this PR is that we're writing the default in a lot of places. I've seen forked codebases in which extrapolation is set as the default, and currently this can be done by flipping the default in |
Hmm, as mentioned I only see the extrapolate argument being passed to the check functions and not to the interpolate functions themselves. Maybe I'm looking in the wrong place but could you point out an example of where the extrapolate argument is overriding the value in the extrapolator? |
I count 97 places where the value is defaulted on the current master branch, but I understand the point. Perhaps we should find a better way to make this configurable so that forking is not required? I still think the two benefits I pointed out in the description are worth pursuing if possible. |
In |
Ouch. Can you point out a few? Changing the default in Extrapolator works, at least for term structures.
Yes, I thought about this while looking at this PR, but having a global switch would probably go in the direction of keeping the
Mind you, we wouldn't really get the first one. All term structures are passed around and stored as |
For example,
That's true for term structures, but other subclasses of |
Oh, ok, the overrides are defaulted to "don't override". At this point it seems like a lucky accident that the overrides only work when the default for the term structure is not to extrapolate...
Warning: I guess my actual question, though, is whether this is a worthwhile use of your time? The effort seems non trivial (also considering the three-states issue I mentioned) and the gain, well, not a lot. It doesn't even simplify the code. |
Yes, I understand that
It may not simplify the library code, but I think that my change does simplify user code, because the extra line to call Anyway as always the final decision is yours. I recognize that this PR is not as straightforward as I originally thought it would be. I will close it if you still think the cost outweighs the benefit. |
Don't worry, you're not that guy yet :) And no worries, let's skip this one. |
Currently extrapolation can only be enabled using the
Extrapolator::enableExtrapolation
method, but it's useful to be able to enable it when constructing the extrapolator for the following reasons:In order to keep this PR relatively small, there are some other subclasses of
Extrapolator
that I haven't yet changed, but I may create another PR to change those later.By the way, I notice that
extrapolate
is passed as a function argument to some functions likecheckRange
andcheckStrike
, but as far as I can tell there is nothing that enforces the value to be the same asExtrapolator::extrapolate_
. Is there a situation in which they can legitimately be different? If not, then how about we deprecate theextrapolate
function argument and use the value of the member variable directly?