Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions lilio/calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,18 +376,19 @@ def _concatenate_periods(self, year, list_periods, is_target):
# loop through all the building blocks to
for block in list_periods:
left_date += block.gap_dateoffset
right_date = left_date + block.length_dateoffset
intervals.append(pd.Interval(left_date, right_date, closed="left"))
# -1 day because now closed on both sides
right_date = left_date + block.length_dateoffset - DateOffset(days=1)
intervals.append(pd.Interval(left_date, right_date, closed="both"))
# update left date
left_date = right_date
else:
# build from right to left
right_date = self._get_anchor(year)
# loop through all the building blocks to
for block in list_periods:
right_date -= block.gap_dateoffset
right_date -= block.gap_dateoffset - DateOffset(days=1)
left_date = right_date - block.length_dateoffset
intervals.append(pd.Interval(left_date, right_date, closed="left"))
intervals.append(pd.Interval(left_date, right_date, closed="both"))
# update right date
right_date = left_date

Expand Down
4 changes: 3 additions & 1 deletion lilio/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,9 @@ def infer_input_data_freq(
)

data_freq = ( # Deal with yearly timedelta case
replace_year_length(data_freq) if "A" in data_freq else data_freq
replace_year_length(data_freq)
if "A" in data_freq or "Y" in data_freq
else data_freq
)

return pd.Timedelta(data_freq)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ classifiers = [
dependencies = [
"netcdf4",
"numpy",
"pandas",
"pandas < 2.2",
"matplotlib",
"xarray",
"scikit-learn",
Expand Down