Skip to content

Commit

Permalink
Merge pull request #175 from pfizer-opensource/development
Browse files Browse the repository at this point in the history
Version 0.16.11
  • Loading branch information
LukasAdamowicz authored Sep 30, 2024
2 parents e205e8f + 104985b commit db78d43
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 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.16.10.post1',
version: '0.16.11',
license: 'MIT',
meson_version: '>=1.1',
)
Expand Down
12 changes: 10 additions & 2 deletions src/skdh/io/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,17 @@ def wrapper_check_input_file(self, **kwargs):
return kwargs

# check file size if desired
if check_size and not hasattr(self, "_skip_file_size_check"):
if pfile.stat().st_size < 1000:
if pfile.stat().st_size < 1000:
if check_size and not hasattr(self, "_skip_file_size_check"):
raise FileSizeError("File is less than 1kb, nothing to read.")
elif hasattr(self, "_skip_file_size_check"):
warn(
f"File is less than 1kb, but the file size check has been "
f"skipped, returning empty dictionary: {file}",
UserWarning,
)
return {}


return func(self, **kwargs)

Expand Down
19 changes: 19 additions & 0 deletions src/skdh/io/multireader.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ def __init__(
fill_value=None,
gaps_error="raise",
require_all_keys=True,
ignore_file_size_check=True,
):
super().__init__(
mode=mode,
Expand All @@ -130,6 +131,8 @@ def __init__(
fill_gaps=fill_gaps,
fill_value=fill_value,
gaps_error=gaps_error,
require_all_keys=require_all_keys,
ignore_file_size_check=ignore_file_size_check,
)

# Set a variable here so that we can ignore file size checking when reading
Expand All @@ -148,6 +151,10 @@ def __init__(
self.rdr = getattr(io, reader)
self.reader_kw = reader_kw

# set an attribute if we want to skip file size checks
if ignore_file_size_check:
self.rdr._skip_file_size_check = True # just needs to be set to anything

self.resample_to_lowest = resample_to_lowest

self.fill_gaps = fill_gaps
Expand Down Expand Up @@ -196,6 +203,12 @@ def handle_combine(self, res):
res = [
v for _, v in res.items()
] # standardize since we dont care about labels

# drop any empty dictionaries - might occur due to some empty files
res = [i for i in res if i] # "if i" === "if i != {}"
# check now that we have any data
if not res:
raise ValueError("No data found in any of the files.")

# get the last time available
t_ends = [i["time"][-1] for i in res]
Expand Down Expand Up @@ -311,6 +324,12 @@ def handle_concatenation(self, res):
res = [
v for _, v in res.items()
] # standardize since we dont care about labels

# drop any empty dictionaries - might occur due to some empty files
res = [i for i in res if i] # "if i" === "if i != {}"
# check now that we have any data
if not res:
raise ValueError("No data found in any of the files.")

t0s = [i["time"][0] for i in res]
# get sorted index
Expand Down

0 comments on commit db78d43

Please sign in to comment.