Skip to content

Commit

Permalink
Merge pull request #293 from pee-po/292-fix-yearly
Browse files Browse the repository at this point in the history
Resolve #292
  • Loading branch information
fboerman authored Jan 24, 2024
2 parents 245002e + 0845f4e commit 6805699
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions entsoe/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,28 +117,33 @@ def year_wrapper(*args, start=None, end=None, **kwargs):

blocks = year_blocks(start, end)
frames = []
is_first_frame = True # Assumes blocks are sorted
for _start, _end in blocks:
try:
frame = func(*args, start=_start, end=_end, **kwargs)
# Due to partial matching func may return data indexed by
# timestamps outside _start and _end. In order to avoid
# (unintentionally) repeating records, frames are truncated to
# left-open intervals. Additionally, second disjunct forces the
# earliest block to be a closed interval.
# left-open intervals (or closed interval in the case of the
# earliest block).
#
# If there are repeating records in a single frame (e.g. due
# to corrections) then the result will also have them.
interval_mask = (
((frame.index > _start) & (frame.index <= _end))
| (frame.index == start)
)
if is_first_frame:
interval_mask = frame.index <= _end
else:
interval_mask = (
(frame.index <= _end)
& (frame.index > _start)
)
frame = frame.loc[interval_mask]
except NoMatchingDataError:
logger.debug(
f"NoMatchingDataError: between {_start} and {_end}"
)
frame = None
frames.append(frame)
is_first_frame = False

if sum([f is None for f in frames]) == len(frames):
# All the data returned are void
Expand Down

0 comments on commit 6805699

Please sign in to comment.