Generate clean 2D game sprites & animation atlases — component-row pipeline: state rows, alpha cleanup, frame extraction, runtime atlases. Codex/Claude skill.
fix(video): a walk's crossings mark cycles only where its body rises and falls twice an interval, and video-set leaves an unwitnessed walk out of its cycle alignment
Soohong Kim9bb1c4805bdc
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex a5d751b..b34b2f0 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -2,30 +2,34 @@All notable public changes to `sprite-gen` are recorded here. Versions track the `version:` field in `SKILL.md` and `pyproject.toml`.-## Unreleased - A walk whose feet meet once a cycle is cut one cycle long, a walk that starts or stops in its take is named to film again, and video-set cuts a searched walk or run with motion-auto by default+## Unreleased - A walk whose feet meet once a cycle is cut one cycle long only where its body witnesses it, a walk that starts or stops in its take is named to film again, and video-set cuts a searched walk or run with motion-auto by default-**Upgrading from 3.5.0: `video-set` now cuts searched walk and run loops with `--anchor motion-auto` and their view by default, and `video-loop --anchor motion-auto` recognises crossings that mark cycles where feet hide or step apart instead of cutting two cycles.** Every walk or run item whose loop is searched is now cut with `motion-auto` and its view, producing a different cut and different bytes; `--anchor none` gives the old cut, its pictures and reports byte for byte apart from the engine hash (`producer.implementation_sha256`). Idle, attack, once-hold, lifetime, and once-return items are cut as before. In `video-loop --anchor motion-auto` without `--view`, a walk whose feet are seen together over half the interval at a pass (`crossings.HIDE_SHARE`, 0.5) and whose picture repeats each interval is now counted on cycles only where the shade of its feet's two halves moves: where the parent engine cut two cycles, the loop is now one cycle with new bytes; where the parent engine kept the search's cut with no `steps`, the cut is the same and the strip and report now record `steps: 2`; where the shade does not move (legs drawn alike to it), its crossings stay on steps, cut as in 3.5.0, with a warning. A walk whose crossings mark steps (brief passes, or from the side) is cut to the same bytes. With `--view` (or through `video-set`), a front, back, or diagonal walk is evaluated even with brief passes: such a walk is counted on cycles only where its foot cue turns over half an interval on, and where the cue does not tell the legs apart its crossings stay on steps, cut as without a view, with a warning, and a foot cue that does not move leaves the crossings on steps wherever it is read, where a pass can hide too. Every report whose clip stands still gains `stands` and `run_limit`, reports where cycle reading is asked gain `cycles`, and reports where a pass can hide gain `cycles.cue` with no view as well.+**Upgrading from 3.5.0: `video-set` now cuts searched walk and run loops with `--anchor motion-auto` and their view by default, and `video-loop --anchor motion-auto` recognises crossings that mark cycles where feet hide or step apart instead of cutting two cycles.** Every walk or run item whose loop is searched is now cut with `motion-auto` and its view, producing a different cut and different bytes; `--anchor none` gives the old cut, its pictures and reports byte for byte apart from the engine hash (`producer.implementation_sha256`). Idle, attack, once-hold, lifetime, and once-return items are cut as before. In `video-loop --anchor motion-auto` without `--view`, a walk whose feet are seen together over half the interval at a pass (`crossings.HIDE_SHARE`, 0.5) and whose picture repeats each interval is now counted on cycles only where the body's top line rises and falls twice an interval: where the parent engine cut two cycles, the loop is now one cycle with new bytes; where the parent engine kept the search's cut with no `steps`, the cut is the same and the strip and report now record `steps: 2`; where nothing witnesses, its crossings stay on steps with a warning (`cycle-unwitnessed`). A walk whose crossings mark steps (brief passes, or from the side) is cut to the same bytes. With `--view` (or through `video-set`), a front, back, or diagonal walk is evaluated even with brief passes: such a walk is counted on cycles with the same witness, the view's foot cue only refusing where it turns over one interval on; where nothing witnesses, its crossings stay on steps with a warning, and `video-set` leaves a `cycle-unwitnessed` loop out of the cycle alignment. Every report whose clip stands still gains `stands` and `run_limit`, and reports where cycle reading is asked gain `cycles`, with `bob` where the picture passes and `cue` only where a view is given.-- **New: crossing cycle detection (`local_cycle.read_cycles`, `local_cycle.cue_word`, `crossings.HIDE_SHARE`, `crossings.Reading.hides`, `CYCLE_SLACK`, `CUE_FLOOR`, `CUE_SWAPPED`).** In gap mode on a readable reading, when feet can hide behind one another (`reading.overlap` over `crossings.HIDE_SHARE`, 0.5) or when the view is given and is not `side`, crossing intervals are checked to see if they mark full cycles rather than single steps. `repeat_at(distances, span)` reads the mean distance of frames to those lagged by `span` over the clip's mean step from frame to frame. Comparing distances at half, one, and two intervals, crossings mark cycles when `one < half` and `one <= two + CYCLE_SLACK` (0.5), judged with the directional foot cue (`legs.shade_cue` from the side or diagonal, `legs.depth_cue` from the front or back); with no view, where a pass can hide, the feet's shade is read only for whether it moves (`lead` false): a cue whose range over the clip is under `CUE_FLOOR` (0.5) of the step it is drawn in (`legs.TONE`, 1/255, or a pixel row of median body height) does not move and says `"alike"`, one that moves says nothing (null); `"steps"` and `"cycles"` are said only by the view's cue, `"steps"` where it turns over one interval on (`crossings.correlation_on` at or below `CUE_SWAPPED`, −0.2) and `"cycles"` where it turns over half an interval on (−0.2 or under) and not one interval on; a hidden pass marks cycles unless the cue says `"steps"` or `"alike"`; the view alone needs the cue to say `"cycles"`; otherwise crossings stay on steps, with a warning. When cycles are marked, `Reading.mark_cycles` sets `per` to 2 and halves `step` and `step_range`: a cut one interval long is two steps, and the search's cut (`--anchor motion-auto`) taken on it writes `steps: {count: 2, by: crossings}`. A fixed cut (`--cycle fixed`, `fixed_count`) and the loop as it plays round (`ring_steps`) read the same; a fixed cut one interval long is counted two steps and not refused, and still writes no `steps`.+- **New: crossing cycle detection (`local_cycle.read_cycles`, `local_cycle.bob_word`, `local_cycle.cue_word`, `crossings.HIDE_SHARE`, `crossings.Reading.hides`, `CYCLE_SLACK`, `CUE_FLOOR`, `CUE_SWAPPED`, `BOB_TWICE`, `BOB_FLOOR`, `UNWITNESSED`).** In gap mode on a readable reading, when feet can hide behind one another (`reading.overlap` over `crossings.HIDE_SHARE`, 0.5) or when the view is given and is not `side`, crossing intervals are checked to see if they mark full cycles rather than single steps. `repeat_at(distances, span)` reads the mean distance of frames to those lagged by `span` over the clip's mean step from frame to frame. Comparing distances at half, one, and two intervals, crossings mark cycles when `one < half` and `one <= two + CYCLE_SLACK` (0.5), only where a witness that reads no leg says the interval holds two steps: the body's top line (`legs.strike_signals` `top`) rising and falling twice an interval. `local_cycle.bob_word(top, interval, height)` reads the line's range over the body's median height (`swing`); where that is under `BOB_FLOOR` (0.005) it does not rise and fall and witnesses nothing (`says` null), otherwise its correlation half an interval on (`crossings.correlation_on`) is read (`half`), saying `"cycles"` where `half` is `BOB_TWICE` (0.28) or more, null otherwise. The directional foot cue (`legs.shade_cue` from the side or diagonal, `legs.depth_cue` from the front or back) is read with a view given by `local_cycle.cue_word(cue, interval, step=None)` and can only refuse cycles: under `CUE_FLOOR` (0.5) of the step it is drawn in (`legs.TONE`, 1/255, or a pixel row of median body height) it says `"alike"`; where it turns over one interval on (`crossings.correlation_on` at or below `CUE_SWAPPED`, `-0.2`) it says `"steps"`, refusing cycles because the other leg leads there; otherwise null. With no view no cue is read at all. Where the view's cue says `"steps"`, the count stands (two steps); else where the bob says `"cycles"`, cycles are marked; otherwise crossings stay on steps with `unwitnessed` true (`local_cycle.UNWITNESSED`) and a warning (`cycle-unwitnessed`). When cycles are marked, `Reading.mark_cycles` sets `per` to 2 and halves `step` and `step_range`: a cut one interval long is two steps, and the search's cut (`--anchor motion-auto`) taken on it writes `steps: {count: 2, by: crossings}`. A fixed cut (`--cycle fixed`, `fixed_count`) and the loop as it plays round (`ring_steps`) read the same; a fixed cut one interval long is counted two steps and not refused, and still writes no `steps`.- **Removed: the same-picture rule (`local_cycle.same_picture`, `local_cycle.same_picture_count`, `local_cycle.SAME_PICTURE_MAX`, count code `same-picture`, report fields `step_count.search.same_picture` and `step_count.same_picture`).** It kept the search's cut, with no `steps`, where the count said one step; it never cut one cycle where the search had found two. `local_cycle.read_cycles` takes its place.- **New: walk start-stop retake reporting (`loop.stand_retake`, `crossings.Reading.stands`).** In gap mode, runs where the feet stay together longer than `run_limit` (√2 times the median whole pass run) are recorded in `Reading.stands`. Where a clip shows its steps, contains `stands`, and the cut kept does not count two steps (`verdict` is not `two`) with no two-step cut closing between the standing frames, `loop.stand_retake` emits a `retake` report (`reason: "start-stop"`, `remedy: "retake"`), keeping the cut as cut without refusal under `--unfixed refuse`. Where a part also pops, one `retake` names both (`loop.retakes`): the first reason's record, `reasons: ["part-pop", "start-stop"]`, and each reason's numbers under its own key (`part_pop`, `start_stop`).- **Changed: `video-set` defaults gait anchoring to `motion-auto` (`batch.anchor_for`).** Without an explicit `--anchor`, `video-set` cuts each walk and run item whose loop is searched (`cycle_for` returns `auto` or `periodic`) with `motion-auto`, and assigns `none` to idle, attack, once-hold, lifetime, and once-return items; explicit `--anchor` options are applied to every item as before. `video-set` passes each item's view to `video-loop`. Any item whose loop names a retake carries `loop.retake`, appears in the set's `warnings`, and appends ` (film again: <reasons>)` to `table.md`.-- **Changed: cycle alignment leaves out start-stop retake loops (`batch.align_gaits`, `video-set --align-cycles auto`).** Takes flagged with `start-stop` retakes loop no two steps and are excluded from gait cycle alignment, keeping their loops as cut while aligning the remaining directions. Excluded items are recorded under `left_out` (`{item: reasons}`) with a stderr warning and a set warning; if fewer than two directions remain, alignment is skipped (`applied: false`, `why: "fewer than two directions left to align"`).+- **Changed: cycle alignment leaves out start-stop retake and cycle-unwitnessed loops (`batch.align_gaits`, `video-set --align-cycles auto`).** Takes flagged with `start-stop` retakes loop no two steps, and loops whose crossings were left on steps unwitnessed (`cycle-unwitnessed`) may have two steps that are two cycles and would play at twice their speed if aligned as one cycle; both are excluded from gait cycle alignment, keeping their loops as cut while aligning the remaining directions. Excluded items are recorded under `left_out` (`{item: reasons}`, listing `["start-stop"]`, `["cycle-unwitnessed"]`, or both) with a stderr warning and a set warning; if fewer than two directions remain, alignment is skipped (`applied: false`, `why: "fewer than two directions left to align"`).- CLI: `video-loop --view front|back|side|front_diagonal|back_diagonal` (default none) sets the clip view for cycle detection and foot cue selection.-- Report fields: `cycle.step_count.cycles` (`{asked, interval, overlap, half, one, two, slack, cue: {range, floor, swapped, half, one, says, why}, cycles, why}`, the cue's `half` and `one` absent where `says` is `"alike"`, and with no view where a pass can hide and the picture repeats each interval `{range, floor, says, why}`); the loop's warnings (`jolt.warnings`); `step_count.stands` and `step_count.run_limit`; `loop.retake` (`{reason: "start-stop", reasons, start_stop: {stands, run_limit, crossings, cut, verdict, code, why}, remedy: "retake"}`); the set report's item `loop.retake` (`{reason, reasons, remedy}`) and its state's `cycle_align.<state>.left_out` (`{item: reasons}`).-- Python callers: new `local_cycle.read_cycles(reading, distances, view=None, cue=None, cue_step=None)`, `local_cycle.cue_word(cue, interval, step=None, lead=True)`, `local_cycle.CUE_FLOOR`, `legs.TONE`, `local_cycle.repeat_at(distances, span)`, `batch.anchor_for(state, cut, anchor)`, `loop.stand_retake(cycle)`, `loop.retakes(*records)`, `loop.STAND_REASON`; `crossings._alternation` is now public `crossings.correlation_on(values, span)`; `align._feet`, `align._depth_cue`, `align._shade_cue`, and `align.SHADE_BAND` are moved to `legs.feet_halves`, `legs.depth_cue`, `legs.shade_cue`, and `legs.SHADE_BAND` (`align` keeps `_depth_cue` and `_shade_cue` aliases); `crossings.Reading` gains `interval`, `per`, `cycles`, `hides`, and `mark_cycles(said)`.+- Report fields: `cycle.step_count.cycles` (`{asked, interval, overlap, half, one, two, slack, cue, bob, cycles, unwitnessed, why}`, where `cue` and `bob` are recorded only where the picture passes, `cue: {range, floor, swapped, one, says, why}` only with a view, `one` absent where `says` is `"alike"`, `bob: {swing, floor, twice, half, says, why}`, `half` absent under the floor and `why` absent where it says `"cycles"`, and `unwitnessed` true only where nothing witnessed); the loop's warnings (`jolt.warnings`); `step_count.stands` and `step_count.run_limit`; `loop.retake` (`{reason: "start-stop", reasons, start_stop: {stands, run_limit, crossings, cut, verdict, code, why}, remedy: "retake"}`); the set report's item `loop.retake` (`{reason, reasons, remedy}`) and item `loop["cycle-unwitnessed"]` (`true`), and its state's `cycle_align.<state>.left_out` (`{item: reasons}`).+- Python callers: new `local_cycle.read_cycles(reading, distances, view=None, cue=None, cue_step=None, signals=None)`, `local_cycle.bob_word(top, interval, height)`, `local_cycle.cue_word(cue, interval, step=None)`, `local_cycle.BOB_TWICE`, `local_cycle.BOB_FLOOR`, `local_cycle.UNWITNESSED`, `local_cycle.CUE_FLOOR`, `legs.TONE`, `local_cycle.repeat_at(distances, span)`, `batch.anchor_for(state, cut, anchor)`, `batch.left_out_why(reasons, stands=False)`, `loop.stand_retake(cycle)`, `loop.retakes(*records)`, `loop.STAND_REASON`; `crossings._alternation` is now public `crossings.correlation_on(values, span)`; `align._feet`, `align._depth_cue`, `align._shade_cue`, and `align.SHADE_BAND` are moved to `legs.feet_halves`, `legs.depth_cue`, `legs.shade_cue`, and `legs.SHADE_BAND` (`align` keeps `_depth_cue` and `_shade_cue` aliases); `crossings.Reading` gains `interval`, `per`, `cycles`, `hides`, and `mark_cycles(said)`.- **Tests**: `tests/video/test_walk_steps.py` covers these synthetic walker cases:- - a walker seen from behind whose far foot hides behind the near one (feet together over half the interval) across cycles of 20 frames on twos, 24 on threes, and 17.5 and 18.5 on ones is cut to one cycle within a frame, with `cycles` true and `steps: 2`;- - a side walker whose two steps are one silhouette (46-frame cycle, near and far legs one or four tones apart) is not asked with no view or `--view side`, keeping two steps at 46 frames;- - a front-diagonal walker stepping toward the camera with feet passing apart (feet together under half the interval, cycle 16 and 18), whose foot cue turns over half an interval on, cuts one cycle (16, 18) with `--view front_diagonal`, and cuts two cycles (32, 36) without a view;- - a 46-frame front-diagonal walker with legs four tones apart asked with `--view front_diagonal` sees one interval on as near as two on, but keeps two steps at 46 frames because the foot cue turns over one interval on;- - the same 46-frame walker with its legs drawn alike (its arms still four tones apart) asked with `--view` set to `front`, `front_diagonal`, `back` and `back_diagonal` sees one interval on as near as two on, but the foot cue says `"alike"` (it does not move, its range far under the floor), keeping two steps at 46 frames with `cycles` false and a warning that names the cut;- - the same 46-frame walker with its legs drawn alike and each leg twice as wide (10 px either side of its line instead of 5), so the feet are seen together over half the interval at each pass, where a pass could hide: asked with no view and with `--view` set to `side`, `front_diagonal` and `back`, one interval on (a step on) is the same picture, as near as two on, but the foot cue (the view's, or with no view the feet's shade) does not move (`says: "alike"`): two steps, 46 frames, `cycles` false, and a warning that names the cut;- - synthetic units meeting every 15 frames verify that repeating every 15 frames with 9 frames overlap marks cycles, repeating every 30 frames marks steps, brief meetings with no view or `side` are not asked, and on front diagonals a cue turning over every 15 frames (one interval on) keeps two steps of 15 (30 frames), a cue turning over every 7.5 frames (half an interval on) and holding one interval on marks cycles (15 frames kept as one cycle), a still cue (a sine of amplitude 1e-8, its range far under half a tone) and a cue flickering every 4 frames (turning over neither) leave crossings on steps (two steps of 15, with the warning), while where a pass can hide (feet together 9 frames at each meeting), a still cue, with the back diagonal view or with no view, leaves the crossings on steps (two steps of 15, 30 frames, with the warning); with no view a shade that moves, even one turning over one interval on, is not asked which leg leads and leaves the picture to mark cycles (15 frames kept as one cycle with `steps: 2`);+ - a walker seen from behind whose far foot hides behind the near one (feet together over half the interval) across cycles of 20 frames on twos, 24 on threes, and 17.5 and 18.5 on ones: its top line rises and falls twice an interval, cutting one cycle within a frame with `cycles` true, `steps: 2`, and no cue read with no view; the same walker with its far leg drawn as the near one (legs alike), with no view and with `--view back_diagonal`, is still cut to one cycle because the view's cue says `"alike"` (which no longer refuses) and the bob witnesses;+ - a front-diagonal walker whose near foot steps out toward the camera and passes the far one apart (feet together under half the interval, cycle 16 and 18): with `--view front_diagonal` cut to one cycle because its foot cue moves over the floor and does not turn over one interval on (`says` null) and its top line rises and falls twice an interval; without a view it is not asked and is cut to two cycles (32, 36 frames);+ - the walker seen from behind (17.5 on ones; no view and `--view back_diagonal`) and the front-diagonal walker (16, `--view front_diagonal`) with their bodies held still: the top line does not rise and fall (`swing` under `BOB_FLOOR`), keeping two intervals (two cycles) with `cycles` false, `unwitnessed` true, and the warning naming the cut;+ - a side walker whose two steps are one silhouette (46-frame cycle, near and far a tone or four apart), passes brief: not asked with no view or `--view side`, keeping two steps at 46 frames;+ - the same 46-frame walker filmed as a front diagonal, its far leg four tones off the near one, `--view front_diagonal`: the picture passes, but the foot cue turns over one interval on (`says: "steps"`), keeping two steps at 46 frames with no warning;+ - the same 46-frame walker with its legs drawn alike (arms still four tones apart) asked with `--view` set to `front`, `front_diagonal`, `back`, and `back_diagonal`: the picture passes, the cue says `"alike"`, and its top line rises and falls once an interval (a step), so its `half` correlation is negative, leaving nothing to witness and keeping two steps at 46 frames with `unwitnessed` true and the warning;+ - the same 46-frame walker with its legs drawn alike and twice as wide (10 px either side of its line instead of 5), so the feet are seen together over half the interval and a pass could hide: asked with no view and with `--view` set to `side`, `front_diagonal`, and `back`, keeping two steps at 46 frames with `unwitnessed` true and the warning (with a view the cue says `"alike"`, and with no view no cue is read);+ - the wide alike walker lit by a light fixed on the screen, lighter to the right (up to 12 tones across the feet), with no view and with `--view` set to `side`, `front_diagonal`, and `back_diagonal`: the shade of the feet moves with how far apart they are drawn and turns over half an interval on, but nothing witnesses, keeping two steps at 46 frames with the warning;+ - the alike walker (legs 5 px) with the leg swinging forward lifted 6 px at its pass and a light fixed on the screen varying top to bottom (12 tones), asked with `--view` set to `front`, `front_diagonal`, `back`, and `back_diagonal`: the cue moves with the swing whichever leg swings and turns over half an interval on, but nothing witnesses, keeping two steps at 46 frames with the warning;+ - the wide walker with its far leg four tones off the near one (where a pass can hide): with `--view side` or `front_diagonal` the cue turns over one interval on (`"steps"`), keeping two steps at 46 frames with no warning, while with no view no cue is read and nothing witnesses, keeping 46 frames with `unwitnessed` true and the warning;+ - synthetic units meeting every 15 frames verify that where a pass can hide (feet together 9 frames at each meeting), a top line rising and falling every 7.5 frames (twice an interval) marks cycles (15 frames kept as one cycle, `steps: 2`), while rising and falling every 15 frames (once an interval) or held still keeps two steps of 15 (30 frames) with `unwitnessed` true and the warning; brief meetings with no view or `side` are not asked; on front diagonals with brief meetings, a cue turning over every 15 frames (one interval on) keeps two steps of 15 (30 frames) whatever the body does, and a cue turning over half an interval on and holding one interval on is no witness (30 frames with the warning when the top line is once an interval, 15 frames and one cycle when twice an interval); a still cue (range far under half a tone) or one flickering every 4 frames refuses nothing, letting the body decide (twice an interval: one cycle of 15; held still: 30 with the warning) on front diagonals with brief meetings, back diagonals where a pass can hide, and with no view where a pass can hide; and `bob_word` on an interval of 15 frames for a body 100 rows tall says `"cycles"` with 3 rows either way every 7.5 frames, says null every 15 or 30 frames, and says null under the floor at 0.2 rows either way without reading its correlation;- synthetic start-stop clips with feet together for 15 frames at the head and 14 at the tail alongside passes of 8 and 3 frames flag retakes when the cut is uncertain, omit retakes when counted as two steps, and report no `stands` when feet only pass.- **Tests**: `tests/video/test_gait_guard_anchor_wide.py` and `tests/video/test_cycle_align.py` cover batch anchoring and cycle alignment:- `batch.anchor_for` assigns `motion-auto` to walk and run loops while assigning `none` to cheer, walk with `--anchor none`, and pinned idle items, propagating loop retakes to item records, warnings, and markdown tables;- - `batch.align_gaits` excludes loops with `start-stop` retakes, aligns remaining directions, records omissions under `left_out`, and leaves the state unaligned when fewer than two directions remain.+ - `batch.align_gaits` excludes loops with a `start-stop` retake, a loop with `cycle-unwitnessed`, or a loop with both, names its reasons under `left_out` (`["start-stop"]`, `["cycle-unwitnessed"]`, `["start-stop", "cycle-unwitnessed"]`) and in the stderr warning, aligns remaining directions, and leaves the state unaligned when fewer than two directions remain.## v3.5.0 - Widened square canvas framing for side walk and run stride and trailing parts, measured background matte cutout for flat backgrounds of any colour, and failure when a cutout removes nothingdiff --git a/docs/loop-repair.md b/docs/loop-repair.mdindex 6d174c3..5b5c64e 100644--- a/docs/loop-repair.md+++ b/docs/loop-repair.md@@ -1269,7 +1269,7 @@ crossings, joined at the wrap where the walk itself goes on, is one cycle (`cros| `step_range` | the clip's own step (the median between crossings) and the range a step must lie in, a factor of √2 either way || `readable`, `why`, `alternation` | whether the clip shows its steps: three crossings or more, and in sign mode a lean that turns over a step on (correlation one step on at most **−0.7**, `crossings.ALTERNATION_MAX`) || `cut`, `search` | the cut taken and the pixel search's own cut (or why it found none), each with its `verdict`, `code`, `k` (steps covered), `phase` and `ring` |-| `cycles` | whether crossings mark cycles: `asked`, `interval`, `overlap`, `half`, `one`, `two`, `slack`, `cue` (`range`, `floor`, `swapped`, `half`, `one`, `says`, `why`; `says` is `"steps"`, `"cycles"`, `"alike"` or null; with no view, where a pass can hide, `cue` has only `range`, `floor`, `says`, `why`), `cycles` (`true` or `false`), and `why`; absent where not asked |+| `cycles` | whether crossings mark cycles: `asked`, `interval`, `overlap`, `half`, `one`, `two`, `slack`, `cue` (`range`, `floor`, `swapped`, `one`, `says`, `why`; only with a view; `one` absent where `"alike"`; `says` is `"steps"`, `"alike"` or null), `bob` (`swing`, `floor`, `twice`, `half`, `says`, `why`; `says` is `"cycles"` or null), `cycles` (`true` or `false`), `unwitnessed` (`true` only where nothing witnessed), and `why`; absent where not asked || `stands`, `run_limit` | gap mode, the runs of the feet together longer than any pass (over `run_limit`, √2 times the median run the clip shows whole: whole, or cut by the first or last frame), recorded as pairs of frames; only where there is one || `chosen_by` | `search` (kept), `two steps` (chosen on the count), and the search again where the count refutes its cut (`searched_again`) || `declined` | the best two-step cut, where none closed and the search's cut stood: its `cut`, `phase`, whether it passed the gates (`gated`) and its `seam` |@@ -1294,10 +1294,10 @@ behind on a diagonal), or a foot steps toward or away from the camera and passesdiagonal, a front view). There the feet meet once a cycle, the engine called a cycle one step, and twosteps were two cycles: a loop twice as long as the walk's cycle, which then plays at half the walk'sspeed beside the rest of a set. Before any cut is judged,-`local_cycle.read_cycles(reading, distances, view=None, cue=None, cue_step=None)` asks whether the-crossings mark cycles instead of steps. It is asked only in gap mode, on a readable reading, and only-where a pass can hide (`reading.overlap` over `crossings.HIDE_SHARE`, 0.5: the feet seen together over-half the interval at a pass) or where the clip's view is given+`local_cycle.read_cycles(reading, distances, view=None, cue=None, cue_step=None, signals=None)` asks+whether the crossings mark cycles instead of steps. It is asked only in gap mode, on a readable reading,+and only where a pass can hide (`reading.overlap` over `crossings.HIDE_SHARE`, 0.5: the feet seen+together over half the interval at a pass) or where the clip's view is given(`--view front|back|side|front_diagonal|back_diagonal`, default none) and is not `side`. From the sidethe legs a step on are one silhouette, as near as a cycle on, and the picture cannot tell; so a side clipwith brief passes, or a clip with no view and brief passes, is not asked (the count stands exactly as@@ -1305,78 +1305,93 @@ before). `repeat_at(distances, span)` measures how far the clip lies from itselfmean distance of every frame to the one a lag on, over the clip's mean step from one frame to the next,the nearer of the two whole lags about `span` (none where the clip holds under half a lag of frames pastit). It is read at half the crossing interval (`half`), one interval (`one`) and two intervals (`two`).-The crossings mark cycles where `one < half` (one interval on is nearer than the pose a half interval on)-and `one <= two + CYCLE_SLACK` (`CYCLE_SLACK` = 0.5 of the mean step: one interval on is as near as two-on, so the same leg leads one interval on). Then the view's foot cue is asked-(`local_cycle.cue_word(cue, interval, step=None, lead=True)`): `legs.shade_cue` (the near foot's shade-against the far one's) from the side or a diagonal, `legs.depth_cue` (the picture's right foot drawn-lower than its left) from the front or back, per frame. With no view given, where a pass can hide-(`reading.hides`), `video-loop` reads the shade of the feet's two halves (`legs.shade_cue`, in steps of-`legs.TONE`) and passes it to `local_cycle.read_cycles` as the cue, read only for whether it moves-(`lead` false). A cue whose range over the clip (largest value minus smallest) is under `CUE_FLOOR` (0.5)-of the step it is drawn in does not move: legs drawn alike to the cue leave it still, and what is left of-it is floating point rounding, which repeats with the legs and can correlate fully one interval on; it-says `"alike"`, its correlations are not read (`half` and `one` absent), and `why` gives its range and-the step. The step a cue is drawn in is `legs.TONE` (1/255, one 8-bit level of luma) for the shade cue,-or one pixel row of the body's median height (1 over the median body height in pixels) for the depth cue.-Otherwise, with `lead` true (the view's foot cue), its correlation half an interval on (`half`) and one-interval on (`one`) is read with `crossings.correlation_on` (trend removed). The cue says `"steps"` where-it turns over one interval on (correlation at `CUE_SWAPPED`, −0.2, or under: the other leg leads there,-so the interval is a step); `"cycles"` where it turns over half an interval on (−0.2 or under) and does-not turn over one interval on (the other leg leads a step on, so the interval is two steps); and null-where it does neither (the cue does not tell the legs apart). With `lead` false (no view), only whether-the cue moves is read: its correlations are not read, because the two halves are the picture's halves,-which are the two legs only from the side or a diagonal; a cue that moves says null, `why` "it moves;-with no view, which leg leads is not read", and the record has only `range`, `floor`, `says` and `why`-(no `swapped`, `half` or `one`). Where a pass can hide (`reading.overlap` over `crossings.HIDE_SHARE`,-0.5), the picture marks cycles unless the cue says `"steps"` (the view's cue) or `"alike"` (the view's-cue, or with no view the feet's shade). Legs drawn alike to the cue are the same picture a step on as a-cycle on, so the picture cannot tell; the crossings stay on steps, as from the side, with the warning. A-cue that moves and says null leaves the picture's word. Where only the view asks (the view is given and-is not `side`, and passes are brief), the picture alone marks nothing, because legs drawn alike are the-same picture a step on as a cycle on: the crossings mark cycles only where the cue says `"cycles"`; where-it says `"steps"`, the count stands (two steps); where it says `"alike"` or null, the crossings stay on-steps, as from the side, the cut taken without a view, with the warning. Where the crossings stay on-steps this way, `cycles.why` says the view's foot cue does not tell the legs apart (with the cue's own-`why` in parentheses): a step on draws as a cycle on, as from the side, and the crossings mark steps-(with no view, "the feet's shade" in place of "the view's foot cue"); and the loop's warnings-(`jolt.warnings`, from `local_cycle.step_verdict`) gain a line: the clip one interval on is the same-picture, as a walk whose feet meet once a cycle draws it, but its foot cue does not tell its legs apart,-so its crossings are counted as steps, as from the side, and where its feet do meet once a cycle, each-step counted in the cut is a cycle. It is given wherever the crossings stay on steps because the cue says-`"alike"` or null, where a pass can hide too. Where they mark cycles the reading holds two steps an-interval (`Reading.mark_cycles`: `per` 2, `step` half the interval, `step_range` halved): a cut one-interval long is two steps (one cycle) and is taken as such (`steps: {count: 2, by: crossings}` written).-Recorded in `cycle.step_count.cycles`:-`{asked, interval, overlap, half, one, two, slack, cue: {range, floor, swapped, half, one, says, why}, cycles: true|false, why}`-(the cue's `half` and `one` absent where `says` is `"alike"`), and with no view where a pass can hide and-the picture repeats each interval `cue: {range, floor, says, why}`; `says` is `"steps"`, `"cycles"`,-`"alike"` or null; absent where not asked. The same reading is used for the search's cut-(`--anchor motion-auto`), a fixed cut (`--cycle fixed`, `fixed_count`), and the loop as it plays round-(`ring_steps`, told the clip's `cycles` since a loop alone is too short to read two intervals on).-`video-set` passes each item's view. On the synthetic walkers of `tests/video/test_walk_steps.py`, a-walker seen from behind whose far foot hides behind the near one (feet seen together over half the-interval) has a cycle of 20 frames drawn on twos, 24 on threes, and 17.5 and 18.5 frames on ones (a cycle-not a whole number of frames): cut one cycle (within a frame of it), `cycles` true, `steps` 2. A side-walker whose two steps are one silhouette (46-frame cycle, near and far a tone or four apart) is not-asked with no view or with `--view side`, and is cut two steps (46 frames) as before. A front-diagonal-walker whose near foot steps out toward the camera and passes the far one apart (feet together under half-the interval), cycle 16 and 18 frames: its foot cue moves over the floor and turns over half an interval-on and not one interval on (`says: "cycles"`); with `--view front_diagonal` cut one cycle (16, 18-frames); without a view it is not asked and is cut as before (32, 36 frames: two cycles, as the engine-cannot tell without the view). The same 46-frame walker filmed as a front diagonal, its far leg four-tones off the near one, is asked with `--view front_diagonal`: one interval on is as near as two on, but-the foot cue turns over one interval on (`says: "steps"`): two steps (46 frames), the count stands. The-same 46-frame walker with its legs drawn alike (its arms still four tones apart), asked with `--view` set-to `front`, `front_diagonal`, `back` and `back_diagonal`: one interval on (a step on) is the same-picture, as near as two on, and the foot cue does not move (its range far under the floor,-`says: "alike"`). The crossings stay on steps: two steps, 46 frames, `cycles` false, and a warning that-names the cut. The same 46-frame walker with its legs drawn alike and each leg twice as wide (10 px-either side of its line instead of 5), so the feet are seen together over half the interval at each pass,-where a pass could hide: asked with no view and with `--view` set to `side`, `front_diagonal` and `back`.-One interval on (a step on) is the same picture, as near as two on, but the foot cue (the view's, or with-no view the feet's shade) does not move (`says: "alike"`): two steps, 46 frames, `cycles` false, and a-warning that names the cut.+The picture passes where `one < half` (one interval on is nearer than the pose a half interval on) and+`one <= two + CYCLE_SLACK` (`CYCLE_SLACK` = 0.5 of the mean step: one interval on is as near as two on).+But the picture is the same a step on as a cycle on wherever the legs are drawn alike, so the picture+cannot witness that an interval holds two steps. Neither can a foot cue's turn half an interval on: a+light fixed on the screen shades the feet by how far apart they are drawn, whichever leg leads, so a+walk whose crossings are its steps, its legs drawn alike, turns its cue over half an interval on just as+a walk whose other leg leads a step on does; and a cue that merely moves (the no-view shade) says nothing+about which leg leads. Read that way, a walk whose crossings are its steps was cut one step long and+counted two steps: a half-cycle loop, with no warning. The crossings mark cycles only where a witness+that reads no leg says the interval holds two steps: the body's top line (`legs.strike_signals` `top`,+one row per frame) rising and falling twice an interval. The body rises and falls once a step whichever+leg leads, so two rises an interval are two steps an interval. `local_cycle.bob_word(top, interval, height)`+reads it: the line's range over the clip over the body's median height (`swing`); where that is under+`BOB_FLOOR` (`0.005`, 0.5 % of the body's median height) the line does not rise and fall and witnesses+nothing (`says` null, `why` says its range is under the floor: it does not rise and fall; `half` not+read); otherwise its correlation half an interval on (`crossings.correlation_on`, trend removed) is read+(`half`), and the bob says `"cycles"` where `half` is `BOB_TWICE` (`0.28`) or more, null otherwise (`why`:+its top line does not rise and fall twice an interval). The view's foot cue can only refuse cycles+(`local_cycle.cue_word(cue, interval, step=None)`): `legs.shade_cue` from the side or a diagonal,+`legs.depth_cue` from the front or back, per frame. A cue whose range over the clip is under `CUE_FLOOR`+(0.5) of the step it is drawn in (`legs.TONE` of luma, or one pixel row of the body's median height) does+not move: it says `"alike"`, its correlation is not read (`one` absent), and `why` gives its range and+the step. Otherwise its correlation one interval on (`one`) is read with `crossings.correlation_on`+(trend removed): the cue says `"steps"` where it turns over one interval on (correlation at+`CUE_SWAPPED`, `-0.2`, or under: the other leg leads there, so the interval is a step); and null otherwise+(`why`: it does not turn over one interval on). It no longer reads its correlation half an interval on+and never says `"cycles"`. With no view given, no cue is read at all: the shade of the feet's two halves+is no longer read. Where the picture passes, the view's cue is checked first: where it says `"steps"`,+`cycles` is false, the count stands (two steps), `why` says the view's foot cue turns over there: the+other leg leads, a step, and no warning is given. Else where the bob says `"cycles"`, `cycles` is true,+and `why` says the body's top line rises and falls twice an interval (its `half`, at least `BOB_TWICE`):+two steps an interval, the feet meet once a cycle. Else `cycles` is false and `unwitnessed` is true: the+crossings stay on steps, as from the side; `why` says nothing that reads no leg witnesses two steps an+interval (the bob's own `why` in parentheses, or "no top line read"): a step on draws as a cycle on, as+from the side, and the crossings mark steps; and the loop's warnings (`jolt.warnings`, from+`local_cycle.step_verdict`) gain this line (`s/L` being the cut): "the clip one interval on is the same+picture, as a walk whose feet meet once a cycle draws it, but nothing that reads no leg witnesses it+(<the bob's why>): its crossings are counted as steps, as from the side", where its feet do meet once a+cycle, each step counted in the cut `s/L` is a cycle (`cycle-unwitnessed`). Where the picture fails,+`cycles` is false and `why` says the crossings mark steps, and neither `cue` nor `bob` is recorded.+Where they mark cycles the reading holds two steps an interval (`Reading.mark_cycles`: `per` 2, `step`+half the interval, `step_range` halved): a cut one interval long is two steps (one cycle) and is taken+as such (`steps: {count: 2, by: crossings}` written). Recorded in `cycle.step_count.cycles`:+`{asked, interval, overlap, half, one, two, slack, cue, bob, cycles, unwitnessed, why}`;+`cue: {range, floor, swapped, one, says, why}` (only with a view; `one` absent where `says` is `"alike"`;+`says` is `"steps"`, `"alike"` or null); `bob: {swing, floor, twice, half, says, why}` (`half` absent+under `floor`; `why` absent where it says `"cycles"`; `says` is `"cycles"` or null); `unwitnessed` true+only where nothing witnessed; absent where not asked. `cue` and `bob` are recorded only where the picture+passes. The same reading is used for the search's cut (`--anchor motion-auto`), a fixed cut+(`--cycle fixed`, `fixed_count`), and the loop as it plays round (`ring_steps`, told the clip's `cycles`+since a loop alone is too short to read two intervals on). `video-set` passes each item's view. On the+synthetic walkers of `tests/video/test_walk_steps.py` (bodies rising and falling 3 px either way once a+step unless held still), a walker seen from behind whose far foot hides behind the near one (feet+together over half the interval) has a cycle of 20 frames drawn on twos, 24 on threes, and 17.5 and 18.5+frames on ones: its top line rises and falls twice an interval; cut one cycle (within a frame of it),+`cycles` true, `steps` 2; with no view no cue is read. The same walker with its far leg drawn as the near+one (legs alike), with no view and with `--view back_diagonal`, is still cut one cycle (the view's cue says+`"alike"`, which no longer refuses, and the bob witnesses). A front-diagonal walker whose near foot steps+out toward the camera and passes the far one apart (feet together under half the interval), cycle 16 and 18+frames: with `--view front_diagonal` cut one cycle (16, 18 frames); its foot cue moves over the floor and+does not turn over one interval on (`says` null), and its top line rises and falls twice an interval;+without a view it is not asked and is cut as before (32, 36 frames: two cycles). The walker seen from+behind (17.5 on ones; no view and `--view back_diagonal`) and the front-diagonal walker (16,+`--view front_diagonal`) with their bodies held still have their top line not rising and falling (`swing`+under `BOB_FLOOR`): two intervals (two cycles), `cycles` false, `unwitnessed` true, and the warning naming+the cut. A side walker whose two steps are one silhouette (46-frame cycle, near and far a tone or four+apart), passes brief, is not asked with no view or with `--view side`, and is cut two steps (46 frames) as+before. The same 46-frame walker filmed as a front diagonal, its far leg four tones off the near one, is+asked with `--view front_diagonal`: the picture passes, but the foot cue turns over one interval on+(`says: "steps"`): two steps, 46 frames, no warning. The same 46-frame walker with its legs drawn alike+(arms still four tones apart), asked with `--view` set to `front`, `front_diagonal`, `back` and+`back_diagonal`: the picture passes, the cue says `"alike"`, and its top line rises and falls once an+interval (a step), so its `half` correlation is negative: nothing witnesses, two steps, 46 frames,+`unwitnessed`, and the warning. The same with its legs drawn alike and each leg twice as wide (10 px+either side of its line instead of 5), so the feet are seen together over half the interval at each pass+and a pass could hide: asked with no view and with `--view` set to `side`, `front_diagonal` and `back`: two+steps, 46 frames, `unwitnessed`, warning; with a view the cue says `"alike"`, with no view no cue is read.+The wide alike walker lit by a light fixed on the screen, lighter to the right (up to 12 tones across the+feet), asked with no view and with `--view` set to `side`, `front_diagonal` and `back_diagonal`: the shade+of the feet moves with how far apart they are drawn and turns over half an interval on; nothing witnesses:+two steps, 46 frames, warning. The alike walker (legs 5 px) with the leg swinging forward lifted 6 px at its+pass and a light fixed on the screen varying top to bottom (12 tones), asked with `--view` set to `front`,+`front_diagonal`, `back` and `back_diagonal`: the cue moves with the swing whichever leg swings and turns+over half an interval on; nothing witnesses: 46 frames, warning. The wide walker with its far leg four tones+off the near one (a pass can hide): with `--view side` or `front_diagonal` the cue turns over one interval+on (`"steps"`): two steps, 46 frames, no warning; with no view no cue is read and nothing witnesses: 46+frames, `unwitnessed`, warning.**Choosing the cut.**@@ -1440,24 +1455,19 @@ the feet together inside the clip as long as a pass, and a wobble that reaches tstep's beat read as steps; a narrow step that opens the feet only just past the reading's threshold readsat that threshold. Where a pass is hidden behind the other foot, or where the view is given and is not`side`, the cycles reading (`local_cycle.read_cycles`) sees whether the crossings mark cycles: where the-clip repeats one interval on as near as two on, a pass that can hide marks cycles unless the cue says-`"steps"` or `"alike"`, and where only the view asks, the crossings mark cycles only where the cue says-`"cycles"`; where they mark cycles, the reading cuts one cycle as two steps. What it still cannot tell: a-side walk with brief passes whose two steps are one silhouette is not asked, because from the side the-legs a step on are one silhouette, as near as a cycle on, and the picture cannot tell; a clip with no-view and brief passes is not asked, so a front diagonal whose near foot steps out apart is then cut two-cycles, so give `--view`; a walk filmed from the front, the back or a diagonal, with brief passes, whose-legs are drawn alike to its view's cue (or whose cue turns over neither a step on nor an interval on) has-its crossings left on steps: where its feet do meet once a cycle, it is cut two cycles long, with the-warning; and a cue that moves with how the feet meet rather than with which leg leads (for example both-feet drawn lighter as they part) turns over half an interval on just as swapped legs do, and can still-read a step as a cycle; so can a cue that flickers on a beat of its own and turns over half an interval-on by chance. With no view the feet's shade is read only for whether it moves, so where a pass can hide,-a walk whose legs are drawn a few tones apart (its shade moves) and whose two steps look alike in the-picture can still be read as cycles from the picture: give `--view`. And a walk whose far foot does pass-hidden while its legs are drawn alike to its cue (the view's, or with no view the feet's shade) has its-crossings left on steps: where its feet do meet once a cycle, it is cut two cycles long, with the-warning. Four-legged gaits are read as one foot band (`legs.strike_signals`), as before.+clip repeats one interval on as near as two on, the crossings mark cycles only where the body's top line+rises and falls twice an interval unless the view's foot cue says `"steps"`; where they mark cycles, the+reading cuts one cycle as two steps. What it still cannot tell: a side walk with brief passes whose two+steps are one silhouette is not asked, because from the side the legs a step on are one silhouette, as near+as a cycle on, and the picture cannot tell; a clip with no view and brief passes is not asked, so a front+diagonal whose near foot steps out apart is then cut two cycles, so give `--view`; a walk whose feet do+meet once a cycle but whose body's top line does not rise and fall twice an interval (a body held still, or+a top line that a part held over the head moves on a beat of its own) has its crossings left on steps: cut+two cycles long, with the warning, and `video-set` leaves it out of the cycle alignment (`video-cycle-align`+run on its own reads such a loop's `steps: 2` as one cycle; through `video-set` it is left out); and a walk+whose crossings are its steps, whose legs are drawn alike so its picture repeats a step on, and whose top+line rises and falls twice a step (a part over the head on a beat twice the step's) would still be read as+cycles. Four-legged gaits are read as one foot band (`legs.strike_signals`), as before.### The step gate: every step between drawings, and a fixed cut's countdiff --git a/docs/video-pipeline.md b/docs/video-pipeline.mdindex 25b8ee5..f06504a 100644--- a/docs/video-pipeline.md+++ b/docs/video-pipeline.md@@ -210,8 +210,10 @@ stops the set before anything is rewritten instead (both are explained in[loop repair](loop-repair.md) section 4).`video-set`'s own alignment (`batch.align_gaits`) leaves out a loop named a take to film again for-`start-stop`: its loop is kept as cut, the rest are aligned without it, and the state's record names-it under `left_out`.+`start-stop` or one whose crossings were left on steps unwitnessed (`cycle-unwitnessed`: its two+steps may be two cycles, and aligned as one cycle it would play at twice its speed): its loop is kept+as cut, the rest are aligned without it, and the state's record names it under `left_out` with its+reasons.`video-prompt --json` also gives the duration (the state's own, as `video-set`), whether the clipends on the canvas (`last_frame`), the loop cut (`cycle`) and the canvas, clip, frames and loopdiff --git a/sprite_gen/video/batch.py b/sprite_gen/video/batch.pyindex dba19dc..da2cf76 100644--- a/sprite_gen/video/batch.py+++ b/sprite_gen/video/batch.py@@ -37,6 +37,7 @@ from sprite_gen.video import facing as facing_modfrom sprite_gen.video import canvas as canvas_modfrom sprite_gen.video import frames as frames_modfrom sprite_gen.video import loop as loop_mod+from sprite_gen.video import local_cyclefrom sprite_gen.video import align as align_modfrom sprite_gen.video import body_plan as body_modfrom sprite_gen.video.body_plan import Body@@ -882,6 +883,9 @@ def run_item(if "steps" in lp["cycle"]:# the cut's steps are known: its frame count is two steps — one cycle — not twice its siblings' oneresult["loop"]["steps"] = lp["cycle"]["steps"]["count"]+ if ((lp["cycle"].get("step_count") or {}).get("cycles") or {}).get("unwitnessed"):+ # its crossings may mark cycles, and nothing witnesses whether: its two steps may be two cycles+ result["loop"][local_cycle.UNWITNESSED] = Trueif (lp["cycle"].get("step_screen") or {}).get("suspect"):# the cut may be one step of a cycle twice as long (recorded, not cut again)result["loop"]["step_screen"] = {k: lp["cycle"]["step_screen"][k] for k in ("lag", "ratio", "depth", "coverage")}@@ -964,6 +968,17 @@ def _align_view(r: dict[str, Any]) -> str | None:return r["direction"] + (f"@{r['turned']}" if r["direction"] in handed_mod.LATERAL_VIEWS else "")+def left_out_why(reasons: list[str], *, stands: bool = False) -> str:+ """Why `align_gaits` left a loop out of its state's alignment (`reasons`, as `left_out` keeps them), in words: a take+ to film again (its retake reasons, `start-stop` among them; `stands` says why the walk is filmed again), and a loop+ whose crossings may mark cycles with nothing to witness whether (`cycle-unwitnessed`)."""+ retake = [r for r in reasons if r != local_cycle.UNWITNESSED]+ stood = ": the walk starts or stops in it" if stands and loop_mod.STAND_REASON in retake else ""+ return " and ".join([*([f"a take to film again ({', '.join(retake)}){stood}"] if retake else []),+ *([f"its crossings may mark cycles and nothing witnesses whether ({local_cycle.UNWITNESSED}): its two "+ "steps may be two cycles"] if local_cycle.UNWITNESSED in reasons else [])])++def align_gaits(results: list[dict[str, Any]], root: Path, mode: str, *, interpolate: Any = None, between: str = align_mod.DEFAULT_BETWEEN,feet: dict[str, str] | None = None) -> dict[str, Any]:"""One cycle length per gait state across the set's directions (`video-cycle-align`,@@ -974,8 +989,11 @@ def align_gaits(results: list[dict[str, Any]], root: Path, mode: str, *, interpoRIFE is installed (`rife-not-installed`), or a loop may hold two or three cycles and nobody hascounted them (`cycle-suspects`, the loops under `suspects`; `video-cycle-align --cycles`).A loop whose take is to be filmed again because the walk starts or stops in it (`retake` reason- `start-stop`, loop.stand_retake) loops no two steps and has no cycle to match: it is left out, its- loop kept as cut, the rest aligned without it, and its state names it under `left_out`.+ `start-stop`, loop.stand_retake) loops no two steps and has no cycle to match, and a loop whose clip's+ crossings may mark cycles with nothing to witness whether (`cycle-unwitnessed`,+ local_cycle.read_cycles) may loop two cycles where it counts two steps: each is left out, its loop+ kept as cut, the rest aligned without it, and its state names it under `left_out`, with its reasons —+ no loop is played at twice its speed, and no count of its cycles is asked for.`feet` maps an item to the own foot that lands on its loop's first strike (`--align-foot`,`video-cycle-align --foot`), handed to its state's alignment. A state that names loops whose foot@@ -991,8 +1009,10 @@ def align_gaits(results: list[dict[str, Any]], root: Path, mode: str, *, interpofor r in results:if r.get("ok") and loop_mod.profile_for(r["state"]).gait:reasons = (r["loop"].get("retake") or {}).get("reasons") or []- if loop_mod.STAND_REASON in reasons:- left_out.setdefault(r["state"], {})[r["item"]] = reasons+ why = [*(reasons if loop_mod.STAND_REASON in reasons else []),+ *([local_cycle.UNWITNESSED] if r["loop"].get(local_cycle.UNWITNESSED) else [])]+ if why:+ left_out.setdefault(r["state"], {})[r["item"]] = whycontinueby_state.setdefault(r["state"], []).append(r)for state, rows in by_state.items():@@ -1040,8 +1060,9 @@ def align_gaits(results: list[dict[str, Any]], root: Path, mode: str, *, interpor["loop"]["n_out"] = row["strip"]["frames"]for state, items in left_out.items():out.setdefault(state, {"ok": True, "applied": False, "why": "fewer than two directions left to align"})["left_out"] = items- print(f"video-set: warning: {state}: {', '.join(items)} left out of the cycle alignment — a take to film again "- f"({loop_mod.STAND_REASON}): the walk starts or stops in it, and its loop is kept as cut", file=sys.stderr)+ for item, reasons in items.items():+ print(f"video-set: warning: {state}: {item} left out of the cycle alignment — {left_out_why(reasons, stands=True)}, "+ "and its loop is kept as cut", file=sys.stderr)# a foot told for an item no alignment took (its state not aligned, or the item failed) is never dropped quietlyfor state, told_items in asked.items():if told_items and not out[state].get("applied"):@@ -1051,7 +1072,7 @@ def align_gaits(results: list[dict[str, Any]], root: Path, mode: str, *, interpoif r is None:raise SystemExit(f"video-set: --align-foot {item}={foot} names no item of the set")why = (f"{item} failed" if not r.get("ok") else- f"{item} was left out of the alignment, a take to film again ({loop_mod.STAND_REASON})" if item in left_out.get(r["state"], {}) else+ f"{item} was left out of the alignment, {left_out_why(left_out[r['state']][item])}" if item in left_out.get(r["state"], {}) elsef"{r['state']} was not aligned (filmed in fewer than two directions)")out.setdefault(r["state"], {"ok": True, "applied": False, "why": why}).setdefault("feet_unused", {})[item] = footfor state, a in out.items():@@ -1207,7 +1228,7 @@ def run_set(# A take to film again its loop named (`retake`) — never a failure, never silent — and one the alignment left out.warnings += [f"{r['item']}: film this direction again ({', '.join(r['loop']['retake']['reasons'])}) — {r['dir']}/loop.report.json `retake`"for r in results if r.get("ok") and r["loop"].get("retake")]- warnings += [f"cycle-align:{st}: {item} left out — a take to film again ({', '.join(reasons)}), its loop kept as cut"+ warnings += [f"cycle-align:{st}: {item} left out — {left_out_why(reasons)}, its loop kept as cut"for st, a in aligned.items() for item, reasons in a.get("left_out", {}).items()]warnings += [f"cycle-align:{st}: --align-foot {item}={foot} not applied ({a.get('why') or a.get('error') or 'the item failed'})"for st, a in aligned.items() for item, foot in a.get("feet_unused", {}).items()]diff --git a/sprite_gen/video/crossings.py b/sprite_gen/video/crossings.pyindex 283bf0f..a01d6e9 100644--- a/sprite_gen/video/crossings.py+++ b/sprite_gen/video/crossings.py@@ -40,9 +40,11 @@ worst over the bounds: how far the wrap is from joining the same point of the waCrossings that mark cycles (`Reading.mark_cycles`, read by `local_cycle.read_cycles`): in gap mode a crossing iswhere the feet meet on the screen, and they need not meet at every pass. The far foot can pass behind the near oneinside a run of the feet together (a pass hidden), or a foot can step toward or away from the camera and pass the-other apart on the screen. The feet then meet once a cycle, and the interval between two crossings holds two steps.-Every count then reads two steps an interval (`per`): the step is half the interval, a cut's advance is twice the-crossings it covers, and the loop as played shows two steps a crossing. The step range is still read on the intervals.+other apart on the screen. The feet then meet once a cycle, and the interval between two crossings holds two steps —+marked so only where the body's top line witnesses it, rising and falling twice an interval (the picture a step on is+a cycle on's where the legs are drawn alike). Every count then reads two steps an interval (`per`): the step is half+the interval, a cut's advance is twice the crossings it covers, and the loop as played shows two steps a crossing. The+step range is still read on the intervals.What crossings cannot see: a hold the step range absorbs (a 13-frame step held to 17), a still run of the feettogether as long as a pass, a wobble that reaches the reading's sides at a step's beat. They read as steps.@@ -449,7 +451,8 @@ def read(sig: dict[str, list[float]]) -> Reading:def correlation_on(values: list[float], span: float) -> float | None:"""A per-frame signal's correlation `span` frames on (its trend taken out), the larger at the two whole lags about- `span`: the lean's one step on (`read`), a foot cue's one interval on (`local_cycle.read_cycles`)."""+ `span`: the lean's one step on (`read`), a foot cue's one interval on and the body's top line half an interval on+ (`local_cycle.read_cycles`)."""x = np.asarray(values, dtype=float)t = np.arange(len(x))x = x - np.polyval(np.polyfit(t, x, 1), t)diff --git a/sprite_gen/video/legs.py b/sprite_gen/video/legs.pyindex 3a2f447..c69013f 100644--- a/sprite_gen/video/legs.py+++ b/sprite_gen/video/legs.py@@ -11,16 +11,19 @@ Both read the same per-frame signals (`strike_signals`) and choose between themfraction of that height. Seen from the side or a diagonal the feet open and close once a step.- `reach`: the lowest solid row. Seen from the front or back the foot nearer the viewer is drawnlower, once a step.-- `top`: the body's top line, for a body with no legs to read.+- `top`: the body's top line, for a body with no legs to read. It rises and falls once a step+ whichever leg leads, so the step count reads it as the witness that a crossing interval holds+ two steps (`local_cycle.bob_word`).- `gap`: the widest empty run between the foot band's two ends, of the frame's height — two feetseen apart.Which of the two feet is which is read on cues the view draws (`depth_cue`, `shade_cue`): from the front or back thefoot nearer the viewer is drawn lower, from the side or a diagonal the far leg is drawn in shade. `video-cycle-align`-names the foot that lands by them (`align.strike_foot`), and the step count asks whether the same leg leads again one-crossing interval on (`local_cycle.read_cycles`). Legs drawn alike to a cue leave it still: its range over the clip-under half the step it is drawn in (a TONE of luma, a pixel row of the body's height) is the arithmetic's, not the-feet's (`local_cycle.cue_word`).+names the foot that lands by them (`align.strike_foot`), and the step count asks whether the other leg leads one+crossing interval on (`local_cycle.read_cycles`): a cue can only refuse cycles there, never witness them, since a light+fixed on the screen turns it with how far apart the feet are drawn, whichever leg leads. Legs drawn alike to a cue+leave it still: its range over the clip under half the step it is drawn in (a TONE of luma, a pixel row of the body's+height) is the arithmetic's, not the feet's (`local_cycle.cue_word`).The swing of the stride or the lowest row says there is something to read, not that it is legs:a legless body that squashes as it bounces widens its foot band once a cycle, where a walker'sdiff --git a/sprite_gen/video/local_cycle.py b/sprite_gen/video/local_cycle.pyindex 00c4653..57e8981 100644--- a/sprite_gen/video/local_cycle.py+++ b/sprite_gen/video/local_cycle.py@@ -31,15 +31,25 @@ SEAM_TRIES = 4 # two-step cuts, best first, whose seam is read as the seam gate# interval on and as near as two intervals on within CYCLE_SLACK of the clip's mean step (each read at a whole lag, up# to half a frame off the interval: about half a step).CYCLE_SLACK = 0.5-# The view's foot cue (`legs.shade_cue` from a diagonal or the side, `legs.depth_cue` from the front or back) says which-# leg leads (`cue_word`): turned over to CUE_SWAPPED or under one interval on (`crossings.correlation_on`), the other-# leg leads there and the interval is a step; turned over half an interval on and not one, the other leg leads a step-# on and the interval is two. A cue that does neither does not tell the legs apart, and says nothing.+# The view's foot cue (`legs.shade_cue` from a diagonal or the side, `legs.depth_cue` from the front or back) can only+# refuse cycles (`cue_word`): turned over to CUE_SWAPPED or under one interval on (`crossings.correlation_on`), the other+# leg leads there and the interval is a step. Its turn half an interval on witnesses nothing: a light fixed on the screen+# turns a cue bound to how far apart the feet are drawn there too, whichever leg leads.CUE_SWAPPED = -0.2# A cue whose range over the clip is under CUE_FLOOR of the step it is drawn in (`legs.TONE` of luma, a pixel row of the# body's height) rounds to one value: the legs are drawn alike to it, and its correlation is the arithmetic's (not read).CUE_FLOOR = 0.5+# The body's bob witnesses that the crossings mark cycles (`bob_word`), read without telling the legs apart: the body's+# top line (`legs.strike_signals` `top`) rises and falls once a step, so where the interval holds two steps it is+# correlated BOB_TWICE or over half an interval on (where it holds one, it is turned over there). A top line whose range+# over the clip is under BOB_FLOOR of the body's median height does not rise and fall, and witnesses nothing.+BOB_TWICE = 0.28+BOB_FLOOR = 0.005SIDE_VIEW = 'side' # from the side the legs a step on are one silhouette, as near as a cycle on: asked only where a pass hides+# A loop whose clip one interval on is the same picture, as a walk whose feet meet once a cycle draws it, with nothing+# to witness whether they do (`read_cycles`): its crossings stay on steps, so its two steps may be two cycles. Named on+# its step count (`cycles.unwitnessed`), and `video-set` leaves it out of its state's cycle alignment under this reason.+UNWITNESSED = 'cycle-unwitnessed'def _around(start, length):@@ -500,50 +510,64 @@ def repeat_at(distances, span):return min(found) if found else None-def cue_word(cue, interval, *, step=None, lead=True):- """What a foot cue (`cue`, per frame) says of the legs `interval` frames on (`read_cycles`): `says` `alike` where its- range over the clip is under CUE_FLOOR of the `step` it is drawn in (`legs.TONE` of luma, a pixel row of the body's- height) — it does not move: the legs are drawn alike to it, and its correlation (the arithmetic's) is not read. Else,- for the view's cue (`lead`), `steps` where it turns over one interval on (`crossings.correlation_on` at CUE_SWAPPED or- under: the other leg leads there), `cycles` where it turns over half an interval on and not one (the other leg leads- a step on: the interval is two steps), None where it does neither — it does not tell the legs apart. With no view- (`lead` false: the shade of the feet's two halves) only whether it moves is read. Returns the record."""+def cue_word(cue, interval, *, step=None):+ """What the view's foot cue (`cue`, per frame) says of the legs `interval` frames on (`read_cycles`): `says` `alike`+ where its range over the clip is under CUE_FLOOR of the `step` it is drawn in (`legs.TONE` of luma, a pixel row of+ the body's height) — it does not move: the legs are drawn alike to it, and its correlation (the arithmetic's) is not+ read. Else `steps` where it turns over one interval on (`crossings.correlation_on` at CUE_SWAPPED or under: the+ other leg leads there), None where it does not — it cannot say the same leg leads. Returns the record."""values = np.asarray(cue, dtype=float)spread = float(values.max()-values.min()) if values.size else 0.0word = {'range': float(f'{spread:.3g}'), **({'floor': float(f'{CUE_FLOOR*step:.3g}')} if step is not None else {}),- **({'swapped': CUE_SWAPPED} if lead else {})}+ 'swapped': CUE_SWAPPED}if step is not None and spread < CUE_FLOOR*step:return {**word, 'says': 'alike', 'why': f'its range over the clip ({spread:.2g}) is under half the step it is drawn in 'f'({step:.2g}): it does not move'}- if not lead:- return {**word, 'says': None, 'why': 'it moves; with no view, which leg leads is not read'}- half, one = (crossings_mod.correlation_on(values, span) for span in (interval/2, interval))- word.update(half=None if half is None else round(half, 3), one=None if one is None else round(one, 3))+ one = crossings_mod.correlation_on(values, interval)+ word['one'] = None if one is None else round(one, 3)if one is not None and one <= CUE_SWAPPED:return {**word, 'says': 'steps'}- if half is not None and half <= CUE_SWAPPED:+ return {**word, 'says': None, 'why': f"it does not turn over one interval on ({'not read' if one is None else f'{one:+.2f}'}, "+ f"over {CUE_SWAPPED:+g})"}+++def bob_word(top, interval, *, height):+ """Whether the body rises and falls twice an interval `interval` frames long (`read_cycles`), read off its top line+ (`top`, per frame, in pixel rows: `legs.strike_signals`) without telling the legs apart: `says` `cycles` where the+ line's range over the clip is BOB_FLOOR of the body's median `height` or more and it correlates BOB_TWICE or over half+ an interval on (`crossings.correlation_on`) — a step each rise, two steps an interval; None otherwise, with why.+ Returns the record: `swing` (the range of the body's height), `floor`, `twice`, `half` (where read), `says`."""+ values = np.asarray(top, dtype=float)+ swing = float(values.max()-values.min())/height if values.size and height > 0 else 0.0+ word = {'swing': round(swing, 4), 'floor': BOB_FLOOR, 'twice': BOB_TWICE}+ if swing < BOB_FLOOR:+ return {**word, 'says': None, 'why': f"its top line's range over the clip ({swing:.2%} of the body's height) is under "+ f"{BOB_FLOOR:.1%}: it does not rise and fall"}+ half = crossings_mod.correlation_on(values, interval/2)+ word['half'] = None if half is None else round(half, 3)+ if half is not None and half >= BOB_TWICE:return {**word, 'says': 'cycles'}- said = ', '.join(f'{v:+.2f} {k}' for k, v in (('half an interval on', half), ('one on', one)) if v is not None) or 'not read'- return {**word, 'says': None, 'why': f'it turns over neither a step on nor an interval on ({said}, over {CUE_SWAPPED:+g})'}+ return {**word, 'says': None, 'why': f"its top line does not rise and fall twice an interval "+ f"({'not read' if half is None else f'{half:+.2f}'} half an interval on, under {BOB_TWICE:+g})"}-def read_cycles(reading, distances, *, view=None, cue=None, cue_step=None):+def read_cycles(reading, distances, *, view=None, cue=None, cue_step=None, signals=None):"""Whether the crossings the clip shows (`reading`, gap mode) mark its cycles, not its steps, read and kept on thereading (`Reading.mark_cycles`; crossings.py, "Crossings that mark cycles"). The feet need not meet on the screenat every pass: the far foot can pass hidden behind the near one, or a foot step toward or away from the camera andpass the other apart. Then they meet once a cycle, and the clip one interval between crossings on (`repeat_at`) hasthe same leg leading, not the other: it is nearer than half an interval on (the pose a step on) and as near as two- intervals on within CYCLE_SLACK. Where the clip says so, a foot cue (`cue`, per frame, drawn in steps of `cue_step`)- is asked (`cue_word`): the view's, which leg leads — where the other leads one interval on, the interval is a step —- and with no view the shade of the feet's two halves, only whether it moves.-- Asked where a pass can hide (`reading.hides`, the far foot behind the near one): there the picture marks cycles- unless the cue says the other leg leads, or does not move — legs drawn alike to it are the same picture a step on as- a cycle on. Asked too where the `view` is given and is not the side, but there the picture alone marks nothing: the- cue must say the other leg leads a step on — half an interval on. A cue that does not tell the legs apart (one that- does not move, or there turns over neither a step on nor an interval on) leaves the crossings on steps, as from the- side, where the legs a step on are one silhouette and the picture cannot tell. Returns what was read, None where it- is not asked."""+ intervals on within CYCLE_SLACK. Asked where a pass can hide (`reading.hides`, the far foot behind the near one) or+ where the `view` is given and is not the side.++ The picture is the same a step on as a cycle on where the legs are drawn alike, and so is everything else that does+ not tell the legs apart (a foot cue under a light fixed on the screen, how far apart the feet are drawn): it marks+ cycles only where a witness that reads no leg says the interval holds two steps — the body's top line (`signals`,+ `legs.strike_signals`: `top`, and `height`) rising and falling twice an interval (`bob_word`). The view's foot cue+ (`cue`, per frame, drawn in steps of `cue_step`; `cue_word`) only refuses: where it turns over one interval on, the+ other leg leads there, a step. With no witness the crossings stay on steps, as from the side, and the record names+ it (`unwitnessed`): where the feet do meet once a cycle, each step counted is a cycle. Returns what was read, None+ where it is not asked."""if reading.mode != 'gap' or not reading.readable:return Noneoverlap, hides = reading.overlap, reading.hides@@ -555,8 +579,6 @@ def read_cycles(reading, distances, *, view=None, cue=None, cue_step=None):if hides else f'the {view} view, the legs side by side'),'interval': round(d, 2), 'overlap': None if overlap is None else round(overlap, 3),**{k: None if v is None else round(v, 3) for k, v in near.items()}, 'slack': CYCLE_SLACK}- picture = (f"the clip one interval on ({near['one']:.2f} steps off) is nearer than half an interval on ({near['half']:.2f}) "- f"and as near as two on ({near['two']:.2f}, +{CYCLE_SLACK:g})" if None not in near.values() else None)if None in near.values():said.update(cycles=False, why='the clip is too short to be read two intervals on')elif not (near['one'] < near['half'] and near['one'] <= near['two']+CYCLE_SLACK):@@ -564,23 +586,23 @@ def read_cycles(reading, distances, *, view=None, cue=None, cue_step=None):f"an interval on ({near['half']:.2f}) and two on ({near['two']:.2f}, +{CYCLE_SLACK:g}) ""would make it: the crossings mark steps")else:- word = None if cue is None else cue_word(cue, d, step=cue_step, lead=view is not None)- if word is not None:- said['cue'] = word- says = None if word is None else word['says']- if says == 'steps':- said.update(cycles=False, why=f"the clip one interval on is the same picture, but the view's foot cue turns over "- f"there ({word['one']:+.2f}, at most {CUE_SWAPPED:+g}): the other leg leads, a step")- elif hides and says != 'alike':- said.update(cycles=True, why=f"{picture}: the same leg leads, the feet meet once a cycle")- elif says == 'cycles':- said.update(cycles=True, why=f"{picture}, and the view's foot cue turns over half an interval on ({word['half']:+.2f}, "- f"at most {CUE_SWAPPED:+g}): the other leg leads a step on, the feet meet once a cycle")+ picture = (f"the clip one interval on ({near['one']:.2f} steps off) is nearer than half an interval on ({near['half']:.2f}) "+ f"and as near as two on ({near['two']:.2f}, +{CYCLE_SLACK:g})")+ word = None if cue is None or view is None else cue_word(cue, d, step=cue_step)+ bob = None if not signals else bob_word(signals['top'], d, height=float(np.median(signals['height'])))+ said.update({**({'cue': word} if word is not None else {}), **({'bob': bob} if bob is not None else {})})+ if word is not None and word['says'] == 'steps':+ said.update(cycles=False, why=f"{picture}, but the view's foot cue turns over there ({word['one']:+.2f}, at most "+ f"{CUE_SWAPPED:+g}): the other leg leads, a step")+ elif bob is not None and bob['says'] == 'cycles':+ said.update(cycles=True, why=f"{picture}, and the body's top line rises and falls twice an interval ({bob['half']:+.2f} "+ f"half an interval on, at least {BOB_TWICE:+g}): two steps an interval, the feet meet once "+ "a cycle")else:- named = "the view's foot cue" if view is not None else "the feet's shade"- said.update(cycles=False, why=f"{picture}, but {named} does not tell the legs apart "- f"({word['why'] if word is not None else 'none given'}): a step on draws as a cycle "- "on, as from the side, and the crossings mark steps")+ said.update(cycles=False, unwitnessed=True,+ why=f"{picture}, but nothing that reads no leg witnesses two steps an interval "+ f"({'no top line read' if bob is None else bob['why']}): a step on draws as a cycle on, as from the "+ "side, and the crossings mark steps")reading.mark_cycles(said)return said@@ -727,20 +749,22 @@ def _two_steps(cycle, record):def step_verdict(cycle):- """The step count's warnings, in words: crossings left on steps because a foot cue cannot tell the legs apart where- the clip one interval on is the same picture (`read_cycles`), a cut taken on two steps whose seam the pixel search- refuses (a part off the legs' beat) or that passed no gate, a search's cut kept where no two-step cut closes, and a- clip that shows its steps but no cut of two."""+ """The step count's warnings, in words: crossings left on steps because nothing witnesses two steps an interval+ where the clip one interval on is the same picture (`read_cycles`, `unwitnessed`), a cut taken on two steps whose+ seam the pixel search refuses (a part off the legs' beat) or that passed no gate, a search's cut kept where no+ two-step cut closes, and a clip that shows its steps but no cut of two."""counted = cycle.get('step_count')if not counted or not counted.get('readable'):return []s, L = cycle['start'], cycle['length']out = []said = counted.get('cycles') or {}- if said.get('cycles') is False and (said.get('cue') or {}).get('says', 'steps') in (None, 'alike'):- out.append(f"the clip one interval on is the same picture, as a walk whose feet meet once a cycle draws it, but its "- f"foot cue does not tell its legs apart ({said['cue']['why']}): its crossings are counted as steps, "- f"as from the side — where its feet do meet once a cycle, each step counted in the cut {s}/{L} is a cycle")+ if said.get('unwitnessed'):+ bob = said.get('bob')+ out.append(f"the clip one interval on is the same picture, as a walk whose feet meet once a cycle draws it, but nothing "+ f"that reads no leg witnesses it ({'no top line read' if bob is None else bob['why']}): its crossings are "+ f"counted as steps, as from the side — where its feet do meet once a cycle, each step counted in the cut "+ f"{s}/{L} is a cycle ({UNWITNESSED})")if counted.get('chosen_by') == 'two steps':if not counted.get('gated'):out.append(f"the cut {s}/{L} covers two steps by the clip's crossings, but no two-step cut joins the walk within "diff --git a/sprite_gen/video/loop.py b/sprite_gen/video/loop.pyindex 46c2f2c..dc9fae3 100644--- a/sprite_gen/video/loop.py+++ b/sprite_gen/video/loop.py@@ -1542,11 +1542,10 @@ def wrap_on_cells(frames: list[Image.Image]) -> float:def read_steps(frames: list[Image.Image], D: np.ndarray, *, view: str | None = None, facing: str = "right",signals: dict[str, list[float]] | None = None) -> crossings_mod.Reading:"""The clip's crossings (`crossings.read`), and whether they mark its cycles (`local_cycle.read_cycles`, on `D`, the- clip's distances, and the `view`'s foot cue: `legs.shade_cue` from the side or a diagonal, drawn in tones of- `legs.TONE`, `legs.depth_cue` from the front or back, in pixel rows of the body's median height; with no view, where- a pass can hide, the shade of the feet's two halves, read only for whether it moves). Every count the clip's steps- make is read on it: the search's cut (`_by_steps`), a fixed cut (`fixed_count`) and, carried to the loop, the loop- as it plays (`ring_steps`). `signals` are the frames' leg signals where already read."""+ clip's distances, the body's bob read off `signals` — the frames' leg signals, read here where not given — and the+ `view`'s foot cue: `legs.shade_cue` from the side or a diagonal, drawn in tones of `legs.TONE`, `legs.depth_cue` from+ the front or back, in pixel rows of the body's median height). Every count the clip's steps make is read on it: the+ search's cut (`_by_steps`), a fixed cut (`fixed_count`) and, carried to the loop, the loop as it plays (`ring_steps`)."""signals = leg_signals(frames) if signals is None else signalstry:reading = crossings_mod.read(crossings_mod.foot_signals(frames, gap=signals["gap"] if signals else None))@@ -1558,9 +1557,7 @@ def read_steps(frames: list[Image.Image], D: np.ndarray, *, view: str | None = Ncue = [legs_mod.shade_cue(f, facing) if lateral else legs_mod.depth_cue(f) for f in frames]heights = signals["height"] if signals else legs_mod.strike_signals(frames)["height"]step = legs_mod.TONE if lateral else 1.0 / float(np.median(heights))- elif reading.readable and reading.hides:- cue, step = [legs_mod.shade_cue(f, facing) for f in frames], legs_mod.TONE- local_cycle.read_cycles(reading, D, view=view, cue=cue, cue_step=step)+ local_cycle.read_cycles(reading, D, view=view, cue=cue, cue_step=step, signals=signals)return reading@@ -2784,12 +2781,12 @@ def add_arguments(parser: argparse.ArgumentParser) -> None:parser.add_argument("--view", choices=handed_mod.VIEWS, default=None,help="walk/run: the view the clip is filmed from. The step count asks whether the feet, which need not ""meet on the screen at every pass, meet once a cycle (`cycle.step_count.cycles`): where a pass "- "can hide, as without it, and from the front, the back or a diagonal also where passes are brief, "- "there only where the view's foot cue says the other leg leads a step on, half an interval on — "- "a cue that does not tell the legs apart leaves them on steps, as from the side, and so does one "- "that does not move (legs drawn alike to it) wherever it is asked (docs/loop-repair.md section 3, "- "\"The step count\"). Default: not given, asked only where a pass can hide, and there the feet's "- "shade is read only for whether it moves")+ "can hide, as without it, and from the front, the back or a diagonal also where passes are brief. "+ "Wherever it is asked, the crossings mark cycles only where the body's top line rises and falls "+ "twice an interval; the view's foot cue only refuses, where it says the other leg leads one "+ "interval on. With no witness they stay on steps, as from the side, with a warning "+ "(docs/loop-repair.md section 3, \"The step count\"). Default: not given, asked only where a pass "+ "can hide")parser.add_argument("--name", default="loop", help="basename for strip/gif/webp outputs")parser.add_argument("--report", type=Path)diff --git a/tests/video/test_cycle_align.py b/tests/video/test_cycle_align.pyindex bc3ad3e..90d875e 100644--- a/tests/video/test_cycle_align.py+++ b/tests/video/test_cycle_align.py@@ -20,7 +20,7 @@ import numpy as npimport pytestfrom PIL import Image, ImageDraw-from sprite_gen.video import align+from sprite_gen.video import align, local_cyclefrom sprite_gen.video import loop as loop_modW, H = 100, 120@@ -336,25 +336,36 @@ def test_video_set_aligns_each_gait_filmed_in_two_or_more_directions(tmp_path):@pytest.mark.slow-def test_video_set_leaves_a_take_to_film_again_for_a_start_or_stop_out_of_the_alignment(tmp_path):[email protected]("named, reasons", [+ ({"retake": {"reason": "start-stop", "reasons": ["start-stop"], "remedy": "retake"}}, ["start-stop"]),+ ({"cycle-unwitnessed": True}, ["cycle-unwitnessed"]),+ ({"retake": {"reason": "start-stop", "reasons": ["start-stop"], "remedy": "retake"}, "cycle-unwitnessed": True},+ ["start-stop", "cycle-unwitnessed"]),+])+def test_video_set_leaves_a_take_to_film_again_or_an_unwitnessed_count_out_of_the_alignment(tmp_path, capsys, named, reasons):"""A loop named a take to film again because the walk starts or stops in it (`retake` `start-stop`) loops no two- steps: it is left out, its loop as cut, and the rest are aligned without it. Left alone, the state is not aligned."""+ steps; a loop whose crossings may mark cycles with nothing to witness whether (`cycle-unwitnessed`,+ `local_cycle.read_cycles`) may loop two cycles where it counts two steps, and aligned it would play at twice its+ speed. Either is left out, its loop as cut, its reasons named, and the rest are aligned without it. Left alone, the+ state is not aligned."""from sprite_gen.video import batch- stand = {"reason": "start-stop", "reasons": ["start-stop"], "remedy": "retake"}rows = []- for direction, length, retake in (("front", 20, None), ("side", 24, None), ("back", 19, stand)):+ for direction, length, extra in (("front", 20, {}), ("side", 24, {}), ("back", 19, named)):item = tmp_path / f"{direction}-walk"item.mkdir()_cut(item, "loop", length)rows.append({"item": f"{direction}-walk", "direction": direction, "state": "walk", "dir": str(item), "ok": True,- "loop": {"n_out": length, **({"retake": retake} if retake else {})}})+ "loop": {"n_out": length, **extra}})out = batch.align_gaits(rows, tmp_path, "auto", interpolate=Recorder())- assert out["walk"]["applied"] and out["walk"]["lengths"] == [20, 24] and out["walk"]["left_out"] == {"back-walk": ["start-stop"]}+ assert out["walk"]["applied"] and out["walk"]["lengths"] == [20, 24] and out["walk"]["left_out"] == {"back-walk": reasons}assert [r["loop"]["n_out"] for r in rows] == [out["walk"]["length"]] * 2 + [19] and "cycle_align" not in rows[2]["loop"]+ said = capsys.readouterr().err+ assert ("a take to film again (start-stop)" in said) is ("start-stop" in reasons)+ assert (f"nothing witnesses whether ({local_cycle.UNWITNESSED})" in said) is (local_cycle.UNWITNESSED in reasons)alone = batch.align_gaits(rows[1:], tmp_path, "auto", interpolate=Recorder())assert alone == {"walk": {"ok": True, "applied": False, "why": "fewer than two directions left to align",- "left_out": {"back-walk": ["start-stop"]}}}+ "left_out": {"back-walk": reasons}}}def _no_rife(monkeypatch, tmp_path: Path) -> None:diff --git a/tests/video/test_walk_steps.py b/tests/video/test_walk_steps.pyindex 6a88245..57ff63b 100644--- a/tests/video/test_walk_steps.py+++ b/tests/video/test_walk_steps.py@@ -12,15 +12,18 @@ Each walker is drawn so the pixel search alone makes one of the faults a walk lo- a slow front walk in a short clip, refused outright (no periodic cycle found);- a walk that stalls, its cut playing the stalled step.-Two whose feet meet on the screen once a cycle, read as cycles (`local_cycle.read_cycles`) and cut one cycle: a walk-seen from behind whose far foot passes hidden behind the near one, on ones, twos or threes, a cycle a whole number of-frames or not (the parent engine counted the cycle one step and cut two cycles, or kept the search's cut unwritten); and-a walk on a front diagonal whose near foot steps out toward the camera and passes the far one apart, read so where its-view is given and its foot cue turns over a step on. Four guards: from the side, where the view's foot cue says the-other leg leads an interval on, where the cue cannot tell the legs apart (legs drawn alike, filmed from the front, the-back or a diagonal), and where legs drawn alike and wide keep the feet together over half the interval at a pass, as a-hidden pass does (with a view or none), the count stands however alike a step on draws. And one the count alone gets-wrong, where the search's cut stands: a walk on threes whose tail closes on no cut of two steps.+Two whose feet meet on the screen once a cycle, read as cycles (`local_cycle.read_cycles`) and cut one cycle, their+body rising and falling twice an interval between crossings — the witness that reads no leg: a walk seen from behind+whose far foot passes hidden behind the near one, on ones, twos or threes, a cycle a whole number of frames or not,+its legs drawn apart or alike (the parent engine counted the cycle one step and cut two cycles, or kept the search's+cut unwritten); and a walk on a front diagonal whose near foot steps out toward the camera and passes the far one+apart, read so where its view is given. The guards: from the side, and where the view's foot cue says the other leg+leads an interval on, the count stands however alike a step on draws; and where nothing that reads no leg witnesses+two steps an interval — legs drawn alike from any view, alike and wide as a hidden pass is, alike and wide under a+light fixed on the screen, the swing foot lifted under such a light, a far leg a few tones off with no view, and a+walk whose feet do meet once a cycle but whose body does not bob — the crossings stay on steps, named in a warning.+And one the count alone gets wrong, where the search's cut stands: a walk on threes whose tail closes on no cut of+two steps.A walk the search already cuts two steps long, joined at the walk's own point, is cut exactly as before; a bodywhose feet cannot be read is cut as before. Synthetic frames only."""@@ -87,21 +90,22 @@ def _front(k: float, *, cycle: float, phase: float = 0, tail_cycle: float = 1, treturn im-def _behind(k: int, *, cycle: float, hold: int) -> Image.Image:+def _behind(k: int, *, cycle: float, hold: int, alike: bool = False, bob: int = 3) -> Image.Image:"""A walker seen from behind on a diagonal, drawn on twos or threes (`hold`): the near leg swings ahead and back,and the far one is seen beside it only while it is behind — ahead, it stands hidden behind the near leg. The feetare seen apart once a cycle and together through the other step, its pass hidden among them: one crossing shows a- cycle. Arms opposite, the far one darker; each repeat of a drawing redrawn a little (a pixel aside, a few tones)."""+ cycle. The body bobs `bob` px once a step; the far leg darker (`alike`: drawn as the near one); arms opposite, the+ far one darker; each repeat of a drawing redrawn a little (a pixel aside, a few tones)."""redraw = k % holdph = 2 * math.pi * (k - redraw) / cycleim = Image.new("RGBA", (300, 220))d = ImageDraw.Draw(im)- x, y = 90 + redraw, 40 + round(3 * math.cos(2 * ph))+ x, y = 90 + redraw, 40 + round(bob * math.cos(2 * ph))sw = 16 * math.sin(ph)near = x + 14 + swfar = x + 14 - sw if sw > 0 else neard.rectangle((x + 14 - sw - 4, y + 34, x + 14 - sw + 4, y + 72), fill=(150, 150, 150, 255))- d.rectangle((far - 5, y + 80, far + 5, y + 126), fill=(50, 50, 60, 255))+ d.rectangle((far - 5, y + 80, far + 5, y + 126), fill=(70, 70, 80, 255) if alike else (50, 50, 60, 255))d.rectangle((near - 5, y + 80, near + 5, y + 126), fill=(70, 70, 80, 255))d.rectangle((x, y + 30, x + 28, y + 84), fill=(200 + 12 * redraw, 80, 80, 255))d.rectangle((x + 2, y, x + 26, y + 28), fill=(230, 200, 170, 255))@@ -109,14 +113,15 @@ def _behind(k: int, *, cycle: float, hold: int) -> Image.Image:return im-def _outward(k: float, *, cycle: float) -> Image.Image:+def _outward(k: float, *, cycle: float, bob: int = 3) -> Image.Image:"""A walker on a front diagonal whose near foot steps out toward the camera: it swings wide ahead and back, and thefar foot hardly moves, so the feet meet on the screen once a cycle, where the near foot passes the far one on its- way back; its pass on the way out is made apart. Arms opposite, the far one darker; the far leg a tone off the near."""+ way back; its pass on the way out is made apart. The body bobs `bob` px once a step; arms opposite, the far one+ darker; the far leg a tone off the near."""ph = 2 * math.pi * k / cycleim = Image.new("RGBA", (300, 220))d = ImageDraw.Draw(im)- x, y = 90, 40 + round(3 * math.cos(2 * ph))+ x, y = 90, 40 + round(bob * math.cos(2 * ph))sw = 16 * math.sin(ph)near, far = x + 14 + sw, x + 34 - 4 * math.sin(ph)d.rectangle((x + 14 - sw - 4, y + 34, x + 14 - sw + 4, y + 72), fill=(150, 150, 150, 255))@@ -129,24 +134,46 @@ def _outward(k: float, *, cycle: float) -> Image.Image:def _alike(k: float, *, cycle: float, phase: float = 0, tone: int = 1, lean: float = 0, leg_tone: int | None = None,- leg_half: int = 5) -> Image.Image:+ leg_half: int = 5, lift: int = 0, light: tuple[str, int] | None = None) -> Image.Image:"""A side walker whose two steps are the same silhouette: the far leg and arm `tone` tones lighter than the nearones (the far leg `leg_tone`, where given: 0 draws the legs alike), the arms swinging `lean` px further back thanforward — nothing else tells a step from the next. Each leg is drawn `leg_half` px either side of its line: at 10- the feet are seen together over half the interval at a pass, as where the far foot passes hidden."""+ the feet are seen together over half the interval at a pass, as where the far foot passes hidden. The leg swinging+ forward is lifted up to `lift` px, most at its pass; `light` lays a light fixed on the screen over the legs (`_lit`)."""ph = 2 * math.pi * (k + phase) / cycleim = Image.new("RGBA", (300, 220))d = ImageDraw.Draw(im)+ drawn = Image.new("L", im.size)x, y = 90, 40 + round(3 * math.cos(2 * ph))for sign, t in ((1, 0), (-1, tone)):sw = sign * (16 * math.sin(ph) + lean)d.rectangle((x + 14 - sw - 4, y + 34, x + 14 - sw + 4, y + 72), fill=(190 + t, 190 + t, 190 + t, 255))for sign, t in ((1, 0), (-1, tone if leg_tone is None else leg_tone)):lx = x + 14 + 14 * sign * math.sin(ph)- d.rectangle((lx - leg_half, y + 80, lx + leg_half, y + 126), fill=(60 + t, 60 + t, 70 + t, 255))+ up = round(lift * max(0.0, sign * math.cos(ph)))+ box = (lx - leg_half, y + 80 - up, lx + leg_half, y + 126 - up)+ d.rectangle(box, fill=(60 + t, 60 + t, 70 + t, 255))+ ImageDraw.Draw(drawn).rectangle(box, fill=255)d.rectangle((x, y + 30, x + 28, y + 84), fill=(200, 80, 80, 255))+ ImageDraw.Draw(drawn).rectangle((x, y + 30, x + 28, y + 84), fill=0)d.rectangle((x + 2, y, x + 26, y + 28), fill=(230, 200, 170, 255))- return im+ return _lit(im, drawn, light)+++def _lit(im: Image.Image, legs_drawn: Image.Image, light: tuple[str, int] | None) -> Image.Image:+ """`im` under a light fixed on the screen, laid over the pixels drawn as legs (`legs_drawn`), both legs alike:+ `("x", n)` up to n tones lighter to the right across the feet, `("y", n)` up to n tones lighter lower down the legs.+ It lights a foot by where it is drawn on the screen, not by which leg it is."""+ if light is None:+ return im+ axis, tones = light+ a = np.array(im)+ h, w = a.shape[:2]+ field = (np.clip((np.arange(w) - 80) * tones // 48, 0, tones)[None, :].repeat(h, 0) if axis == "x" else+ np.clip((np.arange(h) - 120) * tones // 46, 0, tones)[:, None].repeat(w, 1))+ on = np.asarray(legs_drawn) > 0+ a[..., :3][on] = np.clip(a[..., :3][on].astype(int) + field[on][:, None], 0, 255).astype(np.uint8)+ return Image.fromarray(a)def _tailed(k: int) -> Image.Image:@@ -296,14 +323,61 @@ def _one_cycle(out: Path, cycle: float) -> dict:def test_a_walk_whose_far_foot_hides_is_cut_one_cycle(tmp_path, cycle, hold):"""Seen from behind on a diagonal, the far foot passes hidden behind the near one: the feet are seen together overmore than half the interval between two crossings, one crossing a cycle. The clip one interval on is the same- picture, a cycle on, and the count reads the crossings as cycles: two steps an interval. The cut is one cycle,- `steps: 2` (the parent engine counted the cycle one step: on twos and threes it kept the search's cut unwritten, and- on ones, a cycle a whole number of frames or not, cut two cycles, 35 and 37 frames)."""+ picture, a cycle on, and the body rises and falls twice an interval — a step each rise: the count reads the+ crossings as cycles, two steps an interval. The cut is one cycle, `steps: 2` (the parent engine counted the cycle+ one step: on twos and threes it kept the search's cut unwritten, and on ones, a cycle a whole number of frames or+ not, cut two cycles, 35 and 37 frames). With no view, no foot cue is read."""report = _cut(tmp_path / "out", _keyed(tmp_path, lambda k: _behind(k, cycle=cycle, hold=hold)))counted = _one_cycle(tmp_path / "out", cycle)+ said = counted["cycles"]assert report["drawings"]["hold"] == hold- assert counted["cycles"]["asked"].startswith("the feet together") and counted["cycles"]["overlap"] > crossings.HIDE_SHARE- assert counted["cycles"]["one"] < counted["cycles"]["half"]+ assert said["asked"].startswith("the feet together") and said["overlap"] > crossings.HIDE_SHARE+ assert said["one"] < said["half"] and "cue" not in said and "unwitnessed" not in said+ assert said["bob"]["says"] == "cycles" and said["bob"]["half"] >= local_cycle.BOB_TWICE and said["bob"]["swing"] >= local_cycle.BOB_FLOOR+ assert "rises and falls twice an interval" in said["why"]++[email protected]("view", [None, "back_diagonal"])[email protected]("cycle, hold", [(17.5, 1), (20, 2)])+def test_a_walk_whose_far_foot_hides_is_cut_one_cycle_however_alike_its_legs(tmp_path, view, cycle, hold):+ """The same walker with its far leg drawn as the near one: the view's shade of the feet does not move (`alike`) and+ says nothing, and the body's bob, which reads no leg, still witnesses two steps an interval: one cycle (the parent+ engine left legs drawn alike to the cue on steps and cut two cycles, with a warning)."""+ _cut(tmp_path / "out", _keyed(tmp_path, lambda k: _behind(k, cycle=cycle, hold=hold, alike=True)), *(("--view", view) if view else ()))+ said = _one_cycle(tmp_path / "out", cycle)["cycles"]+ assert said["bob"]["says"] == "cycles" and (view is None) == ("cue" not in said)+ assert view is None or said["cue"]["says"] == "alike"+++def _unwitnessed(report: dict, interval: float) -> dict:+ """The cut is two crossing intervals long, `interval` frames each, two steps by its crossings left on steps because+ nothing that reads no leg witnesses two steps an interval (`cycles.unwitnessed`), and a warning names it."""+ c = report["cycle"]+ counted = c["step_count"]+ said = counted["cycles"]+ assert abs(c["length"] - 2 * interval) <= 1.5 and c["steps"] == {"count": 2, "by": "crossings"}+ assert counted["cut"]["verdict"] == "two" and report["status"] == "passed"+ assert said["one"] < said["half"] and said["one"] <= said["two"] + local_cycle.CYCLE_SLACK+ assert said["cycles"] is False and said["unwitnessed"] is True and said["bob"]["says"] is None+ assert "nothing that reads no leg witnesses two steps an interval" in said["why"]+ assert any(local_cycle.UNWITNESSED in w and f"the cut {c['start']}/{c['length']}" in w for w in report["jolt"]["warnings"])+ return said++[email protected]("walker, view, interval", [("behind", None, 17.5), ("behind", "back_diagonal", 17.5),+ ("outward", "front_diagonal", 16)])+def test_a_walk_whose_feet_meet_once_a_cycle_but_whose_body_does_not_bob_is_cut_two_intervals_with_a_warning(tmp_path, walker, view,+ interval):+ """The two walkers whose feet meet once a cycle, their body held still: its top line does not rise and fall, and+ nothing else that reads no leg can tell a step on from a cycle on. The crossings stay on steps: two intervals, two+ cycles, named in a warning — never one interval read as two steps on a word that cannot tell (the parent engine cut+ one cycle on the picture where a pass hid, and on the foot cue's turn half an interval on from the view)."""+ draw = (lambda k: _behind(k, cycle=interval, hold=1, bob=0)) if walker == "behind" else (lambda k: _outward(k, cycle=interval, bob=0))+ report = _cut(tmp_path / "out", _keyed(tmp_path, draw), *(("--view", view) if view else ()))+ said = _unwitnessed(report, interval)+ assert said["bob"]["swing"] < local_cycle.BOB_FLOOR and "does not rise and fall" in said["bob"]["why"]@pytest.mark.slow@@ -311,18 +385,20 @@ def test_a_walk_whose_far_foot_hides_is_cut_one_cycle(tmp_path, cycle, hold):def test_a_diagonal_walk_whose_near_foot_steps_out_is_cut_one_cycle_from_its_view(tmp_path, cycle):"""On a front diagonal the near foot steps out toward the camera and passes the far one apart: the feet meet on thescreen once a cycle, and briefly — no pass hides. Given the view, the count asks the picture: the clip one interval- on is the same picture, the legs as they were, and the view's foot cue does not turn over there. One cycle,- `steps: 2` (the parent engine counted each meeting a step and cut two cycles, 32 and 36 frames). Without the view- it is not asked, and cuts as before."""+ on is the same picture, the legs as they were, the view's foot cue does not turn over there, and the body rises and+ falls twice an interval. One cycle, `steps: 2` (the parent engine counted each meeting a step and cut two cycles,+ 32 and 36 frames). Without the view it is not asked, and cuts as before."""keyed = _keyed(tmp_path, lambda k: _outward(k, cycle=cycle))_cut(tmp_path / "view", keyed, "--view", "front_diagonal")counted = _one_cycle(tmp_path / "view", cycle)assert counted["cycles"]["overlap"] <= crossings.HIDE_SHARE and counted["cycles"]["asked"] == "the front_diagonal view, the legs side by side"- # The far leg a tone off the near one moves the cue a tone where the feet part: over the floor, and it turns over- # half an interval on (a step on) and not one — the other leg leads a step on, the interval is two.+ # The far leg a tone off the near one moves the cue a tone where the feet part: over the floor, and it does not turn+ # over one interval on — it does not refuse. Its turn half an interval on is no witness (a light fixed on the screen+ # turns a cue so too); the body's bob is.cue = counted["cycles"]["cue"]- assert cue["says"] == "cycles" and cue["range"] >= cue["floor"] == pytest.approx(local_cycle.CUE_FLOOR * legs.TONE, rel=0.01)- assert cue["half"] <= local_cycle.CUE_SWAPPED < cue["one"]+ assert cue["says"] is None and cue["range"] >= cue["floor"] == pytest.approx(local_cycle.CUE_FLOOR * legs.TONE, rel=0.01)+ assert cue["one"] > local_cycle.CUE_SWAPPED and "half" not in cue+ assert counted["cycles"]["bob"]["says"] == "cycles"plain = _cut(tmp_path / "plain", keyed)assert "cycles" not in plain["cycle"]["step_count"] and abs(plain["cycle"]["length"] - 2 * cycle) <= 1@@ -359,20 +435,17 @@ def test_a_diagonal_walk_whose_foot_cue_turns_over_a_step_on_is_cut_two_steps(tmdef test_a_walk_whose_legs_are_drawn_alike_is_cut_two_steps_from_any_view(tmp_path, view):"""The same walker with its legs drawn alike, its arms still four tones apart, filmed from the front, the back or adiagonal: one interval on (a step on) is the same picture, as near as two on, and the view's foot cue does not move- — the shade of legs drawn alike, feet drawn on one row — its range far under half the step it is drawn in. The cue- does not tell the legs apart and the picture cannot, and the crossings stay on steps, as from the side: two steps,- 46 frames, and a warning naming why (the parent engine read the still cue's float roundings, or no correlation, as- the same leg leading and cut 23 frames, one step, counted two)."""+ — the shade of legs drawn alike, feet drawn on one row — its range far under half the step it is drawn in. The body+ rises and falls once an interval, a step: nothing witnesses two steps an interval, and the crossings stay on steps,+ as from the side: two steps, 46 frames, and a warning naming why (the parent engine read the still cue's float+ roundings, or no correlation, as the same leg leading and cut 23 frames, one step, counted two)."""report = _cut(tmp_path / "out", _keyed(tmp_path, lambda k: _alike(k, cycle=46, phase=13, tone=4, lean=1, leg_tone=0)),"--view", view)- counted = _two_steps(report, 46)- said = counted["cycles"]+ _two_steps(report, 46)+ said = _unwitnessed(report, 23)assert said["asked"] == f"the {view} view, the legs side by side" and said["overlap"] <= crossings.HIDE_SHARE- assert said["cycles"] is False and said["one"] < said["half"] and said["one"] <= said["two"] + local_cycle.CYCLE_SLACKassert said["cue"]["says"] == "alike" and said["cue"]["range"] < said["cue"]["floor"] and "one" not in said["cue"]- assert "does not tell the legs apart" in said["why"]- assert any("does not tell its legs apart" in w and f"the cut {report['cycle']['start']}/46" in w- for w in report["jolt"]["warnings"])+ assert said["bob"]["half"] < -local_cycle.BOB_TWICE@pytest.mark.slow@@ -380,21 +453,62 @@ def test_a_walk_whose_legs_are_drawn_alike_is_cut_two_steps_from_any_view(tmp_padef test_a_walk_whose_legs_are_drawn_alike_and_wide_is_cut_two_steps_where_a_pass_could_hide(tmp_path, view):"""The same walker with its legs drawn alike and twice as wide: the feet are seen together over half the interval ateach pass, as where the far foot passes hidden, so the count asks the picture with or without a view — and one- interval on (a step on) is the same picture, as near as two on. But the foot cue does not move: the view's, or with- no view the shade of the feet's two halves, its range far under half the step it is drawn in. The legs are drawn- alike to it, the picture cannot tell a step on from a cycle on, and the crossings stay on steps: two steps, 46- frames, and a warning naming why (the parent engine let the picture mark cycles and cut 23 frames, one step, counted- two)."""+ interval on (a step on) is the same picture, as near as two on. The view's foot cue does not move (with no view+ none is read), and the body rises and falls once an interval: nothing witnesses two steps an interval, and the+ crossings stay on steps: two steps, 46 frames, and a warning naming why (the parent engine let the picture mark+ cycles and cut 23 frames, one step, counted two)."""keyed = _keyed(tmp_path, lambda k: _alike(k, cycle=46, phase=13, tone=4, lean=1, leg_tone=0, leg_half=10))report = _cut(tmp_path / "out", keyed, *(("--view", view) if view else ()))- counted = _two_steps(report, 46)- said = counted["cycles"]+ _two_steps(report, 46)+ said = _unwitnessed(report, 23)assert said["asked"].startswith("the feet together") and said["overlap"] > crossings.HIDE_SHARE- assert said["cycles"] is False and said["one"] < said["half"] and said["one"] <= said["two"] + local_cycle.CYCLE_SLACK- assert said["cue"]["says"] == "alike" and said["cue"]["range"] < said["cue"]["floor"] and "one" not in said["cue"]- assert ("the view's foot cue" if view else "the feet's shade") + " does not tell the legs apart" in said["why"]- assert any("does not tell its legs apart" in w and f"the cut {report['cycle']['start']}/46" in w- for w in report["jolt"]["warnings"])+ assert (said["cue"]["says"] == "alike" and said["cue"]["range"] < said["cue"]["floor"]) if view else "cue" not in said++[email protected]("view", [None, "side", "front_diagonal", "back_diagonal"])+def test_a_walk_whose_legs_are_drawn_alike_under_a_light_fixed_on_the_screen_is_cut_two_steps(tmp_path, view):+ """The wide walker with its legs drawn alike, lit from the right by a light fixed on the screen (up to 12 tones+ across the feet): the shade of the feet moves with how far apart they are drawn, whichever leg leads, and so turns+ over half an interval on. The body rises and falls once an interval: nothing that reads no leg witnesses two steps+ an interval, and the crossings stay on steps — 46 frames, a warning (the parent engine let the picture mark cycles+ where a pass could hide, and cut 23 frames, one step, counted two, from every one of these views)."""+ report = _cut(tmp_path / "out", _keyed(tmp_path, lambda k: _alike(k, cycle=46, phase=13, tone=4, lean=1, leg_tone=0, leg_half=10,+ light=("x", 12))), *(("--view", view) if view else ()))+ _two_steps(report, 46)+ said = _unwitnessed(report, 23)+ assert view is None or (said["cue"]["says"] is None and said["cue"]["range"] >= said["cue"]["floor"])++[email protected]("view", ["front", "front_diagonal", "back", "back_diagonal"])+def test_a_walk_whose_swing_foot_lifts_under_a_light_fixed_on_the_screen_is_cut_two_steps(tmp_path, view):+ """The walker with its legs drawn alike, the leg swinging forward lifted 6 px at its pass, lit lower down by a light+ fixed on the screen: the depth and the shade of the feet move with the swing, whichever leg swings, and turn over+ half an interval on. Nothing that reads no leg witnesses two steps an interval: 46 frames, a warning (the parent+ engine read the cue's turn half an interval on as the other leg leading a step on, and cut 23 frames)."""+ report = _cut(tmp_path / "out", _keyed(tmp_path, lambda k: _alike(k, cycle=46, phase=13, tone=4, lean=1, leg_tone=0, lift=6,+ light=("y", 12))), "--view", view)+ _two_steps(report, 46)+ assert _unwitnessed(report, 23)["cue"]["says"] in (None, "alike")++[email protected]("view", [None, "side", "front_diagonal"])+def test_a_wide_walk_whose_far_leg_is_drawn_a_few_tones_off_is_cut_two_steps(tmp_path, view):+ """The wide walker with its far leg four tones off the near one: a pass can hide. From the side or a diagonal the+ view's shade turns over one interval on — the other leg leads — and refuses cycles; with no view no cue is read,+ and the body rising and falling once an interval witnesses nothing: two steps, 46 frames either way, a warning+ only where nothing refused (the parent engine let the picture mark cycles with no view and cut 23 frames)."""+ report = _cut(tmp_path / "out", _keyed(tmp_path, lambda k: _alike(k, cycle=46, phase=13, tone=4, lean=1, leg_half=10)),+ *(("--view", view) if view else ()))+ counted = _two_steps(report, 46)+ if view is None:+ _unwitnessed(report, 23)+ else:+ said = counted["cycles"]+ assert said["cycles"] is False and said["cue"]["says"] == "steps" and "unwitnessed" not in said+ assert not any(local_cycle.UNWITNESSED in w for w in report["jolt"]["warnings"])@pytest.mark.slow@@ -498,15 +612,23 @@ def _reading(run: int) -> crossings.Reading:runs=[(c - run // 2, c + run // 2) for c in middles])+def _bob(beat: float | None) -> dict:+ """Leg signals whose body's top line rises and falls 3 rows either way every `beat` frames (None: held still), the+ body 100 rows tall: every 7.5 frames it rises and falls twice an interval of `_reading`, every 15 once."""+ t = np.arange(FRAMES)+ top = 40 + (np.zeros(FRAMES) if beat is None else 3 * np.cos(2 * np.pi * (t - 8) / beat))+ return {"top": list(top), "height": [100.0] * FRAMES}++def _choose(found: dict, *, period: int, seam: float, run: int = 9, search_seam: float = 1.0, view: str | None = None,- cue: list[float] | None = None, cue_step: float | None = None) -> tuple[dict, dict]:+ cue: list[float] | None = None, cue_step: float | None = None, bob: float | None = None) -> tuple[dict, dict]:"""`by_steps` on a clip whose picture goes round every `period` frames and whose feet meet every 15 (`_reading`),- its crossings read as `read_cycles` reads them from `view` and its foot `cue` (drawn in steps of `cue_step`, where- given), with the search's cut `found`: every two-step cut's seam reads `seam` at the gate, its top calm and its flow- off 1.0 either side, and the search's own cut `search_seam`."""+ its crossings read as `read_cycles` reads them from `view`, its foot `cue` (drawn in steps of `cue_step`, where+ given) and its body's bob (`_bob`, every `bob` frames), with the search's cut `found`: every two-step cut's seam+ reads `seam` at the gate, its top calm and its flow off 1.0 either side, and the search's own cut `search_seam`."""D = _distances(period=period, frames=FRAMES)reading = _reading(run)- local_cycle.read_cycles(reading, D, view=view, cue=cue, **({} if cue_step is None else {"cue_step": cue_step}))+ local_cycle.read_cycles(reading, D, view=view, cue=cue, signals=_bob(bob), **({} if cue_step is None else {"cue_step": cue_step}))return local_cycle.by_steps(D, np.zeros(FRAMES), reading, found=dict(found), refused=None, min_len=12, max_len=FRAMES,seam_flow=lambda s, L: {"off": [1.0, 1.0], "turn": [0.0, 0.0], "window": [[0, 0, 1, 1], [0, 0, 1, 1]]},@@ -544,101 +666,105 @@ def test_a_cut_the_count_refutes_gives_way_to_two_steps_closing_or_not():assert record["chosen_by"] == "two steps" and picked["steps"] == {"count": 2, "by": "crossings"} and abs(picked["length"] - 30) <= 1-def test_where_a_pass_can_hide_and_the_picture_repeats_each_interval_the_crossings_mark_cycles():[email protected]("bob", [7.5, 15, None])+def test_where_a_pass_can_hide_and_the_picture_repeats_each_interval_the_body_says_whether_the_crossings_mark_cycles(bob):"""The same meetings on a clip whose picture goes round every 15 frames, the feet together 9 frames at each: a pass- can hide there, and one interval on the clip is the same picture as two on — the same leg leads. The crossings mark- cycles, the step is half the interval, and the search's cut 10/15 is two steps joined at the walk's own point: it- stands, `steps` written."""- picked, record = _choose({"start": 10, "length": 15}, period=15, seam=1.0)+ can hide there, and one interval on the clip is the same picture as two on. Where the body rises and falls twice an+ interval, the crossings mark cycles: the step is half the interval, and the search's cut 10/15 is two steps joined at+ the walk's own point — it stands, `steps` written. Where it rises and falls once an interval, or is held still, the+ picture alone cannot tell a step on from a cycle on (legs drawn alike are the same picture a step on): the crossings+ stay on steps, two steps of 15, `unwitnessed`, a warning naming it (the parent engine let the picture mark cycles)."""+ picked, record = _choose({"start": 10, "length": 15}, period=15, seam=1.0, bob=bob)said = record["cycles"]- assert said["cycles"] is True and said["asked"].startswith("the feet together") and said["one"] <= said["two"] + local_cycle.CYCLE_SLACK- assert record["step_range"][1] == 7.5- assert (picked["start"], picked["length"]) == (10, 15) and picked["steps"] == {"count": 2, "by": "crossings"}- assert record["chosen_by"] == "search" and record["cut"]["verdict"] == "two"+ assert said["asked"].startswith("the feet together") and said["one"] <= said["two"] + local_cycle.CYCLE_SLACK and "cue" not in said+ if bob == 7.5:+ assert said["cycles"] is True and said["bob"]["says"] == "cycles" and said["bob"]["half"] >= local_cycle.BOB_TWICE+ assert record["step_range"][1] == 7.5 and "unwitnessed" not in said+ assert (picked["start"], picked["length"]) == (10, 15) and picked["steps"] == {"count": 2, "by": "crossings"}+ assert record["chosen_by"] == "search" and record["cut"]["verdict"] == "two"+ assert local_cycle.step_verdict({**picked, "step_count": record}) == []+ else:+ assert said["cycles"] is False and said["unwitnessed"] is True and said["bob"]["says"] is None+ assert ("does not rise and fall" if bob is None else "does not rise and fall twice an interval") in said["bob"]["why"]+ assert ("half" not in said["bob"]) if bob is None else said["bob"]["half"] < -local_cycle.BOB_TWICE+ assert record["chosen_by"] == "two steps" and abs(picked["length"] - 30) <= 1+ warned = [w for w in local_cycle.step_verdict({**picked, "step_count": record}) if local_cycle.UNWITNESSED in w]+ assert len(warned) == 1 and said["bob"]["why"] in warned[0]@pytest.mark.parametrize("view", [None, "side"])def test_where_the_feet_meet_briefly_the_count_stands_from_the_side_or_no_view(view):"""The same clip, its feet seen together only at the moment they meet: no pass can hide, and from the side (or withno view given) a step on drawing as near as a cycle on is what legs drawn alike do. Not asked: two steps."""- picked, record = _choose({"start": 10, "length": 15}, period=15, seam=1.0, run=3, view=view)+ picked, record = _choose({"start": 10, "length": 15}, period=15, seam=1.0, run=3, view=view, bob=7.5)assert "cycles" not in recordassert record["search"]["verdict"] == "refuted" and record["chosen_by"] == "two steps" and abs(picked["length"] - 30) <= 1[email protected]("turns, cycles", [(True, False), (False, True)])-def test_from_a_diagonal_the_foot_cue_says_which_leg_leads_an_interval_on(turns, cycles):- """The same brief meetings from a front diagonal: asked. One interval on is the same picture; where the view's foot- cue turns over there (the near foot's shade leading one interval, the far one's the next) the other leg leads and- the count stands, two steps of 15; where it turns over half an interval on instead and holds one on, the other leg- leads a step on, the crossings mark cycles and the search's 15 frames are the cycle."""[email protected]("cue, bob, cycles", [("one", 7.5, False), ("half", 15, False), ("half", 7.5, True)])+def test_from_a_diagonal_the_foot_cue_only_refuses_cycles(cue, bob, cycles):+ """The same brief meetings from a front diagonal: asked, and one interval on is the same picture. Where the view's+ foot cue turns over one interval on (the near foot's shade leading one interval, the far one's the next) the other+ leg leads there: the count stands, two steps of 15, whatever the body says. A cue that turns over half an interval+ on and holds one on is no witness — a light fixed on the screen turns the shade of feet drawn apart so, whichever+ leg leads: with the body rising and falling once an interval, the crossings stay on steps with a warning (the+ parent engine read the turn as the other leg leading a step on and kept 15 frames as two steps); rising and falling+ twice, they mark cycles and the search's 15 frames are the cycle."""t = np.arange(FRAMES)- cue = list(np.sin(2 * np.pi * (t - 8) / (30 if turns else 15)))- picked, record = _choose({"start": 10, "length": 15}, period=15, seam=1.0, run=3, view="front_diagonal", cue=cue,- cue_step=legs.TONE)+ values = list(np.sin(2 * np.pi * (t - 8) / (30 if cue == "one" else 15)))+ picked, record = _choose({"start": 10, "length": 15}, period=15, seam=1.0, run=3, view="front_diagonal", cue=values,+ cue_step=legs.TONE, bob=bob)said = record["cycles"]assert said["asked"] == "the front_diagonal view, the legs side by side" and said["cycles"] is cycles- assert (said["cue"]["one"] <= local_cycle.CUE_SWAPPED) is turns and said["cue"]["says"] == ("steps" if turns else "cycles")- assert turns or said["cue"]["half"] <= local_cycle.CUE_SWAPPED+ assert said["cue"]["says"] == ("steps" if cue == "one" else None) and "half" not in said["cue"]+ assert (said["cue"]["one"] <= local_cycle.CUE_SWAPPED) is (cue == "one")+ assert said.get("unwitnessed", False) is (cue == "half" and not cycles)assert abs(picked["length"] - (15 if cycles else 30)) <= (0 if cycles else 1)+ warned = local_cycle.step_verdict({**picked, "step_count": record})+ assert any(local_cycle.UNWITNESSED in w for w in warned) is (cue == "half" and not cycles)[email protected]("view, run", [("front_diagonal", 3), ("back_diagonal", 9), (None, 9)])@pytest.mark.parametrize("cue", ["still", "own beat"])-def test_from_a_diagonal_a_cue_that_does_not_tell_the_legs_apart_leaves_the_crossings_on_steps(cue):- """The same brief meetings from a front diagonal, the clip one interval on the same picture, but the view's foot cue- does not tell the legs apart. Legs drawn alike leave it still: a few float roundings, its range far under half a- tone (`legs.TONE`) — not read, however well the roundings, which repeat with the legs, correlate one interval on. Or- it flickers on a beat of its own (every 4 frames), turning over neither a step on nor an interval on. It says nothing,- the picture alone cannot tell a step on from a cycle on, and the count stands, two steps of 15, a warning naming it- (the parent engine read either as the same leg leading and kept the search's 15 frames, counted two steps)."""[email protected]("bob", [7.5, None])+def test_a_cue_that_does_not_tell_the_legs_apart_leaves_the_word_to_the_body(view, run, cue, bob):+ """The same meetings, the clip one interval on the same picture, from a diagonal (passes brief or long) or with no+ view where a pass can hide, and a foot cue that does not tell the legs apart: legs drawn alike leave it still — a+ few float roundings, its range far under half a tone (`legs.TONE`), not read, however well the roundings, which+ repeat with the legs, correlate — or it flickers on a beat of its own (every 4 frames) and does not turn over one+ interval on. It refuses nothing; with no view it is not read at all. The body says: rising and falling twice an+ interval, the crossings mark cycles, one cycle of 15 (the parent engine left a still cue on steps, two cycles);+ held still, they stay on steps, two steps of 15, with a warning."""t = np.arange(FRAMES)values = 1e-8 * np.sin(2 * np.pi * (t - 8) / 15) if cue == "still" else 0.05 * np.cos(2 * np.pi * t / 4)- picked, record = _choose({"start": 10, "length": 15}, period=15, seam=1.0, run=3, view="front_diagonal",- cue=list(values), **({"cue_step": legs.TONE} if cue == "still" else {}))+ picked, record = _choose({"start": 10, "length": 15}, period=15, seam=1.0, run=run, view=view, cue=list(values),+ bob=bob, **({"cue_step": legs.TONE} if cue == "still" else {}))said = record["cycles"]assert said["one"] < said["half"] and said["one"] <= said["two"] + local_cycle.CYCLE_SLACK- assert said["cycles"] is False and "does not tell the legs apart" in said["why"]- assert said["cue"]["says"] == ("alike" if cue == "still" else None)- if cue == "still":- assert said["cue"]["range"] < said["cue"]["floor"] and "one" not in said["cue"]+ if view is None:+ assert "cue" not in saidelse:- assert said["cue"]["half"] > local_cycle.CUE_SWAPPED and said["cue"]["one"] > local_cycle.CUE_SWAPPED- assert record["chosen_by"] == "two steps" and abs(picked["length"] - 30) <= 1- warned = local_cycle.step_verdict({**picked, "step_count": record})- assert any("does not tell its legs apart" in w for w in warned)--[email protected]("view", ["back_diagonal", None])-def test_where_a_pass_can_hide_a_still_cue_leaves_the_crossings_on_steps(view):- """Where a pass can hide (the feet together 9 frames at each meeting) the picture marks cycles unless the cue says- otherwise. A still cue — the view's, or with no view the shade of the feet's two halves — says the legs are drawn- alike to it: the picture a step on is then the picture a cycle on, and cannot tell. The crossings stay on steps, two- steps of 15, a warning naming it, whatever the still cue's roundings correlate (the parent engine let the picture- mark cycles and kept the search's 15 frames, counted two steps)."""- t = np.arange(FRAMES)- cue = list(-1e-8 * np.cos(2 * np.pi * (t - 8) / 30))- picked, record = _choose({"start": 10, "length": 15}, period=15, seam=1.0, view=view, cue=cue, cue_step=legs.TONE)- said = record["cycles"]- assert said["asked"].startswith("the feet together") and said["cycles"] is False- assert said["cue"]["says"] == "alike" and said["cue"]["range"] < said["cue"]["floor"] and "one" not in said["cue"]- assert ("the view's foot cue" if view else "the feet's shade") + " does not tell the legs apart" in said["why"]- assert record["chosen_by"] == "two steps" and abs(picked["length"] - 30) <= 1- assert any("does not tell its legs apart" in w for w in local_cycle.step_verdict({**picked, "step_count": record}))---def test_where_a_pass_can_hide_with_no_view_a_moving_shade_leaves_the_picture_to_mark_cycles():- """With no view the shade of the feet's two halves is read only for whether it moves, not for which leg leads (its- halves are the picture's, the legs' only from a side or a diagonal): one that moves — here turning over one- interval on, as a view's cue whose other leg leads there would — leaves the picture to mark cycles, the search's 15- frames a cycle, counted two steps."""+ assert said["cue"]["says"] == ("alike" if cue == "still" else None)+ assert ("one" not in said["cue"]) if cue == "still" else said["cue"]["one"] > local_cycle.CUE_SWAPPED+ assert said["cycles"] is (bob is not None) and said.get("unwitnessed", False) is (bob is None)+ assert abs(picked["length"] - (15 if bob else 30)) <= (0 if bob else 1)+ assert any(local_cycle.UNWITNESSED in w for w in local_cycle.step_verdict({**picked, "step_count": record})) is (bob is None)++[email protected]("swing, beat, says", [(3, 7.5, "cycles"), (3, 15, None), (0.2, 7.5, None), (3, 30, None)])+def test_the_body_witnesses_two_steps_an_interval_where_its_top_line_rises_and_falls_twice(swing, beat, says):+ """`bob_word` on an interval of 15 frames, the body 100 rows tall: a top line rising and falling 3 rows either way+ every 7.5 frames (twice an interval) witnesses two steps an interval; every 15 (once: a step an interval) or every+ 30 (once a cycle of two intervals: a quarter turn half an interval on) does not; 0.2 rows either way, its range+ under BOB_FLOOR of the body's height, does not rise and fall, however it correlates."""t = np.arange(FRAMES)- cue = list(0.05 * np.sin(2 * np.pi * (t - 8) / 30))- picked, record = _choose({"start": 10, "length": 15}, period=15, seam=1.0, cue=cue, cue_step=legs.TONE)- said = record["cycles"]- assert said["asked"].startswith("the feet together") and said["cycles"] is True- assert said["cue"]["says"] is None and said["cue"]["range"] >= said["cue"]["floor"]- assert "one" not in said["cue"] and "swapped" not in said["cue"]- assert (picked["start"], picked["length"]) == (10, 15) and picked["steps"] == {"count": 2, "by": "crossings"}+ word = local_cycle.bob_word(list(40 + swing * np.cos(2 * np.pi * t / beat)), 15, height=100)+ assert word["says"] == says and word["floor"] == local_cycle.BOB_FLOOR and word["twice"] == local_cycle.BOB_TWICE+ assert word["swing"] == pytest.approx(2 * swing / 100, abs=0.002)+ if swing < 1:+ assert "half" not in word and "does not rise and fall" in word["why"]+ else:+ assert (word["half"] >= local_cycle.BOB_TWICE) is (says == "cycles")@pytest.mark.parametrize("verdict, named", [("uncertain", True), ("two", False)])