fixing filtering
This commit is contained in:
@@ -1512,7 +1512,7 @@ def getrowdata_pl(id=0, doclean=False, convertnewtons=True,
|
|||||||
|
|
||||||
|
|
||||||
def read_data(columns, ids=[], doclean=True, workstrokesonly=True, debug=False, for_chart=False, compute=True,
|
def read_data(columns, ids=[], doclean=True, workstrokesonly=True, debug=False, for_chart=False, compute=True,
|
||||||
startenddict={}):
|
startenddict={}, driveenergy=True):
|
||||||
if ids:
|
if ids:
|
||||||
csvfilenames = [
|
csvfilenames = [
|
||||||
'media/strokedata_{id}.parquet.gz'.format(id=id) for id in ids]
|
'media/strokedata_{id}.parquet.gz'.format(id=id) for id in ids]
|
||||||
@@ -1520,7 +1520,9 @@ def read_data(columns, ids=[], doclean=True, workstrokesonly=True, debug=False,
|
|||||||
return pl.DataFrame()
|
return pl.DataFrame()
|
||||||
|
|
||||||
data = []
|
data = []
|
||||||
columns = [c for c in columns if c != 'None'] + ['distance', 'spm', 'workoutid','workoutstate', 'driveenergy']
|
columns = [c for c in columns if c != 'None'] + ['distance', 'spm', 'workoutid','workoutstate']
|
||||||
|
if driveenergy:
|
||||||
|
columns = columns + ['driveenergy']
|
||||||
columns = list(set(columns))
|
columns = list(set(columns))
|
||||||
|
|
||||||
for id, f in zip(ids, csvfilenames):
|
for id, f in zip(ids, csvfilenames):
|
||||||
@@ -1583,9 +1585,10 @@ def read_data(columns, ids=[], doclean=True, workstrokesonly=True, debug=False,
|
|||||||
if len(data)==0:
|
if len(data)==0:
|
||||||
return pl.DataFrame()
|
return pl.DataFrame()
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
datadf = pl.concat(data).select(columns)
|
datadf = pl.concat(data).select(columns)
|
||||||
except (SchemaError, ShapeError):
|
except (ShapeError, SchemaError):
|
||||||
data = [
|
data = [
|
||||||
df.select(columns)
|
df.select(columns)
|
||||||
for df in data]
|
for df in data]
|
||||||
@@ -1593,6 +1596,7 @@ def read_data(columns, ids=[], doclean=True, workstrokesonly=True, debug=False,
|
|||||||
# float columns
|
# float columns
|
||||||
floatcolumns = []
|
floatcolumns = []
|
||||||
intcolumns = []
|
intcolumns = []
|
||||||
|
stringcolumns = []
|
||||||
for c in columns:
|
for c in columns:
|
||||||
try:
|
try:
|
||||||
if metricsdicts[c]['numtype'] == 'float':
|
if metricsdicts[c]['numtype'] == 'float':
|
||||||
@@ -1600,7 +1604,11 @@ def read_data(columns, ids=[], doclean=True, workstrokesonly=True, debug=False,
|
|||||||
if metricsdicts[c]['numtype'] == 'integer':
|
if metricsdicts[c]['numtype'] == 'integer':
|
||||||
intcolumns.append(c)
|
intcolumns.append(c)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
if c[0] == 'f':
|
||||||
|
stringcolumns.append(c)
|
||||||
|
else:
|
||||||
|
intcolumns.append(c)
|
||||||
|
|
||||||
data = [
|
data = [
|
||||||
df.with_columns(
|
df.with_columns(
|
||||||
cs.float().cast(pl.Float64)
|
cs.float().cast(pl.Float64)
|
||||||
@@ -1610,6 +1618,8 @@ def read_data(columns, ids=[], doclean=True, workstrokesonly=True, debug=False,
|
|||||||
cs.by_name(intcolumns).cast(pl.Int64)
|
cs.by_name(intcolumns).cast(pl.Int64)
|
||||||
).with_columns(
|
).with_columns(
|
||||||
cs.by_name(floatcolumns).cast(pl.Float64)
|
cs.by_name(floatcolumns).cast(pl.Float64)
|
||||||
|
).with_columns(
|
||||||
|
cs.by_name(stringcolumns).cast(pl.String)
|
||||||
)
|
)
|
||||||
for df in data
|
for df in data
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -1802,7 +1802,7 @@ def interactive_flexchart_stacked(id, r, xparam='time',
|
|||||||
'metrics': metrics_list,
|
'metrics': metrics_list,
|
||||||
}
|
}
|
||||||
|
|
||||||
script, div = get_chart("/stacked", chart_data, debug=False)
|
script, div = get_chart("/stacked", chart_data, debug=True)
|
||||||
|
|
||||||
return script, div
|
return script, div
|
||||||
|
|
||||||
@@ -2129,16 +2129,20 @@ def interactive_multiple_compare_chart(ids, xparam, yparam, plottype='line',
|
|||||||
compute = True
|
compute = True
|
||||||
doclean = True
|
doclean = True
|
||||||
|
|
||||||
|
driveenergy = False
|
||||||
|
if 'driveenergy' in columns:
|
||||||
|
driveenergy = True
|
||||||
|
|
||||||
|
|
||||||
datadf = pl.DataFrame()
|
datadf = pl.DataFrame()
|
||||||
if promember:
|
if promember:
|
||||||
datadf = dataprep.read_data(columns, ids=ids, doclean=doclean,
|
datadf = dataprep.read_data(columns, ids=ids, doclean=doclean,
|
||||||
compute=compute,
|
compute=compute, driveenergy=driveenergy,
|
||||||
workstrokesonly=workstrokesonly, for_chart=True,
|
workstrokesonly=workstrokesonly, for_chart=True,
|
||||||
startenddict=startenddict)
|
startenddict=startenddict)
|
||||||
else:
|
else:
|
||||||
datadf = dataprep.read_data(columns_basic, ids=ids, doclean=doclean,
|
datadf = dataprep.read_data(columns_basic, ids=ids, doclean=doclean,
|
||||||
compute=compute,
|
compute=compute, driveenergy = driveenergy,
|
||||||
workstrokesonly=workstrokesonly, for_chart=True,
|
workstrokesonly=workstrokesonly, for_chart=True,
|
||||||
startenddict=startenddict)
|
startenddict=startenddict)
|
||||||
|
|
||||||
@@ -2165,10 +2169,10 @@ def interactive_multiple_compare_chart(ids, xparam, yparam, plottype='line',
|
|||||||
|
|
||||||
if (xparam == 'time'):
|
if (xparam == 'time'):
|
||||||
datadf = datadf.with_columns((pl.col(xparam)-datadf[0,xparam]).alias(xparam))
|
datadf = datadf.with_columns((pl.col(xparam)-datadf[0,xparam]).alias(xparam))
|
||||||
|
|
||||||
data_dict = datadf.to_dicts()
|
data_dict = datadf.to_dicts()
|
||||||
|
|
||||||
metrics_list = [{'name': name, 'rowingmetrics':d } for name, d in metrics.rowingmetrics]
|
metrics_list = [{'name': name, 'rowingmetrics':{k: v for k, v in d.items() if k != 'numtype_pl'} } for name, d in metrics.rowingmetrics]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
workoutsdict = [{'id': id, 'label': labeldict[id]} for id in ids]
|
workoutsdict = [{'id': id, 'label': labeldict[id]} for id in ids]
|
||||||
@@ -2185,6 +2189,7 @@ def interactive_multiple_compare_chart(ids, xparam, yparam, plottype='line',
|
|||||||
'workouts': workoutsdict,
|
'workouts': workoutsdict,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
script, div = get_chart("/compare", chart_data, debug=False)
|
script, div = get_chart("/compare", chart_data, debug=False)
|
||||||
return script, div
|
return script, div
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import numpy as np
|
|||||||
import pandas as pd
|
import pandas as pd
|
||||||
from scipy import optimize
|
from scipy import optimize
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
|
from polars import String, Int32, Float64
|
||||||
|
|
||||||
from math import log10, log2
|
from math import log10, log2
|
||||||
from rowers.mytypes import otwtypes, otetypes
|
from rowers.mytypes import otwtypes, otetypes
|
||||||
|
|||||||
BIN
rowers/tests/testdata/testdata.tcx.gz
vendored
BIN
rowers/tests/testdata/testdata.tcx.gz
vendored
Binary file not shown.
Reference in New Issue
Block a user