repwise 3.1.0__tar.gz → 3.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {repwise-3.1.0/src/repwise.egg-info → repwise-3.2.0}/PKG-INFO +1 -1
- {repwise-3.1.0 → repwise-3.2.0}/pyproject.toml +1 -1
- {repwise-3.1.0 → repwise-3.2.0}/src/repwise/__init__.py +1 -1
- {repwise-3.1.0 → repwise-3.2.0}/src/repwise/app/update.py +25 -6
- {repwise-3.1.0 → repwise-3.2.0}/src/repwise/domain/models.py +73 -0
- {repwise-3.1.0 → repwise-3.2.0}/src/repwise/domain/progression.py +28 -0
- {repwise-3.1.0 → repwise-3.2.0}/src/repwise/planner.py +103 -21
- {repwise-3.1.0 → repwise-3.2.0/src/repwise.egg-info}/PKG-INFO +1 -1
- {repwise-3.1.0 → repwise-3.2.0}/tests/test_models.py +74 -0
- {repwise-3.1.0 → repwise-3.2.0}/tests/test_planner.py +179 -7
- {repwise-3.1.0 → repwise-3.2.0}/tests/test_progression.py +57 -0
- {repwise-3.1.0 → repwise-3.2.0}/LICENSE +0 -0
- {repwise-3.1.0 → repwise-3.2.0}/README.md +0 -0
- {repwise-3.1.0 → repwise-3.2.0}/setup.cfg +0 -0
- {repwise-3.1.0 → repwise-3.2.0}/src/repwise/__main__.py +0 -0
- {repwise-3.1.0 → repwise-3.2.0}/src/repwise/app/__init__.py +0 -0
- {repwise-3.1.0 → repwise-3.2.0}/src/repwise/app/checking.py +0 -0
- {repwise-3.1.0 → repwise-3.2.0}/src/repwise/app/fetch.py +0 -0
- {repwise-3.1.0 → repwise-3.2.0}/src/repwise/app/importing.py +0 -0
- {repwise-3.1.0 → repwise-3.2.0}/src/repwise/app/listing.py +0 -0
- {repwise-3.1.0 → repwise-3.2.0}/src/repwise/app/logout.py +0 -0
- {repwise-3.1.0 → repwise-3.2.0}/src/repwise/app/report.py +0 -0
- {repwise-3.1.0 → repwise-3.2.0}/src/repwise/checker.py +0 -0
- {repwise-3.1.0 → repwise-3.2.0}/src/repwise/cli/__init__.py +0 -0
- {repwise-3.1.0 → repwise-3.2.0}/src/repwise/cli/completion.py +0 -0
- {repwise-3.1.0 → repwise-3.2.0}/src/repwise/cli/parser.py +0 -0
- {repwise-3.1.0 → repwise-3.2.0}/src/repwise/config.py +0 -0
- {repwise-3.1.0 → repwise-3.2.0}/src/repwise/domain/__init__.py +0 -0
- {repwise-3.1.0 → repwise-3.2.0}/src/repwise/domain/effort.py +0 -0
- {repwise-3.1.0 → repwise-3.2.0}/src/repwise/domain/matching.py +0 -0
- {repwise-3.1.0 → repwise-3.2.0}/src/repwise/dumps.py +0 -0
- {repwise-3.1.0 → repwise-3.2.0}/src/repwise/errors.py +0 -0
- {repwise-3.1.0 → repwise-3.2.0}/src/repwise/garmin/__init__.py +0 -0
- {repwise-3.1.0 → repwise-3.2.0}/src/repwise/garmin/catalog.py +0 -0
- {repwise-3.1.0 → repwise-3.2.0}/src/repwise/garmin/client.py +0 -0
- {repwise-3.1.0 → repwise-3.2.0}/src/repwise/garmin/payloads.py +0 -0
- {repwise-3.1.0 → repwise-3.2.0}/src/repwise/importer.py +0 -0
- {repwise-3.1.0 → repwise-3.2.0}/src/repwise/log.py +0 -0
- {repwise-3.1.0 → repwise-3.2.0}/src/repwise/yamlio.py +0 -0
- {repwise-3.1.0 → repwise-3.2.0}/src/repwise.egg-info/SOURCES.txt +0 -0
- {repwise-3.1.0 → repwise-3.2.0}/src/repwise.egg-info/dependency_links.txt +0 -0
- {repwise-3.1.0 → repwise-3.2.0}/src/repwise.egg-info/entry_points.txt +0 -0
- {repwise-3.1.0 → repwise-3.2.0}/src/repwise.egg-info/requires.txt +0 -0
- {repwise-3.1.0 → repwise-3.2.0}/src/repwise.egg-info/top_level.txt +0 -0
- {repwise-3.1.0 → repwise-3.2.0}/tests/test_catalog.py +0 -0
- {repwise-3.1.0 → repwise-3.2.0}/tests/test_checker.py +0 -0
- {repwise-3.1.0 → repwise-3.2.0}/tests/test_checking.py +0 -0
- {repwise-3.1.0 → repwise-3.2.0}/tests/test_cli.py +0 -0
- {repwise-3.1.0 → repwise-3.2.0}/tests/test_client.py +0 -0
- {repwise-3.1.0 → repwise-3.2.0}/tests/test_completion.py +0 -0
- {repwise-3.1.0 → repwise-3.2.0}/tests/test_config.py +0 -0
- {repwise-3.1.0 → repwise-3.2.0}/tests/test_dumps.py +0 -0
- {repwise-3.1.0 → repwise-3.2.0}/tests/test_effort.py +0 -0
- {repwise-3.1.0 → repwise-3.2.0}/tests/test_fetch.py +0 -0
- {repwise-3.1.0 → repwise-3.2.0}/tests/test_importer.py +0 -0
- {repwise-3.1.0 → repwise-3.2.0}/tests/test_importing.py +0 -0
- {repwise-3.1.0 → repwise-3.2.0}/tests/test_listing.py +0 -0
- {repwise-3.1.0 → repwise-3.2.0}/tests/test_log.py +0 -0
- {repwise-3.1.0 → repwise-3.2.0}/tests/test_logout.py +0 -0
- {repwise-3.1.0 → repwise-3.2.0}/tests/test_main.py +0 -0
- {repwise-3.1.0 → repwise-3.2.0}/tests/test_matching.py +0 -0
- {repwise-3.1.0 → repwise-3.2.0}/tests/test_payloads.py +0 -0
- {repwise-3.1.0 → repwise-3.2.0}/tests/test_report.py +0 -0
- {repwise-3.1.0 → repwise-3.2.0}/tests/test_update.py +0 -0
- {repwise-3.1.0 → repwise-3.2.0}/tests/test_yamlio.py +0 -0
|
@@ -29,6 +29,7 @@ from ..planner import (
|
|
|
29
29
|
History,
|
|
30
30
|
Performed,
|
|
31
31
|
Plan,
|
|
32
|
+
decided_markers,
|
|
32
33
|
decided_targets,
|
|
33
34
|
executed_targets,
|
|
34
35
|
find_workout,
|
|
@@ -316,6 +317,7 @@ def sync_other_workouts(
|
|
|
316
317
|
config: Config,
|
|
317
318
|
source: Workout,
|
|
318
319
|
targets: dict[str, Target],
|
|
320
|
+
markers: dict[str, str],
|
|
319
321
|
) -> list[Plan]:
|
|
320
322
|
"""Propagate decided targets into every other workout that shares them.
|
|
321
323
|
|
|
@@ -324,6 +326,10 @@ def sync_other_workouts(
|
|
|
324
326
|
name, and the weight one of them earned is not a weight the other can be
|
|
325
327
|
asked for: 20 kg of gym machine says nothing about a pair of dumbbells.
|
|
326
328
|
Such an entry is left where it is, to be moved by its own sessions.
|
|
329
|
+
|
|
330
|
+
`markers` is carried on the same terms and gated the same way. A miss is
|
|
331
|
+
about the exercise as it was actually loaded, so a miss on the gym cable
|
|
332
|
+
says nothing about the same movement done on a band at home.
|
|
327
333
|
"""
|
|
328
334
|
loads = {normalise(spec.garmin_name): spec.load for spec in source.exercises}
|
|
329
335
|
|
|
@@ -333,15 +339,22 @@ def sync_other_workouts(
|
|
|
333
339
|
continue
|
|
334
340
|
|
|
335
341
|
carried: dict[str, Target] = {}
|
|
342
|
+
held: dict[str, str] = {}
|
|
336
343
|
for spec in other.exercises:
|
|
337
344
|
name = normalise(spec.garmin_name)
|
|
338
|
-
if
|
|
345
|
+
if spec.load != loads.get(name):
|
|
346
|
+
continue
|
|
347
|
+
if name in targets:
|
|
339
348
|
carried[name] = targets[name]
|
|
340
|
-
|
|
349
|
+
if name in markers:
|
|
350
|
+
held[name] = markers[name]
|
|
351
|
+
# A hold moves no target, so a workout worth visiting for its notes
|
|
352
|
+
# alone is the ordinary case rather than an edge one.
|
|
353
|
+
if not carried and not held:
|
|
341
354
|
continue
|
|
342
355
|
|
|
343
356
|
payload = payloads[garmin_id(other)]
|
|
344
|
-
plan = plan_sync(other, payload, carried, source.key)
|
|
357
|
+
plan = plan_sync(other, payload, carried, held, source.key)
|
|
345
358
|
if not plan.writable:
|
|
346
359
|
continue
|
|
347
360
|
|
|
@@ -454,10 +467,16 @@ def advance_trained(
|
|
|
454
467
|
report_plan(plan)
|
|
455
468
|
plans.append(plan)
|
|
456
469
|
|
|
457
|
-
# Anything that moved must move everywhere that exercise appears
|
|
470
|
+
# Anything that moved must move everywhere that exercise appears, and
|
|
471
|
+
# so must a hold - which moves nothing, so it has to be asked for
|
|
472
|
+
# separately or a stalled exercise would carry its marker in one
|
|
473
|
+
# workout and not in the others.
|
|
458
474
|
targets = decided_targets(plan)
|
|
459
|
-
|
|
460
|
-
|
|
475
|
+
markers = decided_markers(plan)
|
|
476
|
+
if targets or markers:
|
|
477
|
+
plans.extend(
|
|
478
|
+
sync_other_workouts(payloads, config, workout, targets, markers)
|
|
479
|
+
)
|
|
461
480
|
|
|
462
481
|
return plans, usable
|
|
463
482
|
|
|
@@ -5,6 +5,7 @@ lives in, and the settings that govern progression. Nothing here reads a file
|
|
|
5
5
|
or talks to Garmin.
|
|
6
6
|
"""
|
|
7
7
|
|
|
8
|
+
import re
|
|
8
9
|
from collections.abc import Iterator
|
|
9
10
|
from dataclasses import dataclass, field
|
|
10
11
|
|
|
@@ -28,6 +29,78 @@ READABLE_NOTE = 160
|
|
|
28
29
|
#: warned about long before it reaches one.
|
|
29
30
|
STORED_NOTE = 512
|
|
30
31
|
|
|
32
|
+
#: The word a note carries while an exercise is holding after a missed target.
|
|
33
|
+
#: Short because it is read on a watch mid-set, and because every character
|
|
34
|
+
#: here is one the cue behind it does not get.
|
|
35
|
+
HOLD = "hold"
|
|
36
|
+
|
|
37
|
+
#: What a hold marker looks like, matched against a whole `|`-separated field
|
|
38
|
+
#: rather than searched for.
|
|
39
|
+
#:
|
|
40
|
+
#: Anchored on purpose. A cue is free text that a user typed, and one of them
|
|
41
|
+
#: begins "hold the chair, lean away" - searching for the word would read that
|
|
42
|
+
#: as a marker, and clearing it would delete the cue. Only a field that is
|
|
43
|
+
#: exactly `hold`, `hold x3` or `hold x3+` and nothing else counts.
|
|
44
|
+
HOLD_MARKER = re.compile(rf"^{HOLD}(?: x\d+\+?)?$")
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def hold_marker(streak: int, sets: int) -> str:
|
|
48
|
+
"""The marker for a session that just missed, `streak` misses behind it.
|
|
49
|
+
|
|
50
|
+
`streak` comes from `miss_streak`, which counts the sessions before the
|
|
51
|
+
latest one, so the figure shown is one more than it: the session that has
|
|
52
|
+
just been judged missed too, and a lifter reading "x2" wants the total
|
|
53
|
+
rather than the history behind it.
|
|
54
|
+
|
|
55
|
+
`miss_streak` stops counting at `sets - 1` because past there the advance
|
|
56
|
+
is already pinned at its minimum and no further history could change the
|
|
57
|
+
target. That bound is invisible to the rules and would be a lie to a
|
|
58
|
+
reader, so a saturated count is marked with a `+`: `hold x3+` on a
|
|
59
|
+
three-set exercise means three *or more*, which is all this can honestly
|
|
60
|
+
say.
|
|
61
|
+
"""
|
|
62
|
+
misses = streak + 1
|
|
63
|
+
if misses == 1:
|
|
64
|
+
return HOLD
|
|
65
|
+
saturated = "+" if streak >= max(sets - 1, 0) else ""
|
|
66
|
+
return f"{HOLD} x{misses}{saturated}"
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def _split_note(note: str) -> tuple[str, str, str]:
|
|
70
|
+
"""A note as its fixed head, its marker, and everything after.
|
|
71
|
+
|
|
72
|
+
The head is the two fields `ExerciseSpec.note` always writes - the rep span
|
|
73
|
+
and the load - and the tail is the cue, which is free text and may hold
|
|
74
|
+
`|` of its own. So the split is bounded rather than greedy: exactly two
|
|
75
|
+
separators to reach the field a marker could occupy, and one more to step
|
|
76
|
+
over it. Anything the cue contains after that is carried whole.
|
|
77
|
+
"""
|
|
78
|
+
parts = note.split(" | ", 2)
|
|
79
|
+
if len(parts) < 3:
|
|
80
|
+
return note, "", ""
|
|
81
|
+
head = " | ".join(parts[:2])
|
|
82
|
+
field, _, rest = parts[2].partition(" | ")
|
|
83
|
+
if HOLD_MARKER.match(field):
|
|
84
|
+
return head, field, rest
|
|
85
|
+
return head, "", parts[2]
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def marker_of(note: str) -> str:
|
|
89
|
+
"""The hold marker a note is carrying, or empty where it has none."""
|
|
90
|
+
return _split_note(note)[1]
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def with_marker(note: str, marker: str) -> str:
|
|
94
|
+
"""The same note carrying exactly `marker`, which empty clears.
|
|
95
|
+
|
|
96
|
+
Idempotent by construction: a note already carrying the marker asked for
|
|
97
|
+
comes back unchanged, which is what lets `update` run twice over one
|
|
98
|
+
session and write nothing the second time.
|
|
99
|
+
"""
|
|
100
|
+
head, _, rest = _split_note(note)
|
|
101
|
+
written = " | ".join(part for part in (head, marker, rest) if part)
|
|
102
|
+
return written[:STORED_NOTE]
|
|
103
|
+
|
|
31
104
|
|
|
32
105
|
@dataclass(frozen=True)
|
|
33
106
|
class LoadTier:
|
|
@@ -195,6 +195,34 @@ def miss_streak(spec: ExerciseSpec, history: list[Session], weight: float) -> in
|
|
|
195
195
|
#: they wait three failures because they have no rep range to give first.
|
|
196
196
|
STALLED_AFTER = 1
|
|
197
197
|
|
|
198
|
+
#: How every reason for a session that fell short of its target begins.
|
|
199
|
+
#:
|
|
200
|
+
#: The rules say what a session earned by returning a target; whether it
|
|
201
|
+
#: *failed* is a second question, and only the reason string distinguishes a
|
|
202
|
+
#: target that held because the session missed from one that held because
|
|
203
|
+
#: there was nothing to learn. Matching on the reason is the cheap way to ask
|
|
204
|
+
#: it - `next_target` has one caller in the application and around a hundred
|
|
205
|
+
#: in the tests, so widening its return to carry a flag would churn all of
|
|
206
|
+
#: them to answer a question only the note asks.
|
|
207
|
+
#:
|
|
208
|
+
#: The cost is a list that has to be kept in step with the reasons below it,
|
|
209
|
+
#: which `test_every_miss_is_recognised` is there to enforce: it walks each
|
|
210
|
+
#: failing path and asserts `missed` knows it. Add a reason without adding it
|
|
211
|
+
#: here and that test fails rather than the marker quietly never appearing.
|
|
212
|
+
MISS_REASONS = ("missed target", "missed twice", "stalled at the bottom")
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
def missed(reason: str) -> bool:
|
|
216
|
+
"""Whether a reason from `next_target` reports a session that fell short.
|
|
217
|
+
|
|
218
|
+
Deliberately narrower than "the target did not go up". A session that
|
|
219
|
+
logged too few sets to judge, or one that came in under `rep_low` at a
|
|
220
|
+
load nobody prescribed, also leaves the target where it was - but neither
|
|
221
|
+
is a failed attempt at the figure on the watch, and telling someone to
|
|
222
|
+
hold a number they never really tried for would be noise.
|
|
223
|
+
"""
|
|
224
|
+
return reason.startswith(MISS_REASONS)
|
|
225
|
+
|
|
198
226
|
|
|
199
227
|
def _ladder(spec: ExerciseSpec, target: Target) -> int:
|
|
200
228
|
"""Where a target sits on the ladder, so two of them can be compared.
|
|
@@ -11,12 +11,20 @@ from dataclasses import dataclass, field, replace
|
|
|
11
11
|
from typing import Any
|
|
12
12
|
|
|
13
13
|
from .domain.matching import ExerciseIndex, normalise, variants
|
|
14
|
-
from .domain.models import
|
|
14
|
+
from .domain.models import (
|
|
15
|
+
Config,
|
|
16
|
+
ExerciseSpec,
|
|
17
|
+
Workout,
|
|
18
|
+
hold_marker,
|
|
19
|
+
marker_of,
|
|
20
|
+
with_marker,
|
|
21
|
+
)
|
|
15
22
|
from .domain.progression import (
|
|
16
23
|
PerformedSet,
|
|
17
24
|
Session,
|
|
18
25
|
Target,
|
|
19
26
|
miss_streak,
|
|
27
|
+
missed,
|
|
20
28
|
next_target,
|
|
21
29
|
working_weight,
|
|
22
30
|
)
|
|
@@ -62,6 +70,12 @@ class Change:
|
|
|
62
70
|
old: Target
|
|
63
71
|
new: Target
|
|
64
72
|
reason: str
|
|
73
|
+
#: What the step note should say about holding, or None to leave whatever
|
|
74
|
+
#: it already says alone. Three states rather than two, because "this
|
|
75
|
+
#: session had nothing to tell us" is not the same as "this session went
|
|
76
|
+
#: well": a run that judged no session must not clear a marker it never
|
|
77
|
+
#: looked at. See `_refresh_note`.
|
|
78
|
+
marker: str | None = None
|
|
65
79
|
|
|
66
80
|
@property
|
|
67
81
|
def moved(self) -> bool:
|
|
@@ -539,13 +553,20 @@ def _judge( # noqa: PLR0913 - each argument is one independent input
|
|
|
539
553
|
# Garmin logs a hold as 1 rep; the duration is the real figure.
|
|
540
554
|
logged = [entry.as_time() for entry in logged]
|
|
541
555
|
|
|
542
|
-
|
|
543
|
-
|
|
556
|
+
streak = _streak(spec, logged, history)
|
|
557
|
+
new, why = next_target(spec, current, logged, streak)
|
|
558
|
+
# A session that fell short leaves the number on the watch for you to try
|
|
559
|
+
# again, and the note says so - see `_refresh_note`. Anything else clears
|
|
560
|
+
# the marker rather than leaving it None: a session that advanced, or one
|
|
561
|
+
# that only banked a load, is evidence the hold is over.
|
|
562
|
+
marker = hold_marker(streak, spec.sets) if missed(why) else ""
|
|
563
|
+
return Change(spec, current, new, why, marker)
|
|
544
564
|
|
|
545
565
|
|
|
546
566
|
def _refresh_note(
|
|
547
567
|
block: ExerciseBlock,
|
|
548
568
|
spec: ExerciseSpec,
|
|
569
|
+
marker: str | None,
|
|
549
570
|
notes: list[NoteChange],
|
|
550
571
|
warnings: list[str],
|
|
551
572
|
) -> None:
|
|
@@ -558,19 +579,27 @@ def _refresh_note(
|
|
|
558
579
|
A ramped exercise has the same note on both of its halves - they are one
|
|
559
580
|
exercise, programmed one way - so a cue typed onto either is enough to
|
|
560
581
|
leave both alone.
|
|
582
|
+
|
|
583
|
+
`marker` is the one thing here the config does not decide, and None is
|
|
584
|
+
what keeps that honest: it means this run judged no session for this
|
|
585
|
+
exercise, so the note keeps whatever it was already saying. Deriving the
|
|
586
|
+
marker afresh every run instead would clear it on the three runs out of
|
|
587
|
+
four that have nothing to say - an `update` for another workout, a second
|
|
588
|
+
`--apply` over the same activity, a run that found no session at all -
|
|
589
|
+
and the marker would survive only until the next command.
|
|
561
590
|
"""
|
|
562
|
-
|
|
563
|
-
own = [
|
|
564
|
-
note
|
|
565
|
-
for note in (step_note(step) for step in block.steps)
|
|
566
|
-
if note and not GENERATED_NOTE.match(note)
|
|
567
|
-
]
|
|
591
|
+
existing = [step_note(step) for step in block.steps]
|
|
592
|
+
own = [note for note in existing if note and not GENERATED_NOTE.match(note)]
|
|
568
593
|
if own:
|
|
569
594
|
warnings.append(
|
|
570
|
-
f"{spec.name}: has its own note, left alone (wanted {
|
|
595
|
+
f"{spec.name}: has its own note, left alone (wanted {spec.note!r})"
|
|
571
596
|
)
|
|
572
597
|
return
|
|
573
598
|
|
|
599
|
+
if marker is None:
|
|
600
|
+
marker = next((marker_of(note) for note in existing if note), "")
|
|
601
|
+
wanted = with_marker(spec.note, marker)
|
|
602
|
+
|
|
574
603
|
stale = [step for step in block.steps if step_note(step) != wanted]
|
|
575
604
|
if not stale:
|
|
576
605
|
return
|
|
@@ -674,18 +703,34 @@ def _refresh_block(
|
|
|
674
703
|
block: ExerciseBlock,
|
|
675
704
|
spec: ExerciseSpec,
|
|
676
705
|
current: Target | None,
|
|
706
|
+
marker: str | None,
|
|
677
707
|
shaped: _Shaping,
|
|
678
708
|
) -> list[dict[str, Any]] | None:
|
|
679
709
|
"""Write everything workouts.yaml decides about one exercise.
|
|
680
710
|
|
|
681
|
-
The
|
|
682
|
-
|
|
683
|
-
|
|
711
|
+
The rest and the set count describe the programming rather than the
|
|
712
|
+
progress, so they are applied whether or not a session moved anything.
|
|
713
|
+
|
|
714
|
+
The note is the exception, and `marker` is why. Almost all of it is
|
|
715
|
+
programming - the rep span, the load step, the cue - but it also carries
|
|
716
|
+
whether the last session missed, which nothing else stores: Garmin holds
|
|
717
|
+
the target, not the verdict that produced it, and this tool keeps no state
|
|
718
|
+
file of its own. So the note does for a miss what the stored target does
|
|
719
|
+
for a rep count, and that makes it the one field here that has to wait on
|
|
720
|
+
a verdict - which is the whole reason `marker` is a parameter rather than
|
|
721
|
+
something `spec` could answer. `plan_workout` judges the session first and
|
|
722
|
+
passes what it found; `plan_sync` passes what the session that decided it
|
|
723
|
+
found elsewhere.
|
|
684
724
|
|
|
685
725
|
Returns what `_refresh_sets` returned: the steps the exercise now occupies
|
|
686
726
|
when its count was rewritten, and None when it was not.
|
|
687
727
|
"""
|
|
688
|
-
|
|
728
|
+
# Before `_refresh_sets`, which may build a second group for a ramp: a
|
|
729
|
+
# group built there takes its note from `spec` alone and would carry no
|
|
730
|
+
# marker. Writing here puts the marker on every step that already exists,
|
|
731
|
+
# and a freshly built half is corrected on the next run - the same one-run
|
|
732
|
+
# lag a rep-range edit has always had.
|
|
733
|
+
_refresh_note(block, spec, marker, shaped.notes, shaped.warnings)
|
|
689
734
|
_refresh_rest(block, spec, shaped.rests, shaped.skips, shaped.warnings)
|
|
690
735
|
return _refresh_sets(block, spec, current, shaped.sets, shaped.warnings)
|
|
691
736
|
|
|
@@ -1082,12 +1127,10 @@ def plan_workout( # noqa: PLR0913 - each argument is one independent input
|
|
|
1082
1127
|
|
|
1083
1128
|
current = block_target(block, spec)
|
|
1084
1129
|
|
|
1085
|
-
#
|
|
1086
|
-
#
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
reshaped |= _relay(layout, position, recounted)
|
|
1090
|
-
|
|
1130
|
+
# Judged before the refresh below, which is the reverse of how this
|
|
1131
|
+
# read until the note started carrying whether the last session
|
|
1132
|
+
# missed. `_judge` only reads the block, so nothing it decides depends
|
|
1133
|
+
# on the refresh; the refresh's note now depends on it.
|
|
1091
1134
|
change = _judge(
|
|
1092
1135
|
spec,
|
|
1093
1136
|
block,
|
|
@@ -1100,6 +1143,15 @@ def plan_workout( # noqa: PLR0913 - each argument is one independent input
|
|
|
1100
1143
|
shaped=shaped,
|
|
1101
1144
|
)
|
|
1102
1145
|
|
|
1146
|
+
# What the config says about this exercise holds whether or not this
|
|
1147
|
+
# session moved anything. The marker is the one part that does not:
|
|
1148
|
+
# None where no session was judged, which leaves the note's alone.
|
|
1149
|
+
recounted = _refresh_block(
|
|
1150
|
+
block, spec, current, change.marker if change is not None else None, shaped
|
|
1151
|
+
)
|
|
1152
|
+
if recounted is not None:
|
|
1153
|
+
reshaped |= _relay(layout, position, recounted)
|
|
1154
|
+
|
|
1103
1155
|
# The last word on the target, whether a session decided it or nobody
|
|
1104
1156
|
# did: with partial progression off, a ramp is not a shape this workout
|
|
1105
1157
|
# is allowed to hold, so it is evened out here rather than left for a
|
|
@@ -1116,6 +1168,10 @@ def plan_workout( # noqa: PLR0913 - each argument is one independent input
|
|
|
1116
1168
|
change.old if change is not None else decided,
|
|
1117
1169
|
fixed,
|
|
1118
1170
|
f"{said}; {label}" if said and said not in SAYS_NOTHING else label,
|
|
1171
|
+
# Levelling a ramp is a change of shape, not a verdict on
|
|
1172
|
+
# the session, so it does not get a say in the marker. The
|
|
1173
|
+
# note has already been written by here either way.
|
|
1174
|
+
change.marker if change is not None else None,
|
|
1119
1175
|
)
|
|
1120
1176
|
|
|
1121
1177
|
if change is None:
|
|
@@ -1148,6 +1204,7 @@ def plan_sync(
|
|
|
1148
1204
|
workout: Workout,
|
|
1149
1205
|
payload: dict[str, Any],
|
|
1150
1206
|
targets: dict[str, Target],
|
|
1207
|
+
markers: dict[str, str],
|
|
1151
1208
|
source: str,
|
|
1152
1209
|
) -> Plan:
|
|
1153
1210
|
"""Force already-decided targets onto another workout's matching steps.
|
|
@@ -1155,6 +1212,13 @@ def plan_sync(
|
|
|
1155
1212
|
An exercise can appear in more than one workout -- the calf raise is in
|
|
1156
1213
|
both -- and a target earned in one session should hold everywhere it
|
|
1157
1214
|
appears, otherwise the copies drift apart.
|
|
1215
|
+
|
|
1216
|
+
`markers` travels with them for the same reason. Missing a target is a
|
|
1217
|
+
fact about the exercise rather than about the workout it was missed in, so
|
|
1218
|
+
a copy that said nothing about it would be a copy that disagrees. An
|
|
1219
|
+
exercise absent from `markers` was not decided by this session and keeps
|
|
1220
|
+
whatever its note already says, which is what `None` means to
|
|
1221
|
+
`_refresh_block`.
|
|
1158
1222
|
"""
|
|
1159
1223
|
specs = index_specs(workout.exercises)
|
|
1160
1224
|
|
|
@@ -1174,7 +1238,9 @@ def plan_sync(
|
|
|
1174
1238
|
|
|
1175
1239
|
current = block_target(block, spec)
|
|
1176
1240
|
|
|
1177
|
-
recounted = _refresh_block(
|
|
1241
|
+
recounted = _refresh_block(
|
|
1242
|
+
block, spec, current, markers.get(normalise(spec.garmin_name)), shaped
|
|
1243
|
+
)
|
|
1178
1244
|
if recounted is not None:
|
|
1179
1245
|
reshaped |= _relay(layout, position, recounted)
|
|
1180
1246
|
|
|
@@ -1253,3 +1319,19 @@ def executed_targets(
|
|
|
1253
1319
|
def decided_targets(plan: Plan) -> dict[str, Target]:
|
|
1254
1320
|
"""The targets that moved, keyed for lookup in another workout."""
|
|
1255
1321
|
return {normalise(c.spec.garmin_name): c.new for c in plan.moved}
|
|
1322
|
+
|
|
1323
|
+
|
|
1324
|
+
def decided_markers(plan: Plan) -> dict[str, str]:
|
|
1325
|
+
"""What each judged exercise's note should say about holding.
|
|
1326
|
+
|
|
1327
|
+
Read from every change rather than from `plan.moved`, which is the whole
|
|
1328
|
+
difference between this and `decided_targets`: a hold is a target that
|
|
1329
|
+
stayed exactly where it was, so the sessions this most needs to propagate
|
|
1330
|
+
are precisely the ones that moved nothing. A change carrying None judged
|
|
1331
|
+
no session and is left out, so a copy elsewhere keeps its own note.
|
|
1332
|
+
"""
|
|
1333
|
+
return {
|
|
1334
|
+
normalise(c.spec.garmin_name): c.marker
|
|
1335
|
+
for c in plan.changes
|
|
1336
|
+
if c.marker is not None
|
|
1337
|
+
}
|
|
@@ -12,6 +12,9 @@ from repwise.domain.models import (
|
|
|
12
12
|
ExerciseSpec,
|
|
13
13
|
LoadTier,
|
|
14
14
|
Workout,
|
|
15
|
+
hold_marker,
|
|
16
|
+
marker_of,
|
|
17
|
+
with_marker,
|
|
15
18
|
)
|
|
16
19
|
|
|
17
20
|
|
|
@@ -96,6 +99,77 @@ def test_no_cue_leaves_the_note_exactly_as_it_was():
|
|
|
96
99
|
)
|
|
97
100
|
|
|
98
101
|
|
|
102
|
+
# --- the hold marker a note carries ---------------------------------------
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
PLAIN = "6-10 reps | +5 kg"
|
|
106
|
+
CUED = "6-10 reps | +5 kg | 0-1 RIR | knees out"
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
def test_a_marker_goes_between_the_load_and_the_cue():
|
|
110
|
+
assert with_marker(CUED, "hold") == "6-10 reps | +5 kg | hold | 0-1 RIR | knees out"
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
def test_a_marker_can_be_added_to_a_note_with_no_cue():
|
|
114
|
+
assert with_marker(PLAIN, "hold x2") == "6-10 reps | +5 kg | hold x2"
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
def test_a_marker_round_trips():
|
|
118
|
+
assert marker_of(with_marker(CUED, "hold x3+")) == "hold x3+"
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
def test_writing_the_same_marker_twice_changes_nothing():
|
|
122
|
+
"""What makes a second `update` over one session a no-op."""
|
|
123
|
+
once = with_marker(CUED, "hold x2")
|
|
124
|
+
assert with_marker(once, "hold x2") == once
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
def test_an_empty_marker_clears_one_that_was_there():
|
|
128
|
+
assert with_marker(with_marker(CUED, "hold"), "") == CUED
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
def test_a_note_with_no_marker_reports_none():
|
|
132
|
+
assert marker_of(CUED) == ""
|
|
133
|
+
assert marker_of(PLAIN) == ""
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
def test_a_cue_beginning_with_the_marker_word_is_not_one():
|
|
137
|
+
"""A real cue starts "hold the chair, lean away". Reading it as a marker
|
|
138
|
+
would clear it, and the cue would be gone with nothing to say so."""
|
|
139
|
+
note = "6-10 reps | +5 kg | hold the chair, lean away"
|
|
140
|
+
assert marker_of(note) == ""
|
|
141
|
+
assert with_marker(note, "hold") == (
|
|
142
|
+
"6-10 reps | +5 kg | hold | hold the chair, lean away"
|
|
143
|
+
)
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
def test_a_cue_carrying_pipes_of_its_own_is_read_whole():
|
|
147
|
+
"""The cue is free text and every real one contains `|`, so the split has
|
|
148
|
+
to stop counting once it has passed the field a marker could be in - and
|
|
149
|
+
the rest, however many separators it holds, is cue."""
|
|
150
|
+
marked = with_marker(CUED, "hold x2")
|
|
151
|
+
assert marker_of(marked) == "hold x2"
|
|
152
|
+
assert marked.endswith("| 0-1 RIR | knees out"), "the cue arrived intact"
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
def test_the_first_miss_needs_no_count():
|
|
156
|
+
assert hold_marker(0, 3) == "hold"
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
def test_later_misses_count_the_session_being_judged_too():
|
|
160
|
+
"""`miss_streak` counts the sessions *before* this one, and a reader
|
|
161
|
+
wants the total."""
|
|
162
|
+
assert hold_marker(1, 3) == "hold x2"
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
def test_a_streak_at_the_limit_of_what_can_be_counted_is_marked():
|
|
166
|
+
"""`miss_streak` stops at `sets - 1`, so 3 on a three-set exercise means
|
|
167
|
+
three or more and should not claim to be exact."""
|
|
168
|
+
assert hold_marker(2, 3) == "hold x3+"
|
|
169
|
+
assert hold_marker(3, 4) == "hold x4+"
|
|
170
|
+
assert hold_marker(2, 4) == "hold x3", "still below the limit, so exact"
|
|
171
|
+
|
|
172
|
+
|
|
99
173
|
# --- which rack a weight is on --------------------------------------------
|
|
100
174
|
#
|
|
101
175
|
# All of this was covered and none of it was asserted: mutation testing found
|
|
@@ -17,7 +17,7 @@ from builders import (
|
|
|
17
17
|
)
|
|
18
18
|
|
|
19
19
|
from repwise.domain.models import Config, Workout
|
|
20
|
-
from repwise.domain.progression import Target
|
|
20
|
+
from repwise.domain.progression import PerformedSet, Session, Target
|
|
21
21
|
from repwise.errors import ActivityNotFound
|
|
22
22
|
from repwise.garmin.payloads import (
|
|
23
23
|
is_timed_rest,
|
|
@@ -28,6 +28,7 @@ from repwise.garmin.payloads import (
|
|
|
28
28
|
)
|
|
29
29
|
from repwise.planner import (
|
|
30
30
|
NOT_TRAINED,
|
|
31
|
+
decided_markers,
|
|
31
32
|
decided_targets,
|
|
32
33
|
find_workout,
|
|
33
34
|
index_specs,
|
|
@@ -358,10 +359,175 @@ def test_notes_reach_a_workout_that_only_receives_a_sync():
|
|
|
358
359
|
payload = workout(rep_step("WEIGHTED_STANDING_CALF_RAISE", "CALF_RAISE", 12, 0.0))
|
|
359
360
|
targets = {"weightedstandingcalfraise": Target(12, 20.0)}
|
|
360
361
|
|
|
361
|
-
plan = plan_sync(
|
|
362
|
+
plan = plan_sync(
|
|
363
|
+
a_workout("Workout B", "2", [CALF]), payload, targets, {}, "Workout A"
|
|
364
|
+
)
|
|
362
365
|
assert noted(plan) == [("Weighted Standing Calf Raise", "", "12-20 reps | +5 kg")]
|
|
363
366
|
|
|
364
367
|
|
|
368
|
+
# --- hold markers ---------------------------------------------------------
|
|
369
|
+
|
|
370
|
+
|
|
371
|
+
def only_note(payload):
|
|
372
|
+
"""What the one exercise step in this payload says."""
|
|
373
|
+
return step_note(next(iter(payload["workoutSegments"][0]["workoutSteps"])))
|
|
374
|
+
|
|
375
|
+
|
|
376
|
+
def a_missed_squat(stored=8, did=7):
|
|
377
|
+
"""A workout stored at `stored` reps, and a session that only did `did`."""
|
|
378
|
+
return workout(rep_step("BARBELL_BACK_SQUAT", "SQUAT", stored, 20.0)), (
|
|
379
|
+
a_squat_session(did)
|
|
380
|
+
)
|
|
381
|
+
|
|
382
|
+
|
|
383
|
+
def test_a_missed_target_marks_the_note_to_hold():
|
|
384
|
+
"""The whole point: the watch says the number was missed last time, so
|
|
385
|
+
this session is for matching it rather than beating it."""
|
|
386
|
+
payload, performed = a_missed_squat()
|
|
387
|
+
plan = plan_workout(a_workout(), payload, performed)
|
|
388
|
+
|
|
389
|
+
assert not plan.moved, "a miss holds the target where it was"
|
|
390
|
+
assert only_note(payload) == "6-10 reps | +2.5 kg | hold"
|
|
391
|
+
assert noted(plan) == [("Barbell Back Squat", "", "6-10 reps | +2.5 kg | hold")]
|
|
392
|
+
|
|
393
|
+
|
|
394
|
+
def test_hitting_the_target_clears_the_marker():
|
|
395
|
+
payload = workout(rep_step("BARBELL_BACK_SQUAT", "SQUAT", 8, 20.0))
|
|
396
|
+
only_step = next(iter(payload["workoutSegments"][0]["workoutSteps"]))
|
|
397
|
+
only_step["description"] = "6-10 reps | +2.5 kg | hold"
|
|
398
|
+
|
|
399
|
+
plan_workout(a_workout(), payload, a_squat_session(8))
|
|
400
|
+
|
|
401
|
+
assert only_note(payload) == "6-10 reps | +2.5 kg", "the hold is over"
|
|
402
|
+
|
|
403
|
+
|
|
404
|
+
def test_running_twice_over_one_session_writes_the_note_once():
|
|
405
|
+
"""Idempotent: a second run must not re-save the workout for nothing."""
|
|
406
|
+
payload, performed = a_missed_squat()
|
|
407
|
+
plan_workout(a_workout(), payload, performed)
|
|
408
|
+
|
|
409
|
+
again = plan_workout(a_workout(), payload, performed)
|
|
410
|
+
|
|
411
|
+
assert again.notes == [], "the marker was already there"
|
|
412
|
+
assert only_note(payload) == "6-10 reps | +2.5 kg | hold", "and did not double up"
|
|
413
|
+
|
|
414
|
+
|
|
415
|
+
def test_a_marker_survives_a_run_that_judged_no_session():
|
|
416
|
+
"""The one that would bite daily: an `update` for another workout must not
|
|
417
|
+
clear a marker it never looked at."""
|
|
418
|
+
payload = workout(rep_step("BARBELL_BACK_SQUAT", "SQUAT", 8, 20.0))
|
|
419
|
+
only_step = next(iter(payload["workoutSegments"][0]["workoutSteps"]))
|
|
420
|
+
only_step["description"] = "6-10 reps | +2.5 kg | hold x2"
|
|
421
|
+
|
|
422
|
+
plan = plan_workout(a_workout(), payload, ({}, {}))
|
|
423
|
+
|
|
424
|
+
assert plan.changes[0].reason == NOT_TRAINED
|
|
425
|
+
assert plan.notes == [], "nothing was judged, so nothing about it changed"
|
|
426
|
+
assert only_note(payload) == "6-10 reps | +2.5 kg | hold x2"
|
|
427
|
+
|
|
428
|
+
|
|
429
|
+
def test_a_marker_survives_a_session_the_target_has_moved_past():
|
|
430
|
+
"""A deload moves the target, so the second run reads `up to date` and has
|
|
431
|
+
no verdict of its own - the marker has to come from the note."""
|
|
432
|
+
payload = workout(rep_step("BARBELL_BACK_SQUAT", "SQUAT", 7, 20.0))
|
|
433
|
+
only_step = next(iter(payload["workoutSegments"][0]["workoutSteps"]))
|
|
434
|
+
only_step["description"] = "6-10 reps | +2.5 kg | hold x2"
|
|
435
|
+
|
|
436
|
+
plan = plan_workout(
|
|
437
|
+
a_workout(),
|
|
438
|
+
payload,
|
|
439
|
+
a_squat_session(7),
|
|
440
|
+
asked={"barbellbacksquat": Target(8, 0.0)},
|
|
441
|
+
)
|
|
442
|
+
|
|
443
|
+
assert plan.changes[0].reason == "up to date"
|
|
444
|
+
assert only_note(payload) == "6-10 reps | +2.5 kg | hold x2"
|
|
445
|
+
|
|
446
|
+
|
|
447
|
+
def test_a_second_miss_in_a_row_is_counted():
|
|
448
|
+
payload, performed = a_missed_squat()
|
|
449
|
+
history = {
|
|
450
|
+
"barbellbacksquat": [
|
|
451
|
+
Session(Target(8, 20.0), [PerformedSet(7, 20.0)] * 3),
|
|
452
|
+
]
|
|
453
|
+
}
|
|
454
|
+
plan_workout(a_workout(), payload, performed, history)
|
|
455
|
+
|
|
456
|
+
assert only_note(payload) == "6-10 reps | +2.5 kg | hold x2"
|
|
457
|
+
|
|
458
|
+
|
|
459
|
+
def test_a_saturated_streak_says_so_rather_than_understating_it():
|
|
460
|
+
"""`miss_streak` stops counting at `sets - 1`, so three on a three-set
|
|
461
|
+
exercise is the most it can ever report. The `+` is that admission."""
|
|
462
|
+
payload, performed = a_missed_squat()
|
|
463
|
+
history = {
|
|
464
|
+
"barbellbacksquat": [Session(Target(8, 20.0), [PerformedSet(7, 20.0)] * 3)] * 5
|
|
465
|
+
}
|
|
466
|
+
plan_workout(a_workout(), payload, performed, history)
|
|
467
|
+
|
|
468
|
+
assert only_note(payload) == "6-10 reps | +2.5 kg | hold x3+"
|
|
469
|
+
|
|
470
|
+
|
|
471
|
+
def test_a_cue_beginning_with_hold_is_not_read_as_a_marker():
|
|
472
|
+
"""One of the real cues starts "hold the chair", and clearing it as if it
|
|
473
|
+
were a marker would delete it."""
|
|
474
|
+
cued = replace(SQUAT, notes="hold the chair, lean away")
|
|
475
|
+
payload = workout(rep_step("BARBELL_BACK_SQUAT", "SQUAT", 8, 20.0))
|
|
476
|
+
only_step = next(iter(payload["workoutSegments"][0]["workoutSteps"]))
|
|
477
|
+
only_step["description"] = "6-10 reps | +2.5 kg | hold the chair, lean away"
|
|
478
|
+
|
|
479
|
+
plan = plan_workout(a_workout(exercises=[cued]), payload, a_squat_session(8))
|
|
480
|
+
|
|
481
|
+
assert plan.notes == [], "the cue was already right, and is not a marker"
|
|
482
|
+
assert only_note(payload) == "6-10 reps | +2.5 kg | hold the chair, lean away"
|
|
483
|
+
|
|
484
|
+
|
|
485
|
+
def test_a_marker_sits_between_the_load_and_the_cue():
|
|
486
|
+
cued = replace(SQUAT, notes="knees out")
|
|
487
|
+
payload, performed = a_missed_squat()
|
|
488
|
+
|
|
489
|
+
plan_workout(a_workout(exercises=[cued]), payload, performed)
|
|
490
|
+
|
|
491
|
+
assert only_note(payload) == "6-10 reps | +2.5 kg | hold | knees out"
|
|
492
|
+
|
|
493
|
+
|
|
494
|
+
def test_sync_carries_a_marker_into_another_workout():
|
|
495
|
+
"""A miss is about the exercise, not about which workout it happened in."""
|
|
496
|
+
payload = workout(rep_step("WEIGHTED_STANDING_CALF_RAISE", "CALF_RAISE", 12, 0.0))
|
|
497
|
+
plan = plan_sync(
|
|
498
|
+
a_workout("Workout B", "2", [CALF]),
|
|
499
|
+
payload,
|
|
500
|
+
{},
|
|
501
|
+
{"weightedstandingcalfraise": "hold x2"},
|
|
502
|
+
"Workout A",
|
|
503
|
+
)
|
|
504
|
+
|
|
505
|
+
assert noted(plan) == [
|
|
506
|
+
("Weighted Standing Calf Raise", "", "12-20 reps | +5 kg | hold x2")
|
|
507
|
+
]
|
|
508
|
+
|
|
509
|
+
|
|
510
|
+
def test_sync_leaves_the_note_of_an_exercise_it_was_told_nothing_about():
|
|
511
|
+
payload = workout(rep_step("WEIGHTED_STANDING_CALF_RAISE", "CALF_RAISE", 12, 0.0))
|
|
512
|
+
only_step = next(iter(payload["workoutSegments"][0]["workoutSteps"]))
|
|
513
|
+
only_step["description"] = "12-20 reps | +5 kg | hold"
|
|
514
|
+
|
|
515
|
+
plan = plan_sync(a_workout("Workout B", "2", [CALF]), payload, {}, {}, "Workout A")
|
|
516
|
+
|
|
517
|
+
assert plan.notes == []
|
|
518
|
+
assert only_note(payload) == "12-20 reps | +5 kg | hold"
|
|
519
|
+
|
|
520
|
+
|
|
521
|
+
def test_a_hold_is_collected_for_syncing_even_though_it_moved_nothing():
|
|
522
|
+
"""`decided_targets` reads `plan.moved` and would miss every hold, which
|
|
523
|
+
is exactly the case a marker exists for."""
|
|
524
|
+
payload, performed = a_missed_squat()
|
|
525
|
+
plan = plan_workout(a_workout(), payload, performed)
|
|
526
|
+
|
|
527
|
+
assert decided_targets(plan) == {}, "a hold moves no target"
|
|
528
|
+
assert decided_markers(plan) == {"barbellbacksquat": "hold"}
|
|
529
|
+
|
|
530
|
+
|
|
365
531
|
# --- rest between sets ----------------------------------------------------
|
|
366
532
|
|
|
367
533
|
|
|
@@ -453,7 +619,7 @@ def test_rests_reach_a_workout_that_only_receives_a_sync():
|
|
|
453
619
|
targets = {"weightedstandingcalfraise": Target(12, 20.0)}
|
|
454
620
|
|
|
455
621
|
plan = plan_sync(
|
|
456
|
-
a_workout("Workout B", "2", [rested_calf]), built, targets, "Workout A"
|
|
622
|
+
a_workout("Workout B", "2", [rested_calf]), built, targets, {}, "Workout A"
|
|
457
623
|
)
|
|
458
624
|
|
|
459
625
|
assert [(c.old, c.new) for c in plan.rests] == [(60, 90)]
|
|
@@ -536,7 +702,9 @@ def test_the_last_rest_is_restored_in_a_workout_that_only_receives_a_sync():
|
|
|
536
702
|
built = skipping(workout(repeat(step, sets=3, rest=60.0)))
|
|
537
703
|
targets = {"weightedstandingcalfraise": Target(12, 20.0)}
|
|
538
704
|
|
|
539
|
-
plan = plan_sync(
|
|
705
|
+
plan = plan_sync(
|
|
706
|
+
a_workout("Workout B", "2", [CALF]), built, targets, {}, "Workout A"
|
|
707
|
+
)
|
|
540
708
|
|
|
541
709
|
assert skips_of(built) == [False]
|
|
542
710
|
assert [c.spec.name for c in plan.skips] == [CALF.name]
|
|
@@ -965,7 +1133,9 @@ def test_sync_pushes_a_decided_target_into_another_workout():
|
|
|
965
1133
|
payload = workout(rep_step("WEIGHTED_STANDING_CALF_RAISE", "CALF_RAISE", 12, 0.0))
|
|
966
1134
|
targets = {"weightedstandingcalfraise": Target(12, 20.0)}
|
|
967
1135
|
|
|
968
|
-
plan = plan_sync(
|
|
1136
|
+
plan = plan_sync(
|
|
1137
|
+
a_workout("Workout B", "2", [CALF]), payload, targets, {}, "Workout A"
|
|
1138
|
+
)
|
|
969
1139
|
|
|
970
1140
|
assert plan.moved
|
|
971
1141
|
assert plan.changes[0].new == Target(12, 20.0)
|
|
@@ -974,7 +1144,7 @@ def test_sync_pushes_a_decided_target_into_another_workout():
|
|
|
974
1144
|
|
|
975
1145
|
def test_sync_ignores_exercises_that_did_not_move():
|
|
976
1146
|
payload = workout(rep_step("BARBELL_BACK_SQUAT", "SQUAT", 7, 20.0))
|
|
977
|
-
plan = plan_sync(a_workout(), payload, {"somethingelse": Target(9, 9.0)}, "A")
|
|
1147
|
+
plan = plan_sync(a_workout(), payload, {"somethingelse": Target(9, 9.0)}, {}, "A")
|
|
978
1148
|
assert plan.changes == []
|
|
979
1149
|
|
|
980
1150
|
|
|
@@ -982,7 +1152,9 @@ def test_sync_warns_when_a_target_leaves_the_range():
|
|
|
982
1152
|
payload = workout(group_of(CALF, 12, 0.0))
|
|
983
1153
|
targets = {"weightedstandingcalfraise": Target(30, 20.0)} # above rep_high 20
|
|
984
1154
|
|
|
985
|
-
plan = plan_sync(
|
|
1155
|
+
plan = plan_sync(
|
|
1156
|
+
a_workout("Workout B", "2", [CALF]), payload, targets, {}, "Workout A"
|
|
1157
|
+
)
|
|
986
1158
|
assert "outside this workout's 12-20 range" in plan.warnings[0]
|
|
987
1159
|
|
|
988
1160
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"""The double progression rules."""
|
|
2
2
|
|
|
3
|
+
import pytest
|
|
3
4
|
from builders import held, spec
|
|
4
5
|
|
|
5
6
|
from repwise.domain.models import LoadTier
|
|
@@ -13,6 +14,7 @@ from repwise.domain.progression import (
|
|
|
13
14
|
next_target,
|
|
14
15
|
working_weight,
|
|
15
16
|
)
|
|
17
|
+
from repwise.domain.progression import missed as is_miss
|
|
16
18
|
|
|
17
19
|
SQUAT = spec()
|
|
18
20
|
LUNGE = spec(
|
|
@@ -702,6 +704,61 @@ def test_easing_steps_by_rep_step():
|
|
|
702
704
|
assert target.per_set(4, rep_step=2) == [20, 20, 20, 18]
|
|
703
705
|
|
|
704
706
|
|
|
707
|
+
#: Every way a session can fall short, and what each is called. Written out
|
|
708
|
+
#: rather than generated because the point is to notice a *new* one: a rule
|
|
709
|
+
#: that fails a session in some way not listed here is a rule whose reason
|
|
710
|
+
#: `missed` has never been shown, and the marker would quietly never appear
|
|
711
|
+
#: for it.
|
|
712
|
+
MISSES = [
|
|
713
|
+
("first miss", BARBELL_SQUAT, Target(9, 20.0), [P(8, 20.0)] * 3, 0),
|
|
714
|
+
("eased by one", BARBELL_SQUAT, Target(9, 20.0), [P(8, 20.0)] * 3, 1),
|
|
715
|
+
("eased to the bottom", BARBELL_SQUAT, Target(7, 20.0), [P(3, 20.0)] * 3, 1),
|
|
716
|
+
("eased to the session", BARBELL_SQUAT, Target(10, 20.0), [P(7, 20.0)] * 3, 1),
|
|
717
|
+
("load comes off", BARBELL_SQUAT, Target(6, 20.0), [P(5, 20.0)] * 3, 1),
|
|
718
|
+
("already at the minimum", LIGHT_RAISE, Target(12, 1.0), [P(10, 1.0)] * 3, 1),
|
|
719
|
+
("nothing to take off", PLANK, Target(30, 0.0), held(28, 28, 28), 1),
|
|
720
|
+
]
|
|
721
|
+
|
|
722
|
+
|
|
723
|
+
@pytest.mark.parametrize(
|
|
724
|
+
("label", "spec_", "current", "performed", "streak"),
|
|
725
|
+
MISSES,
|
|
726
|
+
ids=[case[0] for case in MISSES],
|
|
727
|
+
)
|
|
728
|
+
def test_every_miss_is_recognised(label, spec_, current, performed, streak):
|
|
729
|
+
"""The guard on `MISS_REASONS`. It is a list of prefixes matched against
|
|
730
|
+
free text, so the way it rots is silently: a reason is reworded or added,
|
|
731
|
+
nothing raises, and the note simply stops saying `hold`."""
|
|
732
|
+
_, why = next_target(spec_, current, performed, streak=streak)
|
|
733
|
+
assert is_miss(why), f"{label}: {why!r} is a failed session and reads as one"
|
|
734
|
+
|
|
735
|
+
|
|
736
|
+
@pytest.mark.parametrize(
|
|
737
|
+
("label", "why"),
|
|
738
|
+
[
|
|
739
|
+
("advanced", next_target(BARBELL_SQUAT, Target(8, 20.0), [P(8, 20.0)] * 3)[1]),
|
|
740
|
+
(
|
|
741
|
+
"topped out",
|
|
742
|
+
next_target(BARBELL_SQUAT, Target(10, 20.0), [P(10, 20.0)] * 3)[1],
|
|
743
|
+
),
|
|
744
|
+
("nothing logged", next_target(BARBELL_SQUAT, Target(9, 20.0), [])[1]),
|
|
745
|
+
(
|
|
746
|
+
"too few sets",
|
|
747
|
+
next_target(BARBELL_SQUAT, Target(9, 20.0), [P(9, 20.0)] * 2)[1],
|
|
748
|
+
),
|
|
749
|
+
(
|
|
750
|
+
"a load nobody asked for",
|
|
751
|
+
next_target(LIGHT_RAISE, Target(13, 3.0), [P(8, 4.0)] * 3, streak=1)[1],
|
|
752
|
+
),
|
|
753
|
+
],
|
|
754
|
+
)
|
|
755
|
+
def test_what_is_not_a_miss(label, why):
|
|
756
|
+
"""The other half. Telling someone to hold a number they never really
|
|
757
|
+
tried for - a half-logged session, a load nobody prescribed - would be
|
|
758
|
+
noise, so those leave the target alone without being called failures."""
|
|
759
|
+
assert not is_miss(why), f"{label}: {why!r}"
|
|
760
|
+
|
|
761
|
+
|
|
705
762
|
def test_a_deload_and_the_climb_back_are_the_same_ladder():
|
|
706
763
|
"""Ease down, then hit it: the granular advance takes it straight back."""
|
|
707
764
|
eased, _ = next_target(
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|