Esempio n. 1
0
    def max_value_maintained_for_n_minutes(self, activity_df, measurement='heartrate', window_size=5):
        all_max_values = [float('NaN')] * len(activity_df)

        for i in range(len(activity_df)):
            stream_df = load_stream(self.database_driver, activity_df.strava_id[i], '%s' % measurement)
            if stream_df is not None:
                min_index = stream_df.index.min()
                all_max_values[i] = np.nanmax(
                    [stream_df[measurement].loc[subtract_n_minutes(second,
                                                                   minutes=window_size,
                                                                   minimum_value=min_index):second].min()
                     for second in stream_df.index])

        activity_df['max_%s_%d_minutes' % (measurement, window_size)] = all_max_values
        return activity_df
Esempio n. 2
0
 def test_subtract_5_minutes_negative_result(self):
     """Should not return negative values, but default to a minimum of 0"""
     self.assertEqual(subtract_n_minutes(99), 0)
Esempio n. 3
0
 def test_subtract_1_minute(self):
     """Should return result for a provided amount of minutes to be subtracted"""
     self.assertEqual(subtract_n_minutes(423, 1), 363)
Esempio n. 4
0
 def test_subtract_5_minutes(self):
     """Should default to 5 minutes"""
     self.assertEqual(subtract_n_minutes(423), 123)
Esempio n. 5
0
 def test_subtract_5_minutes_minimum_value(self):
     """Should return the provided minimum value in case of negative result"""
     self.assertEqual(subtract_n_minutes(99, minimum_value=50), 50)