Private
Public Access
1
0

Merge branch 'release/v11.93'

This commit is contained in:
Sander Roosendaal
2020-03-18 22:52:50 +01:00
5 changed files with 18 additions and 3 deletions

View File

@@ -483,6 +483,9 @@ def df_resample(datadf):
def clean_df_stats(datadf, workstrokesonly=True, ignorehr=True, def clean_df_stats(datadf, workstrokesonly=True, ignorehr=True,
ignoreadvanced=False): ignoreadvanced=False):
# clean data remove zeros and negative values # clean data remove zeros and negative values
before = len(datadf)
data_orig = datadf.copy()
# bring metrics which have negative values to positive domain # bring metrics which have negative values to positive domain
if len(datadf)==0: if len(datadf)==0:
@@ -706,6 +709,12 @@ def clean_df_stats(datadf, workstrokesonly=True, ignorehr=True,
except: except:
pass pass
after = len(datadf.dropna())
ratio = float(after)/float(before)
if ratio < 0.001 or after < 2:
return data_orig
return datadf return datadf
def getstatsfields(): def getstatsfields():
@@ -1444,6 +1453,7 @@ def parsenonpainsled(fileformat,f2,summary):
pass pass
hasrecognized = True hasrecognized = True
return row,hasrecognized,summary,fileformat return row,hasrecognized,summary,fileformat
def handle_nonpainsled(f2, fileformat, summary=''): def handle_nonpainsled(f2, fileformat, summary=''):
@@ -1465,6 +1475,7 @@ def handle_nonpainsled(f2, fileformat, summary=''):
# should delete file # should delete file
f2 = f2[:-4] + 'o.csv' f2 = f2[:-4] + 'o.csv'
row2 = rrdata(df = row.df) row2 = rrdata(df = row.df)
if 'speedcoach2' in fileformat: if 'speedcoach2' in fileformat:
# impeller consistency # impeller consistency
impellerdata, consistent, ratio = row.impellerconsistent(threshold=0.3) impellerdata, consistent, ratio = row.impellerconsistent(threshold=0.3)
@@ -1472,6 +1483,7 @@ def handle_nonpainsled(f2, fileformat, summary=''):
impeller = True impeller = True
if impellerdata and not consistent: if impellerdata and not consistent:
row2.use_gpsdata() row2.use_gpsdata()
row2.write_csv(f2, gzip=True) row2.write_csv(f2, gzip=True)

View File

@@ -3715,6 +3715,7 @@ def interactive_flex_chart2(id=0,promember=0,
rowdata = dataprep.getsmallrowdata_db(columns,ids=[id],doclean=True, rowdata = dataprep.getsmallrowdata_db(columns,ids=[id],doclean=True,
workstrokesonly=workstrokesonly) workstrokesonly=workstrokesonly)
if len(rowdata)<2: if len(rowdata)<2:
rowdata = dataprep.getsmallrowdata_db(columns,ids=[id],doclean=True, rowdata = dataprep.getsmallrowdata_db(columns,ids=[id],doclean=True,
workstrokesonly=False) workstrokesonly=False)

View File

@@ -85,7 +85,7 @@ class ForceUnits(TestCase):
df = dataprep.clean_df_stats(df,ignoreadvanced=False) df = dataprep.clean_df_stats(df,ignoreadvanced=False)
average_N = int(df['averageforce'].mean()) average_N = int(df['averageforce'].mean())
self.assertEqual(average_N,399) self.assertEqual(average_N,398)
def test_upload_speedcoach_N(self): def test_upload_speedcoach_N(self):
login = self.c.login(username=self.u.username, password=self.password) login = self.c.login(username=self.u.username, password=self.password)

View File

@@ -318,6 +318,7 @@ def trendflexdata(workouts, options,userid=0):
datadf['date'].replace(datemapping,inplace=True) datadf['date'].replace(datemapping,inplace=True)
today = datetime.date.today() today = datetime.date.today()
datadf['days ago'] = list(map(lambda x : x.days, datadf.date - today)) datadf['days ago'] = list(map(lambda x : x.days, datadf.date - today))
@@ -648,6 +649,8 @@ def boxplotdata(workouts,options):
datadf['workoutid'].replace(datemapping,inplace=True) datadf['workoutid'].replace(datemapping,inplace=True)
datadf.rename(columns={"workoutid":"date"},inplace=True) datadf.rename(columns={"workoutid":"date"},inplace=True)
datadf['date'] = pd.to_datetime(datadf['date'],errors='coerce')
datadf = datadf.dropna(subset=['date'])
datadf = datadf.sort_values(['date']) datadf = datadf.sort_values(['date'])
if userid == 0: if userid == 0:

View File

@@ -235,8 +235,6 @@ def workout_csvemail_view(request,id=0):
w = get_workout(id) w = get_workout(id)
rowdata = rdata(w.csvfilename) rowdata = rdata(w.csvfilename)
code = str(uuid4()) code = str(uuid4())
filename = code+'.csv' filename = code+'.csv'
@@ -244,6 +242,7 @@ def workout_csvemail_view(request,id=0):
rowdate = rowdata.rowdatetime rowdate = rowdata.rowdatetime
starttimeunix = arrow.get(rowdate).timestamp starttimeunix = arrow.get(rowdate).timestamp
df = rowdata.df df = rowdata.df
try: try:
df[' ElapsedTime (sec)'] = df['TimeStamp (sec)'] df[' ElapsedTime (sec)'] = df['TimeStamp (sec)']
df['TimeStamp (sec)'] = df['TimeStamp (sec)'] + starttimeunix df['TimeStamp (sec)'] = df['TimeStamp (sec)'] + starttimeunix