Private
Public Access
1
0

polarized marker workouts

This commit is contained in:
2024-04-14 16:50:00 +02:00
parent a4d964c4f0
commit c3d7afd7af

View File

@@ -415,7 +415,7 @@ def resample(id, r, parent, overwrite='copy'):
def calculate_goldmedalstandard(rower, workout, recurrance=True):
cpfile = 'media/cpdata_{id}.parquet.gz'.format(id=workout.id)
try:
df = pd.read_parquet(cpfile)
df = pl.read_parquet(cpfile)
except:
background = True
if settings.TESTING:
@@ -423,11 +423,13 @@ def calculate_goldmedalstandard(rower, workout, recurrance=True):
df, delta, cpvalues = setcp(workout, background=background)
if df.empty:
return 0, 0
df = pl.from_pandas(df)
if df.empty and recurrance: # pragma: no cover
if df.is_empty() and recurrance: # pragma: no cover
df, delta, cpvalues = setcp(workout, recurrance=False, background=True)
if df.empty:
return 0, 0
df = pl.from_pandas(df)
age = calculate_age(rower.birthdate, today=workout.date)
@@ -490,9 +492,10 @@ def calculate_goldmedalstandard(rower, workout, recurrance=True):
scores = 100.*powers/wcpowers
try:
indexmax = scores.idxmax()
delta = int(df.loc[indexmax, 'delta'])
maxvalue = scores.max()
df = pl.DataFrame({'times': times, 'scores': scores})
df = df.filter(pl.col("scores") == pl.col("scores").max())
delta = df[0, "times"]
maxvalue = df[0, "scores"]
except (ValueError, TypeError, KeyError): # pragma: no cover
indexmax = 0
delta = 0