Skip to content

Commit 9634bd9

Browse files
committed
fix: minor fixes from testing
1 parent 25d0d0a commit 9634bd9

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

climada/trajectories/risk_trajectory.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,9 @@ def default_rp(self):
122122
@default_rp.setter
123123
def default_rp(self, value):
124124
if not isinstance(value, list):
125-
ValueError("Return periods need to be a list of int.")
125+
raise ValueError("Return periods need to be a list of int.")
126126
if any(not isinstance(i, int) for i in value):
127-
ValueError("Return periods need to be a list of int.")
127+
raise ValueError("Return periods need to be a list of int.")
128128
self._return_periods_metrics = None
129129
self._all_risk_metrics = None
130130
self._default_rp = value
@@ -477,7 +477,7 @@ def _get_risk_periods(
477477
period
478478
for period in risk_periods
479479
if (
480-
start_date >= period.snapshot0.date or end_date <= period.snapshot1.date
480+
start_date <= period.snapshot0.date or end_date >= period.snapshot1.date
481481
)
482482
]
483483

@@ -803,9 +803,8 @@ def calc_npv_cash_flows(
803803
)
804804
tmp.index = df.index
805805
df = tmp.copy()
806-
df["discount_factor"] = (1 / (1 + df["rate"])) ** (
807-
(df.index - start_date).days // 365
808-
)
806+
start = pd.Timestamp(start_date)
807+
df["discount_factor"] = (1 / (1 + df["rate"])) ** ((df.index - start).days // 365)
809808

810809
# Apply the discount factors to the cash flows
811810
df["npv_cash_flow"] = df["cash_flow"] * df["discount_factor"]

0 commit comments

Comments
 (0)