Skip to content

Commit

Permalink
Merge pull request #135 from pfizer-opensource/development
Browse files Browse the repository at this point in the history
Version 0.13.2
  • Loading branch information
yiorg authored Jan 24, 2024
2 parents 7dfcac1 + 4714d7e commit d693574
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
project(
'scikit-digital-health',
'c',
version: '0.13.2a2',
version: '0.13.2',
license: 'MIT',
meson_version: '>=1.1',
)
Expand Down
18 changes: 15 additions & 3 deletions src/skdh/io/csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ def __init__(

@handle_process_returns(results_to_kwargs=True)
@check_input_file(".csv")
def predict(self, *, file, **kwargs):
def predict(self, *, file, tz_name=None, **kwargs):
"""
predict(*, file)
Expand All @@ -332,7 +332,10 @@ def predict(self, *, file, **kwargs):
Parameters
----------
file : {str, Path}
Path to the file to read
Path to the file to read.
tz_name : {None, str}, optional
Name of a time-zone to convert the timestamps to. Default is None,
which will leave them as naive.
Returns
-------
Expand All @@ -346,14 +349,23 @@ def predict(self, *, file, **kwargs):
If the file name is not provided.
"""

super().predict(expect_days=False, expect_wear=False, file=file, **kwargs)
super().predict(expect_days=False, expect_wear=False, file=file, tz_name=tz_name, **kwargs)

# load the file with pandas
raw = read_csv(file, **self.read_csv_kwargs)

# update the to_datetime_kwargs based on tz_name. tz_name==None (utc=False)
self.to_datetime_kw.update({"utc": tz_name is not None})

# convert time column to a datetime column. Give a unique name so we shouldnt overwrite
raw["_datetime_"] = to_datetime(raw[self.time_col_name], **self.to_datetime_kw)

# convert timestamps if necessary
if tz_name is not None:
# convert, and then remove the timezone so its naive again, but now in local time
tmp = raw["_datetime_"].dt.tz_convert(tz_name)
raw["_datetime_"] = tmp.dt.tz_localize(None)

# now handle data gaps and second level timestamps, etc
raw, fs = handle_timestamp_inconsistency(
raw, self.fill_gaps, self.acc_col_names, self.accel_in_g, self.g_value
Expand Down

0 comments on commit d693574

Please sign in to comment.