From 4839d9a4cb74ff4666b0f6e4e80c67f69704b131 Mon Sep 17 00:00:00 2001 From: Shane Jaroch Date: Sun, 26 Mar 2023 12:53:44 -0400 Subject: [PATCH] wip plot 1rm with asciichartpy --- ntclient/argparser/funcs.py | 10 ++++++++++ ntclient/services/calculate.py | 13 ++++++++----- requirements.txt | 1 + 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/ntclient/argparser/funcs.py b/ntclient/argparser/funcs.py index aa177de..ebb3dd9 100644 --- a/ntclient/argparser/funcs.py +++ b/ntclient/argparser/funcs.py @@ -11,6 +11,7 @@ import argparse import os import traceback +import asciichartpy as asciichartpy from tabulate import tabulate import ntclient.services.analyze @@ -120,6 +121,10 @@ def calc_1rm(args: argparse.Namespace) -> tuple: _epley = calc.orm_epley(weight, reps) _brzycki = calc.orm_brzycki(weight, reps) _dos_remedios = calc.orm_dos_remedios(weight, reps) + _average = { + n: (_epley[n] + _brzycki[n] + _dos_remedios[n]) / 3 + for n in sorted(_epley.keys()) + } result = {"epley": _epley, "brzycki": _brzycki, "dos_remedios": _dos_remedios} @@ -140,6 +145,11 @@ def calc_1rm(args: argparse.Namespace) -> tuple: _table = tabulate(_all, headers=["n", "epl", "brz", "rmds"]) print(_table) + # Print graph + # TODO: make this a configurable height? + _plot = asciichartpy.plot(sorted(_average.values(), reverse=True), {"height": 20}) + print(_plot) + return 0, result diff --git a/ntclient/services/calculate.py b/ntclient/services/calculate.py index 8fc9322..4ac5b25 100644 --- a/ntclient/services/calculate.py +++ b/ntclient/services/calculate.py @@ -15,8 +15,11 @@ from ntclient.utils import Gender # 1 rep max # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# The only ones displayed in the result table -common_n_reps = (1, 2, 3, 5, 6, 8, 10, 12, 15, 20) +# The rep values used in the calculation +COMMON_N_REPS_MIN = 1 +COMMON_N_REPS_MAX = 20 +COMMON_N_REPS = range(COMMON_N_REPS_MIN, COMMON_N_REPS_MAX) +# common_n_reps = (1, 2, 3, 5, 6, 8, 10, 12, 15, 20) def orm_epley(weight: float, reps: float) -> dict: @@ -42,7 +45,7 @@ def orm_epley(weight: float, reps: float) -> dict: 1, ) - return {n_reps: max_weight(n_reps) for n_reps in common_n_reps} + return {n_reps: max_weight(n_reps) for n_reps in COMMON_N_REPS} def orm_brzycki(weight: float, reps: float) -> dict: @@ -73,7 +76,7 @@ def orm_brzycki(weight: float, reps: float) -> dict: 1, ) - return {n_reps: max_weight(n_reps) for n_reps in common_n_reps} + return {n_reps: max_weight(n_reps) for n_reps in COMMON_N_REPS} def orm_dos_remedios(weight: float, reps: int) -> dict: @@ -125,7 +128,7 @@ def orm_dos_remedios(weight: float, reps: int) -> dict: 1, ) - return {n_reps: max_weight(n_reps) for n_reps in common_n_reps} + return {n_reps: max_weight(n_reps) for n_reps in COMMON_N_REPS} # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/requirements.txt b/requirements.txt index 6a6c215..9fe3669 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,5 @@ argcomplete>=1.8.2,<=1.12.3 +asciichartpy==1.5.25 colorama>=0.1.17,<=0.4.1 fuzzywuzzy>=0.3.0 tabulate>=0.4.3,<=0.8.9 -- 2.52.0