-
Notifications
You must be signed in to change notification settings - Fork 148
Risk Trajectory Split 4 : Non-interpolated (Static) trajectories #1200
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
Open
spjuhel
wants to merge
22
commits into
develop
Choose a base branch
from
feature/static-risk-traj
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
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
This was referenced Dec 18, 2025
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.
As the Risk trajectory PR is too substantial, this is a fourth split.
This PR builds on PRs #1197 and #1199, introduces
RiskTrajectory, the abstract basis for trajectory objects, and the concrete classStaticRiskTrajectorywhich aims at facilitating the computation of risk metrics over multipleSnapshotobjects.The code is split between a high level interface
StaticRiskTrajectoryand a low level computing classCalcRiskMetricsPoint.RiskTrajectoryThe rationale behind this class is to hold the common code for any type of risk trajectory:
CalcRiskMetricPointThe rationale behind this class is to handle the computation and "data formatting" of different risk metrics over a collection of
Snapshot, following anImpactComputationStrategy(see PR #1199). In this case, without any interpolation, thus it is essentially a wrapper for multiple calls toImpactCalcor equivalent inImpactComputationStrategy.The class contains:
@lazy_propertyproperties, dictating how the foundational elements for risk metric should be computed (see below)calc_<risk_metric>methods (which are the ones called by theStaticRiskTrajectoryobject): these make use of the above and put them in nice and tidy dataframes.@lazy_propertyexplainedWe want to avoid recomputing when unnecessary, thus we have computed metrics and "impact data" as
@lazy_property, which cache the results of the computation. For instance, callingstatic_traj.per_date_aaithe first time computes the different requiredImpactobjects, stores them, and then the.aai_aggfor eachImpactand also store them.A subsequent call to
.per_date_aaireturn the previously stored value.In addition, a subsequent call to
.per_date_eaiwill reuse computedImpactobjects.The
@lazy_propertydecorator implements this memoization flow: it returns the cached_metricattribute if available. If not, it computes the value, stores it in_metric, and returns the result.Attributes that would change metric results (such as the computation strategy or the return periods to compute) make use of
@propertyto reset the cached data when their value is changed by calling_reset_impact_data.StaticRiskTrajectoryThis class is the interface with the user. It receives the list of snapshot to compute metrics for, and gives access to computed risk metrics and plots. It also handles the computation of net present values if a risk discount rate is provided.
It also uses a memoization flow for the "final" results.
PR Author Checklist
develop)PR Reviewer Checklist