]> Nutra Git (v2) - nutratech/cli.git/commitdiff
wip plot 1rm with asciichartpy
authorShane Jaroch <chown_tee@proton.me>
Sun, 26 Mar 2023 16:53:44 +0000 (12:53 -0400)
committerShane Jaroch <chown_tee@proton.me>
Sun, 26 Mar 2023 16:53:44 +0000 (12:53 -0400)
ntclient/argparser/funcs.py
ntclient/services/calculate.py
requirements.txt

index aa177de077eb731b44b4054dc47d85b8ce34101d..ebb3dd9e9020cddef53d83b94121563dfd6a1c6a 100644 (file)
@@ -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
 
 
index 8fc93228f08f190789175a84f51fcc0ae5c722f1..4ac5b251c314e39f2e22cf7687c6c5d18989e241 100644 (file)
@@ -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}
 
 
 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
index 6a6c215df12038634d09608d9f7619a1ec0c8a4f..9fe36697a62a675deff3f0cd54c72a18c1ebb62e 100644 (file)
@@ -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