Open Vaeliss opened 8 months ago
Clearly, in such case the function sleep.get_sleep_timestamps
should be uniformed to the other to call simply sleep.get_sleep_statistic
and delegate the actual computation to the new function sleep._compute_sleep_timestamps
@Vaeliss at the moment we have:
get_bedtime
get_wakeup_time
that work with the same principle of all the other sleep statistics.Do you think that the function get_sleep_timestamps
, which is the only one that is different from all the others, should still be left in the module? As it does not offer any of the new features (kind
, return_df
, and so on), I see two options here:
I'd probably remove it, as you said now that we have get_bedtime
and get_wakeup_time
, it's redundant.
However, it's used in several other modules for now (cardiac for hrv stats, stress module, and the labfront loader), so we need to remove it and at the same time substitute it with the two funcs above in those cases.
At the moment bedtime and wake-up time are not returned in the general
pywearable.sleep.get_sleep_statistics
. They should be added.In order to do so a
sleep._compute_sleep_timestamp
must be added, which will require asleep_summary
parameter as other compute functions. The main difference to take into account for the calculation of statistics is that the parameterkind
can't be applied directly as it is the case for other sleep statistics but must be mapped to functions in theutils
module such asutils.get_earliest_bedtime
etc..This mapping could be done by creating a dictionary (
kind_mapping
) for the mapping which includes only the sleep metrics which have a different behavior w.r.t. thekind
parameter. Whenkind
needs to be applied for the calculation of sleep_statistics it should be simply proceeded by something likekind = kind_mapping.get(sleep_metric, kind)
so that for metrics which require a different treatment, such as bedtime and wake-up time, the proper function is used.