my.body.exercise: add more annotations & ci check
This commit is contained in:
parent
06ee72bc30
commit
e63c159b80
4 changed files with 31 additions and 25 deletions
|
@ -2,7 +2,7 @@
|
|||
Feel free to remove this if you don't need it/add your own custom settings and use them
|
||||
"""
|
||||
|
||||
from my.core import Paths
|
||||
from my.core import Paths, PathIsh
|
||||
|
||||
class hypothesis:
|
||||
# expects outputs from https://github.com/karlicoss/hypexport
|
||||
|
@ -23,3 +23,6 @@ class reddit:
|
|||
|
||||
class endomondo:
|
||||
export_path: Paths = ''
|
||||
|
||||
class exercise:
|
||||
workout_log: PathIsh = '/some/path.org'
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
'''
|
||||
Cardio data, filtered from Endomondo and inferred from other data sources
|
||||
'''
|
||||
from ...core.pandas import check_dataframe as cdf
|
||||
|
||||
import pandas as pd # type: ignore
|
||||
from ...core.pandas import DataFrameT, check_dataframe as cdf
|
||||
|
||||
|
||||
CARDIO = {
|
||||
|
@ -24,10 +22,10 @@ NOT_CARDIO = {
|
|||
|
||||
|
||||
@cdf
|
||||
def endomondo_cardio() -> pd.DataFrame:
|
||||
def endomondo_cardio() -> DataFrameT:
|
||||
assert len(CARDIO.intersection(NOT_CARDIO)) == 0, (CARDIO, NOT_CARDIO)
|
||||
|
||||
from ..endomondo import dataframe as EDF
|
||||
from ...endomondo import dataframe as EDF
|
||||
df = EDF()
|
||||
|
||||
# not sure...
|
||||
|
@ -46,5 +44,5 @@ def endomondo_cardio() -> pd.DataFrame:
|
|||
return df
|
||||
|
||||
|
||||
def dataframe():
|
||||
def dataframe() -> DataFrameT:
|
||||
return endomondo_cardio()
|
||||
|
|
|
@ -8,7 +8,7 @@ For now it's worth keeping it here as an example and perhaps utility functions m
|
|||
from datetime import datetime, timedelta
|
||||
from typing import Optional
|
||||
|
||||
from ...core.pandas import check_dataframe as cdf
|
||||
from ...core.pandas import DataFrameT, check_dataframe as cdf
|
||||
|
||||
from my.config import exercise as config
|
||||
|
||||
|
@ -59,7 +59,7 @@ def cross_trainer_data():
|
|||
for k, v in row.items():
|
||||
# todo have something smarter... e.g. allow pandas to infer the type??
|
||||
mapper = mappers.get(k, maybe(float))
|
||||
d[k] = mapper(v)
|
||||
d[k] = mapper(v) # type: ignore[operator]
|
||||
yield d
|
||||
except Exception as e:
|
||||
# todo add parsing context
|
||||
|
@ -70,11 +70,11 @@ def cross_trainer_data():
|
|||
|
||||
|
||||
@cdf
|
||||
def cross_trainer_manual_dataframe():
|
||||
def cross_trainer_manual_dataframe() -> DataFrameT:
|
||||
'''
|
||||
Only manual org-mode entries
|
||||
'''
|
||||
import pandas as pd
|
||||
import pandas as pd # type: ignore[import]
|
||||
df = pd.DataFrame(cross_trainer_data())
|
||||
return df
|
||||
|
||||
|
@ -83,11 +83,11 @@ _DELTA = timedelta(hours=10)
|
|||
|
||||
# todo check error handling by introducing typos (e.g. especially dates) in org-mode
|
||||
@cdf
|
||||
def dataframe():
|
||||
def dataframe() -> DataFrameT:
|
||||
'''
|
||||
Attaches manually logged data (which Endomondo can't capture) and attaches it to Endomondo
|
||||
'''
|
||||
import pandas as pd
|
||||
import pandas as pd # type: ignore[import]
|
||||
|
||||
from ...endomondo import dataframe as EDF
|
||||
edf = EDF()
|
||||
|
@ -99,7 +99,7 @@ def dataframe():
|
|||
# now for each manual entry, find a 'close enough' endomondo entry
|
||||
# ideally it's a 1-1 (or 0-1) relationship, but there might be errors
|
||||
rows = []
|
||||
idxs = []
|
||||
idxs = [] # type: ignore[var-annotated]
|
||||
NO_ENDOMONDO = 'no endomondo matches'
|
||||
for i, row in mdf.iterrows():
|
||||
rd = row.to_dict()
|
||||
|
@ -159,12 +159,12 @@ def dataframe():
|
|||
# TODO wtf?? where is speed coming from??
|
||||
|
||||
|
||||
def stats():
|
||||
from ...core import stat
|
||||
from ...core import stat, Stats
|
||||
def stats() -> Stats:
|
||||
return stat(cross_trainer_data)
|
||||
|
||||
|
||||
def compare_manual():
|
||||
def compare_manual() -> None:
|
||||
df = dataframe()
|
||||
df = df.set_index('start_time')
|
||||
|
||||
|
|
5
tox.ini
5
tox.ini
|
@ -37,6 +37,9 @@ commands =
|
|||
pip install git+https://github.com/karlicoss/pockexport
|
||||
pip install git+https://github.com/karlicoss/rexport
|
||||
pip install git+https://github.com/karlicoss/endoexport
|
||||
|
||||
pip install git+https://github.com/karlicoss/porg
|
||||
|
||||
# todo I guess use a script...
|
||||
python3 -m mypy -p my.github.ghexport \
|
||||
-p my.hypothesis \
|
||||
|
@ -44,6 +47,8 @@ commands =
|
|||
-p my.pocket \
|
||||
-p my.reddit \
|
||||
-p my.endomondo \
|
||||
-p my.body.exercise.cardio \
|
||||
-p my.body.exercise.cross_trainer \
|
||||
--txt-report .mypy-coverage \
|
||||
--html-report .mypy-coverage \
|
||||
{posargs}
|
||||
|
|
Loading…
Add table
Reference in a new issue