Skip to content

Commit eb02440

Browse files
authored
Merge pull request #290 from WenjieDu/dev
Updating load_dict_from_h5() and release v0.3
2 parents a432038 + 2ece024 commit eb02440

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

pypots/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#
2323
# Dev branch marker is: 'X.Y.dev' or 'X.Y.devN' where N is an integer.
2424
# 'X.Y.dev0' is the canonical version of 'X.Y.dev'
25-
__version__ = "0.2.1"
25+
__version__ = "0.3"
2626

2727

2828
from . import imputation, classification, clustering, forecasting, optim, data, utils

pypots/data/saving/h5.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from typing import Optional
1212

1313
import h5py
14-
import yaml
1514

1615
from ...utils.file import extract_parent_dir, create_dir_if_not_exist
1716
from ...utils.logging import logger
@@ -93,6 +92,10 @@ def load_dict_from_h5(
9392
) -> dict:
9493
"""Load the data from the given h5 file and return as a Python dictionary.
9594
95+
Notes
96+
-----
97+
This implementation was inspired by https://github.com/SiggiGue/hdfdict/blob/master/hdfdict/hdfdict.py#L93
98+
9699
Parameters
97100
----------
98101
file_path : str,
@@ -117,13 +120,12 @@ def load_set(handle, datadict):
117120
elif isinstance(item, h5py.Dataset):
118121
value = item[()]
119122
if "_type_" in item.attrs:
123+
# in case that datetime type of data was saved as timestamps
120124
if item.attrs["_type_"].astype(str) == "datetime":
121125
if hasattr(value, "__iter__"):
122126
value = [datetime.fromtimestamp(ts) for ts in value]
123127
else:
124128
value = datetime.fromtimestamp(value)
125-
elif item.attrs["_type_"].astype(str) == "yaml":
126-
value = yaml.safe_load(value.decode())
127129
datadict[key] = value
128130

129131
return datadict

0 commit comments

Comments
 (0)