some precautions against empty workouts
This commit is contained in:
@@ -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)'])
|
||||
|
||||
@@ -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'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user