Beispiel #1
0
def wdf_big():
    athlete = dataframes.Athlete(cp=200, w_prime=20000, weight=80)
    current_dir = os.path.dirname(os.path.abspath(__file__))
    wdf = dataframes.WorkoutDataFrame(
        pd.read_csv(os.path.join(current_dir, 'fixtures/workout_1.csv'))
    )
    wdf = wdf.set_index('time')
    wdf.athlete = athlete
    return wdf
Beispiel #2
0
def wdf():
    data = {
        'time': range(10),
        'heartrate': range(10),
        'power': range(10)}
    athlete = dataframes.Athlete(name='Chris', weight=80, ftp=300)
    wdf = dataframes.WorkoutDataFrame(data)
    wdf = wdf.set_index('time')
    wdf.athlete = athlete
    return wdf
Beispiel #3
0
    def test_is_valid_invalid_max_value(self):
        data = {
            'time': range(10),
            'heartrate': range(10),
            'power': range(10000, 10010)}
        wdf = dataframes.WorkoutDataFrame(data)
        wdf = wdf.set_index('time')

        with pytest.raises(exceptions.WorkoutDataFrameValidationException) as e:
            wdf.is_valid()
            assert e.message == '[.\n]*Column \'power\' has values > 3000[.\n]*'
Beispiel #4
0
    def test_is_valid_invalid_dtype(self):
        data = {
            'time': range(10),
            'heartrate': np.arange(0, 15, 1.5),
            'power': range(10)}
        wdf = dataframes.WorkoutDataFrame(data)
        wdf = wdf.set_index('time')

        with pytest.raises(exceptions.WorkoutDataFrameValidationException) as e:
            wdf.is_valid()
            assert e.message == '[.\n]*Column \'heartrate\' is not of dtype[.\n]*'
Beispiel #5
0
    def test_is_valid_invalid_sample_rate(self):
        data = {
            'time': range(0, 20, 2),
            'heartrate': range(10),
            'power': range(10)}
        wdf = dataframes.WorkoutDataFrame(data)
        wdf = wdf.set_index('time')

        with pytest.raises(exceptions.WorkoutDataFrameValidationException) as e:
            wdf.is_valid()
            assert e.message == '[.\n]*Sample rate is not \(consistent\) 1Hz[.\n]*'
Beispiel #6
0
    def test_empty_init(self):
        wdf = dataframes.WorkoutDataFrame()

        assert isinstance(wdf, pd.DataFrame)
        assert isinstance(wdf, dataframes.WorkoutDataFrame)