fixing course calculations
This commit is contained in:
@@ -31,17 +31,24 @@ def time_in_path(df, p, maxmin='max', getall=False, name='unknown', logfile=None
|
||||
|
||||
if len(df[b == 2]):
|
||||
if logfile is not None: # pragma: no cover
|
||||
s = '{name} {maxmin} {getall} {nrpasses} passes found'.format(
|
||||
s = '{name} {maxmin} {getall} {nrpasses} passes found at {time} seconds'.format(
|
||||
name = name,
|
||||
maxmin = maxmin,
|
||||
getall = getall,
|
||||
nrpasses = len(df[b==2]),
|
||||
time = df[b==2]['time'].min() if not getall else df[b==2]['time'].max()
|
||||
)
|
||||
dologging(logfile,s)
|
||||
if getall: # pragma: no cover
|
||||
return df[b == 2]['time'], df[b == 2]['cum_dist']
|
||||
try:
|
||||
return df[b == 2]['time'], df[b == 2]['cumdist']
|
||||
except KeyError:
|
||||
return df[b == 2]['time'], df[b == 2]['cum_dist']
|
||||
else:
|
||||
return df[b == 2]['time'].min(), df[b == 2]['cum_dist'].min()
|
||||
try:
|
||||
return df[b == 2]['time'].min(), df[b == 2]['cumdist'].min()
|
||||
except KeyError:
|
||||
return df[b == 2]['time'].min(), df[b == 2]['cum_dist'].min()
|
||||
|
||||
if logfile is not None: # pragma: no cover
|
||||
s = '{name} {maxmin} {getall} {nrpasses} pass not found'.format(
|
||||
@@ -60,7 +67,10 @@ def time_in_path(df, p, maxmin='max', getall=False, name='unknown', logfile=None
|
||||
def coursetime_first(data, paths, polygons=[], logfile=None):
|
||||
|
||||
entrytime = data['time'].max()
|
||||
entrydistance = data['cum_dist'].max()
|
||||
try:
|
||||
entrydistance = data['cumdist'].max()
|
||||
except KeyError:
|
||||
entrydistance = data['cum_dist'].max()
|
||||
coursecompleted = False
|
||||
|
||||
if len(polygons) == 0:
|
||||
@@ -72,7 +82,10 @@ def coursetime_first(data, paths, polygons=[], logfile=None):
|
||||
coursecompleted = True
|
||||
except InvalidTrajectoryError: # pragma: no cover
|
||||
entrytime = data['time'].max()
|
||||
entrydistance = data['cum_dist'].max()
|
||||
try:
|
||||
entrydistance = data['cumdist'].max()
|
||||
except KeyError:
|
||||
entrydistance = data['cum_dist'].max()
|
||||
coursecompleted = False
|
||||
return entrytime, entrydistance, coursecompleted
|
||||
|
||||
@@ -80,7 +93,10 @@ def coursetime_first(data, paths, polygons=[], logfile=None):
|
||||
def coursetime_paths(data, paths, finalmaxmin='min', polygons=[], logfile=None):
|
||||
|
||||
entrytime = data['time'].max()
|
||||
entrydistance = data['cum_dist'].max()
|
||||
try:
|
||||
entrydistance = data['cumdist'].max()
|
||||
except KeyError:
|
||||
entrydistance = data['cum_dist'].max()
|
||||
coursecompleted = False
|
||||
|
||||
if len(polygons) == 0:
|
||||
@@ -100,7 +116,10 @@ def coursetime_paths(data, paths, finalmaxmin='min', polygons=[], logfile=None):
|
||||
coursecompleted = True
|
||||
except InvalidTrajectoryError: # pragma: no cover
|
||||
entrytime = data['time'].max()
|
||||
entrydistance = data['cum_dist'].max()
|
||||
try:
|
||||
entrydistance = data['cumdist'].max()
|
||||
except KeyError:
|
||||
entrydistance = data['cum_dist'].max()
|
||||
coursecompleted = False
|
||||
return entrytime, entrydistance, coursecompleted
|
||||
|
||||
@@ -110,7 +129,10 @@ def coursetime_paths(data, paths, finalmaxmin='min', polygons=[], logfile=None):
|
||||
data, paths[0], name=str(polygons[0]), logfile=logfile)
|
||||
data2 = data[data['time'] > time].copy()
|
||||
data2['time'] = data2['time'].apply(lambda x: x-time)
|
||||
data2['cum_dist'] = data2['cum_dist'].apply(lambda x: x-dist)
|
||||
try:
|
||||
data2['cumdist'] = data2['cumdist'].apply(lambda x: x-dist)
|
||||
except KeyError:
|
||||
data2['cum_dist'] = data2['cum_dist'].apply(lambda x: x-dist)
|
||||
(
|
||||
timenext,
|
||||
distnext,
|
||||
@@ -119,7 +141,10 @@ def coursetime_paths(data, paths, finalmaxmin='min', polygons=[], logfile=None):
|
||||
return time+timenext, dist+distnext, coursecompleted
|
||||
except InvalidTrajectoryError: # pragma: no cover
|
||||
entrytime = data['time'].max()
|
||||
entrydistance = data['cum_dist'].max()
|
||||
try:
|
||||
entrydistance = data['cumdist'].max()
|
||||
except KeyError:
|
||||
entrydistance = data['cum_dist'].max()
|
||||
coursecompleted = False
|
||||
|
||||
return entrytime, entrydistance, coursecompleted # pragma: no cover
|
||||
|
||||
Reference in New Issue
Block a user