Allow getting derivative at arbitrary time points in tendency#14
Merged
SBlokhuizen merged 26 commits intodevelopfrom Feb 6, 2025
Merged
Allow getting derivative at arbitrary time points in tendency#14SBlokhuizen merged 26 commits intodevelopfrom
SBlokhuizen merged 26 commits intodevelopfrom
Conversation
maarten-ic
reviewed
Feb 6, 2025
Collaborator
maarten-ic
left a comment
There was a problem hiding this comment.
Nice start! I've got a couple of comments to polish the PR, let me know if anything's unclear 🙂
maarten-ic
reviewed
Feb 6, 2025
| else: | ||
| assert tendency.base == approx(expected_base) | ||
| assert tendency.amplitude == approx(expected_amplitude) | ||
| with ( |
Collaborator
There was a problem hiding this comment.
Let's move this to a fixture that's automatically used by all tests in this file?
@pytest.fixture(autouse=True)
def patch_periodic_base_tendency():
arr = np.array([0])
with (
patch.object(PeriodicBaseTendency, "get_value", return_value=(arr, arr)),
patch.object(PeriodicBaseTendency, "get_derivative", return_value=arr),
):
yield
maarten-ic
approved these changes
Feb 6, 2025
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.
This PR rewrites how derivatives are handled in the tendency classes. Before, you could only get the derivatives at the start or end of the tendency. This implementation extends this so the derivative can be obtain at any point in the tendency time range.
This might be necessary for example when using a repeated tendency, followed by a smooth tendency. The repeated tendency can end at any point in a tendency, and the smooth tendency should be able to match the derivative for the last tendency. For example:

Main changes in this PR:
get_derivative/get_valuemethods, these replace theget_start_value,get_end_value,get_start_derivativeandget_end_derivativemethods.get_value/get_derivativemethods. For clarity, I have changed these functions to only take in numpy arrays, and only output numpy arrays, at the expense that you have to map these back to a single float if only the at a single point is required.