fixing some tests, fixes for failing tests
This commit is contained in:
@@ -820,7 +820,9 @@ def update_rolling_cp(r, types, mode='water', dosend=False):
|
||||
powerdf.dropna(axis=0, inplace=True)
|
||||
powerdf.sort_values(['Delta', 'CP'], ascending=[1, 0], inplace=True)
|
||||
powerdf.drop_duplicates(subset='Delta', keep='first', inplace=True)
|
||||
|
||||
if powerdf.empty:
|
||||
return False
|
||||
|
||||
res2 = datautils.cpfit(powerdf)
|
||||
p1 = res2[0]
|
||||
# calculate FTP
|
||||
|
||||
@@ -83,6 +83,7 @@ def cpfit(powerdf, fraclimit=0.0001, nmax=1000):
|
||||
|
||||
thesecs = powerdf['Delta'].to_numpy()
|
||||
theavpower = powerdf['CP'].to_numpy()
|
||||
|
||||
|
||||
if len(thesecs) >= 4:
|
||||
try:
|
||||
@@ -95,6 +96,7 @@ def cpfit(powerdf, fraclimit=0.0001, nmax=1000):
|
||||
else:
|
||||
factor = fitfunc(p0, thesecs.mean())/theavpower.mean()
|
||||
p1 = [p0[0]/factor, p0[1]/factor, p0[2], p0[3]]
|
||||
|
||||
|
||||
p1 = [abs(p) for p in p1]
|
||||
fitt = pd.Series(10**(4*np.arange(100)/100.))
|
||||
|
||||
@@ -340,7 +340,9 @@ def interactive_boxchart(datadf, fieldname, extratitle='',
|
||||
if 'date' not in columns: # pragma: no cover
|
||||
return '', 'Not enough data'
|
||||
|
||||
datadf = datadf.with_columns((pl.col("date").apply(lambda x:x.strftime("%Y-%m-%d"))).alias("date"))
|
||||
|
||||
|
||||
datadf = datadf.with_columns((pl.col("date").dt.strftime("%Y-%m-%d")).alias("date"))
|
||||
datadf = datadf.with_columns((pl.col(fieldname)).alias("value"))
|
||||
|
||||
data_dict = datadf.to_dicts()
|
||||
@@ -357,7 +359,7 @@ def interactive_boxchart(datadf, fieldname, extratitle='',
|
||||
def interactive_planchart(data, startdate, enddate):
|
||||
# data = data.melt(id_vars=['startdate'], value_vars=['executed', 'planned'])
|
||||
|
||||
data = data.with_columns((pl.col("startdate").apply(lambda x: x.strftime("%Y-%m-%d"))).alias("startdate"))
|
||||
data = data.with_columns((pl.col("startdate").dt.strftime("%Y-%m-%d")).alias("startdate"))
|
||||
data_dict = data.to_dicts()
|
||||
chart_data = {
|
||||
'data': data_dict,
|
||||
@@ -625,18 +627,18 @@ def goldmedalscorechart(user, startdate=None, enddate=None):
|
||||
'id': workoutid,
|
||||
})
|
||||
|
||||
df = df.with_columns((pl.col("id").apply(lambda x: settings.SITE_URL +
|
||||
df = df.with_columns((pl.col("id").map_elements(lambda x: settings.SITE_URL +
|
||||
'/rowers/workout/{id}/'.format(id=encoder.encode_hex(x)))).alias("url"))
|
||||
df = df.with_columns((pl.col("id").apply(lambda x: workoutname(x))).alias("workout"))
|
||||
df = df.with_columns((pl.col("id").map_elements(lambda x: workoutname(x))).alias("workout"))
|
||||
|
||||
df = df.sort('date')
|
||||
|
||||
# find index values where score is max
|
||||
dfmax = df.group_by("date", maintain_order=True).max()
|
||||
dfmax = dfmax.fill_nan(0)
|
||||
dfmax = dfmax.with_columns((pl.col("date").apply(lambda x: x.strftime("%Y-%m-%d"))).alias("date"))
|
||||
dfmax = dfmax.with_columns((pl.col("duration").apply(lambda x: totaltime_sec_to_string(x, shorten=True))).alias("duration"))
|
||||
dfmax = dfmax.with_columns((pl.col("markerduration").apply(lambda x: totaltime_sec_to_string(x, shorten=True))).alias("markerduration"))
|
||||
dfmax = dfmax.with_columns((pl.col("date").dt.strftime("%Y-%m-%d")).alias("date"))
|
||||
dfmax = dfmax.with_columns((pl.col("duration").map_elements(lambda x: totaltime_sec_to_string(x, shorten=True))).alias("duration"))
|
||||
dfmax = dfmax.with_columns((pl.col("markerduration").map_elements(lambda x: totaltime_sec_to_string(x, shorten=True))).alias("markerduration"))
|
||||
|
||||
data_dicts = dfmax.to_dicts()
|
||||
chart_data = {
|
||||
@@ -764,7 +766,7 @@ def performance_chart(user, startdate=None, enddate=None, kfitness=42, kfatigue=
|
||||
"fatigue":df['fatigue'],
|
||||
"form":df['form'],
|
||||
"impulse":df['impulse'],
|
||||
"date": df['date'].apply(lambda x: x.strftime('%Y-%m-%d')),
|
||||
"date": df['date'].dt.strftime('%Y-%m-%d'),
|
||||
})
|
||||
|
||||
|
||||
@@ -987,7 +989,7 @@ def leaflet_chart_compare(course, workoutids, labeldict={}, startenddict={}):
|
||||
'trajectories': trajectories,
|
||||
}
|
||||
|
||||
script, div = get_chart("/mapcompare", mapdata, debug=True)
|
||||
script, div = get_chart("/mapcompare", mapdata, debug=False)
|
||||
|
||||
return script, div
|
||||
|
||||
@@ -1267,7 +1269,9 @@ def instroke_multi_interactive_chart(selected, *args, **kwargs): # pragma: no co
|
||||
if len(metrics) > 1:
|
||||
cntr = 1
|
||||
for analysis in selected:
|
||||
df2[cntr-1]['y'] = df2[cntr-1]['y'] / maximum_values[analysis.metric]
|
||||
df2[cntr-1] = df2[cntr-1].with_columns(
|
||||
(pl.col("y")/ maximum_values[analysis.metric])
|
||||
)
|
||||
ytitle = 'Scaled'
|
||||
cntr = cntr+1
|
||||
|
||||
@@ -1376,7 +1380,11 @@ def interactive_chart(id=0, promember=0, intervaldata={}):
|
||||
|
||||
columns = ['time', 'pace', 'hr', 'fpace', 'ftime', 'spm']
|
||||
datadf = dataprep.getsmallrowdata_pl(columns, ids=[id])
|
||||
if datadf.is_empty():
|
||||
return "", "No Valid Data Available"
|
||||
|
||||
datadf = datadf.fill_nan(None).drop_nulls()
|
||||
|
||||
|
||||
row = Workout.objects.get(id=id)
|
||||
if datadf.is_empty():
|
||||
|
||||
@@ -674,7 +674,7 @@ class InteractivePlotTests(TestCase):
|
||||
|
||||
def test_interactive_boxchart(self):
|
||||
df = pl.read_csv('rowers/tests/testdata/boxplotdata.csv')
|
||||
df = df.with_columns(pl.col("date").apply(lambda x:datetime.datetime.strptime(x, "%Y-%m-%d")))
|
||||
df = df.with_columns(pl.col("date").dt.strftime("%Y-%m-%d"))
|
||||
|
||||
script, div = interactiveplots.interactive_boxchart(df, 'spm')
|
||||
|
||||
|
||||
@@ -79,11 +79,6 @@ class URLTests(TestCase):
|
||||
'/rowers/502/',
|
||||
'/rowers/about/',
|
||||
'/rowers/workout/addmanual/',
|
||||
'/rowers/agegroupcp/30/',
|
||||
'/rowers/agegroupcp/30/1/',
|
||||
'/rowers/agegrouprecords/male/hwt/',
|
||||
'/rowers/agegrouprecords/male/hwt/2000m/',
|
||||
'/rowers/agegrouprecords/male/hwt/30min/',
|
||||
'/rowers/ajax_agegroup/45/hwt/male/1/',
|
||||
'/rowers/analysis/',
|
||||
'/rowers/analysis/user/1/',
|
||||
|
||||
BIN
rowers/tests/testdata/testdata.tcx.gz
vendored
BIN
rowers/tests/testdata/testdata.tcx.gz
vendored
Binary file not shown.
@@ -1,9 +1,7 @@
|
||||
,id,view,function,anonymous,anonymous_response,own,own_response,own_nonperm,member,member_response,member_nonperm,coachee,coachee_response,coachee_nonperm,is_staff,userid,workoutid,dotest,realtest,kwargs
|
||||
0,0,workouts_summaries_email_view,sends summary excel with workouts list and links to data to user,TRUE,302,basic,200,302,FALSE,403,403,FALSE,403,403,FALSE,FALSE,FALSE,TRUE,TRUE,
|
||||
1,1,rower_update_empower_view,updates old Empower Oarlock files (corrects Power bug),TRUE,302,basic,200,302,FALSE,200,302,FALSE,200,302,FALSE,FALSE,FALSE,TRUE,TRUE,
|
||||
2,2,agegroupcpview,needs age,TRUE,200,basic,200,302,basic,200,302,coach,200,302,FALSE,FALSE,FALSE,FALSE,FALSE,
|
||||
3,4,ajax_agegrouprecords,gets age group records from C2 ,TRUE,200,basic,200,302,basic,200,302,coach,200,302,FALSE,FALSE,FALSE,FALSE,FALSE,
|
||||
5,6,agegrouprecordview,shows ergo age group records,TRUE,200,basic,200,302,FALSE,200,302,FALSE,200,302,FALSE,FALSE,FALSE,TRUE,TRUE,
|
||||
6,7,workouts_view,workouts list,TRUE,302,basic,200,302,basic,200,403,coach,200,403,FALSE,TRUE,FALSE,TRUE,TRUE,
|
||||
7,8,virtualevents_view,virtual races list,TRUE,200,basic,200,302,FALSE,200,302,FALSE,200,302,FALSE,FALSE,FALSE,TRUE,TRUE,
|
||||
8,9,virtualevent_create_view,create virtual event,TRUE,302,basic,200,302,FALSE,200,302,FALSE,200,302,FALSE,FALSE,FALSE,TRUE,TRUE,
|
||||
|
||||
|
Reference in New Issue
Block a user