Private
Public Access
1
0

some precautions against empty workouts

This commit is contained in:
Sander Roosendaal
2017-05-09 09:52:37 +02:00
parent faa8fa5316
commit cba92b8619
2 changed files with 12 additions and 1 deletions

View File

@@ -338,7 +338,7 @@ def nicepaceformat(values):
# Convert seconds to a Time Delta value, replacing NaN with a 5:50 pace
def timedeltaconv(x):
if not np.isnan(x) and x != 0:
if np.isfinite(x) and x != 0:
dt = datetime.timedelta(seconds=x)
else:
dt = datetime.timedelta(seconds=350.)
@@ -471,6 +471,12 @@ def save_workout_database(f2,r,dosmooth=True,workouttype='rower',
if (len(ws) != 0):
message = "Warning: This workout probably already exists in the database"
# checking for inf values
totaldist = np.nan_to_num(totaldist)
maxhr = np.nan_to_num(maxhr)
averagehr = np.nan_to_num(averagehr)
w = Workout(user=r,name=title,date=workoutdate,
workouttype=workouttype,
@@ -1069,6 +1075,9 @@ def datafusion(id1,id2,columns,offset):
# Takes a rowingdata object's DataFrame as input
def dataprep(rowdatadf,id=0,bands=True,barchart=True,otwpower=True,
empower=True,inboard=0.88):
if rowdatadf.empty:
return 0
rowdatadf.set_index([range(len(rowdatadf))],inplace=True)
t = rowdatadf.ix[:,'TimeStamp (sec)']
t = pd.Series(t-rowdatadf.ix[0,'TimeStamp (sec)'])

View File

@@ -444,6 +444,8 @@ def interactive_histoall(theworkouts):
return [script,div]
def googlemap_chart(lat,lon,name=""):
if lat.empty or lon.empty:
return [0,"invalid coordinate data"]
# plot tools
TOOLS = 'save,pan,box_zoom,wheel_zoom,reset,tap,resize'