Skip to content

Commit 56d63bf

Browse files
committed
Improve logging and process results in ts functions
1 parent 9cc4f98 commit 56d63bf

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

scdata/device/process/timeseries.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,17 @@ def poly_ts(dataframe, **kwargs):
3434
result = sum(coefficients[i]*channels[i]^exponents[i] + extra_term)
3535
"""
3636

37-
if 'channels' not in kwargs: return None
38-
else: channels = kwargs['channels']
37+
if 'channels' not in kwargs:
38+
logger.error('Problem with input data')
39+
return ProcessResult(None, StatusCode.ERROR_MISSING_INPUTS)
40+
else:
41+
channels = kwargs['channels']
3942
n_channels = len(channels)
4043

44+
if any([channel not in dataframe.columns for channel in channels]):
45+
logger.error("Channels not in dataframe")
46+
return ProcessResult(None, StatusCode.ERROR_MISSING_CHANNEL)
47+
4148
result = 0 * dataframe[channels[0]].copy()
4249

4350
if 'coefficients' not in kwargs: coefficients = ones(n_channels)
@@ -79,8 +86,10 @@ def clean_ts(dataframe, **kwargs):
7986
"""
8087

8188
if 'name' not in kwargs:
89+
logger.error('Problem with input data')
8290
return ProcessResult(None, StatusCode.ERROR_MISSING_INPUTS)
8391
if kwargs['name'] not in dataframe:
92+
logger.error(f"{kwargs['name']} not in dataframe")
8493
return ProcessResult(None, StatusCode.ERROR_MISSING_CHANNEL)
8594

8695
result = dataframe[kwargs['name']].copy()

0 commit comments

Comments
 (0)