Skip to content

Commit

Permalink
fixes #327
Browse files Browse the repository at this point in the history
  • Loading branch information
jkbhagatio committed Feb 6, 2024
1 parent b99f658 commit 8071a40
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions aeon/io/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
import datetime
from os import PathLike
from pathlib import Path
import warnings

import numpy as np
import pandas as pd

"""The duration of each acquisition chunk, in whole hours."""
Expand Down Expand Up @@ -138,15 +140,11 @@ def load(root, reader, start=None, end=None, time=None, tolerance=None, epoch=No
_set_index(data)
if start is not None or end is not None:
try:
return data.loc[start:end]
start_idx, end_idx = np.where(data.index >= start)[0][0], np.where(data.index <= end)[0][-1]
return data.iloc[start_idx:end_idx]
except KeyError:
import warnings

if not data.index.has_duplicates:
warnings.warn(f"data index for {reader.pattern} contains out-of-order timestamps!")
data = data.sort_index()
else:
warnings.warn(f"data index for {reader.pattern} contains duplicate keys!")
data = data[~data.index.duplicated(keep="first")]
return data.loc[start:end]
return data.iloc[start_idx:end_idx]
return data

1 comment on commit 8071a40

@lochhh
Copy link
Contributor

@lochhh lochhh commented on 8071a40 Feb 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to do end_idx + 1 (details here)

Please sign in to comment.