passing tests
This commit is contained in:
@@ -685,7 +685,6 @@ def replace_zeros_with_nan(x):
|
||||
def clean_df_stats_pl(datadf, workstrokesonly=True, ignorehr=True,
|
||||
ignoreadvanced=False, for_chart=False):
|
||||
# clean data remove zeros and negative values
|
||||
|
||||
try:
|
||||
_ = datadf['workoutid'].unique()
|
||||
except KeyError:
|
||||
@@ -2047,8 +2046,14 @@ def dataplep(rowdatadf, id=0, inboard=0.88, forceunit='lbs', bands=True, barchar
|
||||
df = df.with_columns((500./pl.col(' Stroke500mPace (sec/500m)')).alias(' AverageBoatSpeed (m/s)'))
|
||||
if ' WorkoutState' not in df.columns:
|
||||
df = df.with_columns((pl.lit(0)).alias(" WorkoutState"))
|
||||
df = df.with_columns((100.*pl.col(" DriveTime (ms)")/(pl.col(" DriveTime (ms)")+pl.col(" StrokeRecoveryTime (ms)"))).alias("rhythm"))
|
||||
df = df.with_columns((pl.col(" AverageDriveForce (lbs)")/pl.col(" PeakDriveForce (lbs)")).alias("forceratio"))
|
||||
if df[" DriveTime (ms)"].mean() > 0:
|
||||
df = df.with_columns((100.*pl.col(" DriveTime (ms)")/(pl.col(" DriveTime (ms)")+pl.col(" StrokeRecoveryTime (ms)"))).alias("rhythm"))
|
||||
else:
|
||||
df = df.with_columns((pl.lit(0)).alias("rhythm"))
|
||||
if df[" PeakDriveForce (lbs)"].mean() > 0:
|
||||
df = df.with_columns((pl.col(" AverageDriveForce (lbs)")/pl.col(" PeakDriveForce (lbs)")).alias("forceratio"))
|
||||
else:
|
||||
df = df.with_columns((pl.lit(0)).alias("forceratio"))
|
||||
f = df['TimeStamp (sec)'].diff().mean()
|
||||
if f != 0 and not np.isinf(f):
|
||||
try:
|
||||
@@ -2085,6 +2090,9 @@ def dataplep(rowdatadf, id=0, inboard=0.88, forceunit='lbs', bands=True, barchar
|
||||
pass
|
||||
|
||||
df = df.with_columns((pl.col(" DriveLength (meters)") / pl.col(" DriveTime (ms)") * 1.0e3).alias("drivespeed"))
|
||||
if df[" DriveTime (ms)"].mean() == 0:
|
||||
df = df.with_columns((pl.lit(0)).alias("drivespeed"))
|
||||
|
||||
|
||||
if 'driveenergy' not in df.columns:
|
||||
if forceunit == 'lbs':
|
||||
@@ -2213,6 +2221,8 @@ def dataplep(rowdatadf, id=0, inboard=0.88, forceunit='lbs', bands=True, barchar
|
||||
|
||||
ergpw = 2.8*data['velo']**3
|
||||
efficiency = 100. * ergpw / data['power']
|
||||
if data['power'].mean() == 0:
|
||||
efficiency = 100.+0.0*data['power']
|
||||
|
||||
data = data.with_columns(efficiency=efficiency)
|
||||
|
||||
|
||||
@@ -1811,6 +1811,7 @@ def interactive_flex_chart2(id, r, promember=0,
|
||||
rowdata = dataprep.getsmallrowdata_pl(columns_basic, ids=[id], doclean=True,
|
||||
workstrokesonly=workstrokesonly, for_chart=True)
|
||||
|
||||
|
||||
if r.usersmooth > 1: # pragma: no cover
|
||||
for column in columns:
|
||||
try:
|
||||
@@ -1858,8 +1859,9 @@ def interactive_flex_chart2(id, r, promember=0,
|
||||
except (KeyError, TypeError, ColumnNotFoundError):
|
||||
rowdata = rowdata.with_columns(power=pl.lit(50))
|
||||
|
||||
|
||||
# replace nans
|
||||
rowdata = rowdata.fill_nan(0)
|
||||
rowdata = dataprep.remove_nulls_pl(rowdata)
|
||||
|
||||
row = Workout.objects.get(id=id)
|
||||
if rowdata.is_empty():
|
||||
@@ -1963,7 +1965,7 @@ def interactive_flex_chart2(id, r, promember=0,
|
||||
'trendline': trendline,
|
||||
'plottype': plottype,
|
||||
}
|
||||
|
||||
|
||||
script, div = get_chart("/flex", chart_data, debug=False)
|
||||
|
||||
return script, div, workstrokesonly
|
||||
|
||||
BIN
rowers/tests/testdata/testdata.tcx.gz
vendored
BIN
rowers/tests/testdata/testdata.tcx.gz
vendored
Binary file not shown.
Reference in New Issue
Block a user