Skip to content
Draft
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
19 changes: 14 additions & 5 deletions aeon/datasets/_tss_data_loaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"load_human_activity_segmentation_datasets",
]

from ast import literal_eval
from os import PathLike
from pathlib import Path

Expand Down Expand Up @@ -94,7 +95,7 @@ def load_time_series_segmentation_benchmark(

# converters to correctly load benchmark
np_cols = ["change_points", "time_series"]
converters = {col: lambda val: np.array(eval(val)) for col in np_cols}
converters = {col: _parse_np_array for col in np_cols}

# load benchmark from git repo (and save locally) / or load locally
if not benchmark_path.exists():
Expand Down Expand Up @@ -209,10 +210,7 @@ def load_human_activity_segmentation_datasets(
"lon",
"speed",
]
converters = {
col: lambda val: np.array([]) if len(val) == 0 else np.array(eval(val))
for col in np_cols
}
converters = {col: _parse_np_array for col in np_cols}

# load activity data from git repo (and save locally) / or load locally
if not benchmark_path.exists():
Expand Down Expand Up @@ -272,3 +270,14 @@ def load_human_activity_segmentation_datasets(
return X, y, metadata

return X, y


def _parse_np_array(val):
if len(val) == 0:
return np.array([])
try:
return np.array(literal_eval(val))
except (ValueError, SyntaxError) as exc:
raise ValueError(
f"Invalid array literal in segmentation dataset CSV: {val!r}"
) from exc
9 changes: 2 additions & 7 deletions aeon/datasets/rehabpile_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,13 +289,8 @@ def load_rehab_pile_dataset(
f"name and your internet connection. Error: {e}"
) from e

X = np.load(dataset_path_fold / files_to_load["X"], allow_pickle=True)
y = np.load(dataset_path_fold / files_to_load["y"], allow_pickle=True)

# Correct issue with pickle loading, ensuring all items are numpy arrays

X = np.array(X.tolist())
y = np.array(y.tolist())
X = np.load(dataset_path_fold / files_to_load["X"])
y = np.load(dataset_path_fold / files_to_load["y"])

if return_meta:
meta_path = dataset_path_meta / "info.json"
Expand Down
Loading