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 body witnesses two steps an interval only less the picture's flow, so a walk carried up and down is not cut one step
Soohong Kim09108d1fa1b7
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex b34b2f0..d0f4987 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -4,20 +4,20 @@ All notable public changes to `sprite-gen` are recorded here. Versions track the## 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 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.+**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, read less the picture's own flow, 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.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`.+- **New: crossing cycle detection (`local_cycle.read_cycles`, `local_cycle.bob_word`, `local_cycle.off_flow`, `local_cycle.cue_word`, `crossings.HIDE_SHARE`, `crossings.Reading.hides`, `CYCLE_SLACK`, `CUE_FLOOR`, `CUE_SWAPPED`, `BOB_TWICE`, `BOB_FLOOR`, `BOB_ROWS`, `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`) less its flow rising and falling twice an interval. New function `local_cycle.off_flow(values, interval)` returns `values` (per frame) less their flow: each frame minus the mean of the interval about it (a moving average one interval long, its two end frames weighted by the part of a frame the interval covers), kept only over the frames the interval fits about (the first and last `ceil(interval/2 - 0.5)` frames drop out), and what is left minus its least-squares straight line; a rise and fall once or twice an interval averages to nothing over one interval and is left whole, while a flow slower than the interval is taken out wholly where it bends no more than a cubic (a constant, a straight drift, an arc, a cubic) and in part where it is a slow sway a few intervals long. `local_cycle.bob_word(top, interval, height)` reads the body's top line less its flow (`off_flow(top, interval)`), not the raw line; `swing` is the range of the line left over the body's median height, and `rows` is that range in pixel rows. Where the clip is under an interval long so nothing is left, `says` is null and `why` says its top line less its flow is not read; where `swing` is under `BOB_FLOOR` (0.005) or `rows` is under `BOB_ROWS` (2), `says` is null, `why` says the line's range less its flow is under 0.5 % of the body's height or 2 rows, so it does not rise and fall (the top line is read in whole pixel rows, so a picture drifting up or down makes the line step a row up and down as it rounds, and that rounding, less its own mean over an interval, stays under 2 rows), and `half` and `quarter` are not read. Otherwise it reads the line left's correlation half an interval on (`half`) and a quarter of an interval on (`quarter`), both with `crossings.correlation_on` (each the larger of the two whole lags about the span), saying `"cycles"` only where `half` is `BOB_TWICE` (0.28) or more and `quarter` is `-BOB_TWICE` (-0.28) or less (the line is as it was half an interval on and turned over a quarter on, which is a rise and fall twice an interval; a step's bob is turned over half an interval on, and any flow left over is as it was at both half and a quarter of an interval on so it cannot pass the quarter test), null otherwise with `why` giving both values. 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 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, 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)`.+- 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, rows, floor, twice, half, quarter, says, why}`, `half` and `quarter` absent under the floors 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.off_flow(values, interval)`, `local_cycle.cue_word(cue, interval, step=None)`, `local_cycle.BOB_TWICE`, `local_cycle.BOB_FLOOR`, `local_cycle.BOB_ROWS`, `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: 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;+ - 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 (the line left under `BOB_FLOOR` of the body's height and under `BOB_ROWS` rows), 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;@@ -25,7 +25,9 @@ All notable public changes to `sprite-gen` are recorded here. Versions track the- 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;+ - the wide legs-alike side walker (46-frame cycle, crossings every 23 frames, a pass can hide), carried up and down with the whole picture: along a smooth arc 24 px deep, and, with its body held still, along the same arc, along a sway 12 px either way, four intervals long (92 frames), and down a ramp 24 px over the clip, a row every three frames; each is cut two steps, 46 frames, with `unwitnessed` and the warning; for the bobbing walker its `half` is `-0.28` or less (less its flow its line rises and falls once an interval); for the still one its `rows` is under `BOB_ROWS`; before this change every one of the four was cut one step, counted two, and no warning said so;+ - the walker seen from behind whose far foot hides behind the near one (cycle 17.5 frames on ones, legs drawn alike), carried along the arc and the cubic: cut one cycle; the bob says `"cycles"` with its `quarter` at `-0.28` or less;+ - 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 floors at 0.2 rows either way without reading `half` or `quarter` (`swing` and `rows` are the range of `off_flow`'s line), while for a top line in whole rows on a picture held still or carried along an arc 24 rows deep, a cubic 48 rows either way, a sway 12 rows either way four intervals long, or a ramp of 6 rows over the clip, rising and falling twice an interval says `"cycles"` under every one, once an interval, or not at all, says null under every one, and not rising at all, on the still picture, the arc, the cubic or the ramp, the line left is under `BOB_ROWS`, and `off_flow` over intervals of 15 and 17.5 frames takes a cubic flow out wholly and leaves a rise and fall once or twice an interval as it was (less its straight line) over the frames the interval fits about;- 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;diff --git a/docs/loop-repair.md b/docs/loop-repair.mdindex 5b5c64e..b3c1ae3 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`, `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 |+| `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`, `rows`, `floor`, `twice`, `half`, `quarter`, `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` |@@ -1309,51 +1309,73 @@ The picture passes where `one < half` (one interval on is nearer than the pose a`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 picturecannot 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+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 nothingabout which leg leads. Read that way, a walk whose crossings are its steps was cut one step long andcounted two steps: a half-cycle loop, with no warning. The crossings mark cycles only where a witnessthat 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`:+leg leads, so two rises an interval are two steps an interval.+`local_cycle.bob_word(top, interval, height)` reads the body's top line less its flow+(`off_flow(top, interval)`), not the raw line. `local_cycle.off_flow(values, interval)` returns `values`+(per frame) less their flow: each frame minus the mean of the interval about it (a moving average one+interval long, its two end frames weighted by the part of a frame the interval covers), kept only over+the frames the interval fits about (the first and last `ceil(interval/2 - 0.5)` frames drop out), and+what is left minus its least-squares straight line. A rise and fall once or twice an interval averages to+nothing over one interval and is left whole. A flow slower than the interval is taken out: wholly where+it bends no more than a cubic (a constant, a straight drift, an arc, a cubic), in part where it is a slow+sway a few intervals long. Its record: `swing` is the range of the line left over the body's median+height; `rows` is that range in pixel rows. Where the clip is under an interval long so nothing is left:+`says` null, `why` says its top line less its flow is not read. Where `swing` is under `BOB_FLOOR`+(`0.005`) or `rows` is under `BOB_ROWS` (`2`): `says` null, `why` says the line's range less its flow is+under 0.5 % of the body's height or 2 rows, so it does not rise and fall; `half` and `quarter` are not+read. The top line is read in whole pixel rows, so a picture drifting up or down makes the line step a+row up and down as it rounds, and that rounding, less its own mean over an interval, stays under 2 rows.+Otherwise it reads the line left's correlation half an interval on (`half`) and a quarter of an interval+on (`quarter`), both with `crossings.correlation_on` (each the larger of the two whole lags about the+span). It says `"cycles"` only where `half` is `BOB_TWICE` (`0.28`) or more and `quarter` is `-BOB_TWICE`+(`-0.28`) or less: the line is as it was half an interval on and turned over a quarter on, which is a+rise and fall twice an interval. Otherwise null, and `why` gives both values. A rise and fall twice an+interval is as it was half an interval on and turned over a quarter on; a step's bob (once an interval)+is turned over half an interval on; any flow left over (slower than the interval) is as it was at both+half and a quarter of an interval on, so it cannot pass the quarter test. The whole picture shaking up+and down at twice the interval's beat is the same signal as the bob and is read as one; a sway of the+whole picture as large as the bob or larger, between about one and three intervals long, can hide a true+bob, and then the crossings stay on steps with the warning (two intervals, named), not one cycle. 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 less its flow rises and falls twice an+interval (its `half`, at least `BOB_TWICE`; its `quarter`, at most `-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+`says` is `"steps"`, `"alike"` or null); `bob: {swing, rows, floor, twice, half, quarter, says, why}`+(`half` and `quarter` absent under the floors; `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 thesynthetic walkers of `tests/video/test_walk_steps.py` (bodies rising and falling 3 px either way once a@@ -1368,9 +1390,10 @@ frames: with `--view front_diagonal` cut one cycle (16, 18 frames); its foot cuedoes 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 frombehind (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+`--view front_diagonal`) with their bodies held still have their top line not rising and falling (the+line left (less its flow) ranges under `BOB_FLOOR` of the body's height and under `BOB_ROWS` rows): 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 fourapart), passes brief, is not asked with no view or with `--view side`, and is cut two steps (46 frames) asbefore. The same 46-frame walker filmed as a front diagonal, its far leg four tones off the near one, isasked with `--view front_diagonal`: the picture passes, but the foot cue turns over one interval on@@ -1391,7 +1414,16 @@ pass and a light fixed on the screen varying top to bottom (12 tones), asked witover half an interval on; nothing witnesses: 46 frames, warning. The wide walker with its far leg four tonesoff the near one (a pass can hide): with `--view side` or `front_diagonal` the cue turns over one intervalon (`"steps"`): two steps, 46 frames, no warning; with no view no cue is read and nothing witnesses: 46-frames, `unwitnessed`, warning.+frames, `unwitnessed`, warning. The wide legs-alike side walker (46-frame cycle, crossings every 23+frames, a pass can hide), carried up and down with the whole picture along a smooth arc 24 px deep, and,+with its body held still, along the same arc, along a sway 12 px either way, four intervals long (92+frames), and down a ramp 24 px over the clip, a row every three frames: each is cut two steps, 46 frames,+with `unwitnessed` and the warning. For the bobbing walker its `half` is `-0.28` or less (less its flow+its line rises and falls once an interval); for the still one its `rows` is under `BOB_ROWS`. Before this+change every one of the four was cut one step, counted two, and no warning said so. The walker seen from+behind whose far foot hides behind the near one (cycle 17.5 frames on ones, legs drawn alike), carried+along the arc and the cubic: cut one cycle; the bob says `"cycles"` with its `quarter` at `-0.28` or+less.**Choosing the cut.**diff --git a/sprite_gen/video/crossings.py b/sprite_gen/video/crossings.pyindex a01d6e9..59caec2 100644--- a/sprite_gen/video/crossings.py+++ b/sprite_gen/video/crossings.py@@ -41,10 +41,10 @@ Crossings that mark cycles (`Reading.mark_cycles`, read by `local_cycle.read_cycwhere 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 theother 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.+marked so only where the body's top line witnesses it, rising and falling twice an interval less its flow (the picture+a step on is a cycle on's where the legs are drawn alike, and the picture drifting up and down moves the line too).+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.@@ -451,8 +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 and the body's top line half an 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 less its flow half+ and a quarter of 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/local_cycle.py b/sprite_gen/video/local_cycle.pyindex 57e8981..7a8b67d 100644--- a/sprite_gen/video/local_cycle.py+++ b/sprite_gen/video/local_cycle.py@@ -40,11 +40,17 @@ CUE_SWAPPED = -0.2# 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.+# top line (`legs.strike_signals` `top`) rises and falls once a step. It is read less its flow (`off_flow`): the+# picture drifting, swaying or zooming up and down slower than the interval, or a lean changing, moves the line where+# it pleases, while a rise and fall once or twice an interval comes to nothing over one and is left whole. Where the+# interval holds two steps the line left is as it was half an interval on and turned over a quarter on, each by+# BOB_TWICE (correlated BOB_TWICE or over there, -BOB_TWICE or under here); where it holds one it is turned over half an+# interval on, and a flow left over is as it was at both. A line left whose range is under BOB_FLOOR of the body's+# median height, or under BOB_ROWS pixel rows (a line read in whole rows rounds a row up and down as the picture+# drifts), does not rise and fall, and witnesses nothing.BOB_TWICE = 0.28BOB_FLOOR = 0.005+BOB_ROWS = 2SIDE_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@@ -531,24 +537,46 @@ def cue_word(cue, interval, *, step=None):f"over {CUE_SWAPPED:+g})"}+def off_flow(values, interval):+ """`values` (per frame) less their flow: each frame less the mean of the `interval` about it (a moving average one+ interval long, its two end frames weighted by the part of a frame the interval covers), over the frames the interval+ fits about, and what is left less its straight line. A rise and fall once or twice an interval comes to nothing over+ one and is left whole; a flow slower than the interval is taken out, wholly where it bends no more than a cubic."""+ x = np.asarray(values, dtype=float)+ reach = math.ceil(interval/2 - 0.5)+ if x.size < 2*reach + 3:+ return x[:0]+ weights = np.clip(interval/2 + 0.5 - np.abs(np.arange(-reach, reach+1)), 0.0, 1.0)+ left = x[reach:x.size-reach] - np.convolve(x, weights/weights.sum(), mode='valid')+ t = np.arange(left.size)+ return left - np.polyval(np.polyfit(t, left, 1), t)++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:+ (`top`, per frame, in pixel rows: `legs.strike_signals`) without telling the legs apart, less its flow (`off_flow`):+ `says` `cycles` where the line left ranges BOB_FLOOR of the body's median `height` or more and BOB_ROWS rows or+ more, and it is as it was half an interval on and turned over a quarter on (`crossings.correlation_on`, BOB_TWICE or+ over there and -BOB_TWICE or under here) — a step each rise, two steps an interval; None otherwise, with why.+ Returns the record: `swing` (the line left's range, of the body's height), `rows` (in rows), `floor`, `twice`,+ `half` and `quarter` (where read), `says`."""+ values = off_flow(top, interval)+ rows = float(values.max()-values.min()) if values.size else 0.0+ swing = rows/height if height > 0 else 0.0+ word = {'swing': round(swing, 4), 'rows': round(rows, 2), 'floor': BOB_FLOOR, 'twice': BOB_TWICE}+ if not values.size:+ return {**word, 'says': None, 'why': "its top line less its flow is not read: the clip is under an interval long"}+ if swing < BOB_FLOOR or rows < BOB_ROWS:+ return {**word, 'says': None, 'why': f"its top line's range less its flow ({swing:.2%} of the body's height, {rows:.1f} "+ f"rows) is under {BOB_FLOOR:.1%} or {BOB_ROWS} rows: it does not rise and fall"}+ half, quarter = (crossings_mod.correlation_on(values, interval/k) for k in (2, 4))+ word.update(half=None if half is None else round(half, 3), quarter=None if quarter is None else round(quarter, 3))+ if half is not None and quarter is not None and half >= BOB_TWICE and quarter <= -BOB_TWICE:return {**word, 'says': 'cycles'}- 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})"}+ return {**word, 'says': None, 'why': f"its top line less its flow does not rise and fall twice an interval "+ f"({'not read' if half is None else f'{half:+.2f}'} half an interval on, "+ f"{'not read' if quarter is None else f'{quarter:+.2f}'} a quarter on: not at least "+ f"{BOB_TWICE:+g} and at most {-BOB_TWICE:+g})"}def read_cycles(reading, distances, *, view=None, cue=None, cue_step=None, signals=None):@@ -563,10 +591,11 @@ def read_cycles(reading, distances, *, view=None, cue=None, cue_step=None, signaThe picture is the same a step on as a cycle on where the legs are drawn alike, and so is everything else that doesnot tell the legs apart (a foot cue under a light fixed on the screen, how far apart the feet are drawn): it markscycles 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+ `legs.strike_signals`: `top`, and `height`) rising and falling twice an interval, less its flow (`bob_word`: the+ picture drifting or swaying up and down as it pleases witnesses nothing). 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, Nonewhere it is not asked."""if reading.mode != 'gap' or not reading.readable:return None@@ -595,9 +624,9 @@ def read_cycles(reading, distances, *, view=None, cue=None, cue_step=None, signasaid.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")+ said.update(cycles=True, why=f"{picture}, and the body's top line less its flow rises and falls twice an interval "+ f"({bob['half']:+.2f} half an interval on, at least {BOB_TWICE:+g}; {bob['quarter']:+.2f} a "+ f"quarter on, at most {-BOB_TWICE:+g}): two steps an interval, the feet meet once a cycle")else:said.update(cycles=False, unwitnessed=True,why=f"{picture}, but nothing that reads no leg witnesses two steps an interval "diff --git a/tests/video/test_walk_steps.py b/tests/video/test_walk_steps.pyindex 57ff63b..19ddd9f 100644--- a/tests/video/test_walk_steps.py+++ b/tests/video/test_walk_steps.py@@ -134,17 +134,18 @@ def _outward(k: float, *, cycle: float, bob: int = 3) -> 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, lift: int = 0, light: tuple[str, int] | None = None) -> Image.Image:+ leg_half: int = 5, lift: int = 0, light: tuple[str, int] | None = None, bob: int = 3) -> 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 10the 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`)."""+ forward is lifted up to `lift` px, most at its pass; `light` lays a light fixed on the screen over the legs+ (`_lit`). The body bobs `bob` px once a step."""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))+ x, y = 90, 40 + round(bob * 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))@@ -176,6 +177,23 @@ def _lit(im: Image.Image, legs_drawn: Image.Image, light: tuple[str, int] | Nonereturn Image.fromarray(a)+def _carried(draw, motion: str, room: int = 60):+ """`draw`'s walker carried up and down the screen with the whole picture (a motion of the picture, not the walk's)+ on a canvas `room` px taller either side: `"arc"` along a smooth arc, 24 px down at either end of the 73 frames+ and level in the middle; `"cubic"` from 48 px up at the start to 48 down at the end, still in the middle;+ `"sway"` 12 px down, level, 12 up and back every 92 frames; `"ramp"` 24 px down over the clip, a row every three+ frames."""+ move = {"arc": lambda k: round(24 * ((k - 36) / 36) ** 2), "cubic": lambda k: round(48 * ((k - 36) / 36) ** 3),+ "sway": lambda k: round(12 * math.sin(2 * math.pi * k / 92)), "ramp": lambda k: round(24 * k / 72)}[motion]++ def frame(k: int) -> Image.Image:+ im = draw(k)+ out = Image.new("RGBA", (im.width, im.height + 2 * room))+ out.paste(im, (0, room + move(k)))+ return out+ return frame++def _tailed(k: int) -> Image.Image:"""A side walker on threes, 30 frames a cycle, its legs hurrying through each pass and slowing apart, with a bigtail swinging on a beat of its own (34 frames); each repeat of a drawing redrawn a few tones."""@@ -511,6 +529,40 @@ def test_a_wide_walk_whose_far_leg_is_drawn_a_few_tones_off_is_cut_two_steps(tmpassert not any(local_cycle.UNWITNESSED in w for w in report["jolt"]["warnings"])[email protected]("motion, bob, room", [("arc", 3, 0), ("arc", 0, 60), ("sway", 0, 60), ("ramp", 0, 60)])+def test_a_walk_whose_crossings_are_its_steps_carried_up_and_down_is_cut_two_steps(tmp_path, motion, bob, room):+ """The wide walker with its legs drawn alike, carried up and down the screen with the whole picture (`_carried`;+ its legs, their steps and their crossings every 23 frames as they were): bobbing, along a smooth arc 24 px deep;+ its body held still, along the same arc, a sway 12 px either way four intervals long, and a ramp 24 px down a row+ every three frames. None of it is the body rising and falling twice an interval: less its flow the bobbing+ walker's top line rises and falls once an interval, turned over half an interval on, and the still one's moves+ under BOB_ROWS (its rows rounding up and down as the picture drifts). Nothing witnesses two steps an interval: two+ steps, 46 frames, a warning (the parent engine read the flow's own likeness half an interval on as the body rising+ and falling twice an interval and cut each one step, counted two, and no warning said so)."""+ walker = lambda k: _alike(k, cycle=46, phase=13, tone=4, lean=1, leg_tone=0, leg_half=10, bob=bob) # noqa: E731+ report = _cut(tmp_path / "out", _keyed(tmp_path, _carried(walker, motion, room)))+ _two_steps(report, 46)+ said = _unwitnessed(report, 23)+ assert said["asked"].startswith("the feet together")+ if bob:+ assert said["bob"]["half"] <= -local_cycle.BOB_TWICE+ else:+ assert said["bob"]["rows"] < local_cycle.BOB_ROWS and "does not rise and fall" in said["bob"]["why"]++[email protected]("motion, room", [("arc", 0), ("cubic", 60)])+def test_a_walk_whose_feet_meet_once_a_cycle_carried_up_and_down_is_cut_one_cycle(tmp_path, motion, room):+ """The walker whose far foot passes hidden, its legs drawn alike, carried along the arc or the cubic with the+ whole picture: less its flow its top line rises and falls twice an interval as it did with the picture still,+ one cycle."""+ walker = lambda k: _behind(k, cycle=17.5, hold=1, alike=True) # noqa: E731+ _cut(tmp_path / "out", _keyed(tmp_path, _carried(walker, motion, room)))+ said = _one_cycle(tmp_path / "out", 17.5)["cycles"]+ assert said["bob"]["says"] == "cycles" and said["bob"]["quarter"] <= -local_cycle.BOB_TWICE++@pytest.mark.slowdef test_a_cut_of_two_steps_that_does_not_close_leaves_the_searchs_cut(tmp_path):"""On threes, a big tail on its own beat: the search's cut is one the count does not refute (it plays feet held@@ -754,17 +806,58 @@ def test_a_cue_that_does_not_tell_the_legs_apart_leaves_the_word_to_the_body(vie@pytest.mark.parametrize("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."""+ every 7.5 frames (twice an interval: as it was half an interval on, turned over a quarter on) witnesses two steps+ an interval; every 15 (once: a step an interval, turned over half an interval on) or every 30 (once a cycle of two+ intervals: a quarter turn half an interval on, and much of it taken out as flow) does not; 0.2 rows either way, its+ range under BOB_FLOOR of the body's height and under BOB_ROWS rows, does not rise and fall, however it correlates."""t = np.arange(FRAMES)- word = local_cycle.bob_word(list(40 + swing * np.cos(2 * np.pi * t / beat)), 15, height=100)+ line = list(40 + swing * np.cos(2 * np.pi * t / beat))+ word = local_cycle.bob_word(line, 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)+ left = local_cycle.off_flow(line, 15)+ assert word["swing"] == pytest.approx(np.ptp(left) / 100, abs=1e-4)+ assert word["rows"] == pytest.approx(np.ptp(left), abs=0.01)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")+ elif beat < 30:+ twice = word["half"] >= local_cycle.BOB_TWICE and word["quarter"] <= -local_cycle.BOB_TWICE+ assert twice is (says == "cycles")++[email protected]("flow", ["still", "arc", "cubic", "sway", "ramp"])[email protected]("beat", [7.5, 15, None])+def test_the_body_is_read_less_the_flow_of_the_picture(beat, flow):+ """`bob_word` on an interval of 15 frames, the body 100 rows tall, its top line read in whole rows: rising and+ falling 3 rows either way twice an interval (every 7.5 frames), once (every 15) or not at all, on a picture held+ still or carried up and down with the line: along an arc 24 rows deep, a cubic 48 rows either way, a sway 12 rows+ either way four intervals long, a ramp of 6 rows over the clip. Less its flow the line is the body's own: twice an+ interval witnesses two steps an interval wherever the picture goes, and once or not at all never does; a line that+ does not rise and fall is left under BOB_ROWS by the picture drifting in whole rows."""+ t = np.arange(FRAMES)+ flows = {"still": 0 * t, "arc": 24 * ((t - 36) / 36) ** 2, "cubic": 48 * ((t - 36) / 36) ** 3,+ "sway": 12 * np.sin(2 * np.pi * t / 60), "ramp": 6 * t / 72}+ top = np.round(40 + (0 if beat is None else 3 * np.cos(2 * np.pi * t / beat)) + flows[flow])+ word = local_cycle.bob_word(list(top), 15, height=100)+ assert (word["says"] == "cycles") is (beat == 7.5)+ if beat is None and flow != "sway":+ assert word["rows"] < local_cycle.BOB_ROWS and "does not rise and fall" in word["why"]+++def test_the_flow_taken_out_leaves_a_rise_and_fall_once_or_twice_an_interval_whole():+ """`off_flow` over an interval of 15 frames (and of 17.5, its end frames a quarter weighted): a cubic flow is taken+ out wholly, and a rise and fall once or twice an interval laid on it is left as it was, over the frames the+ interval fits about (7 either end; 9 at 17.5), less its straight line."""+ t = np.arange(FRAMES)+ flow = 48 * ((t - 36) / 36) ** 3 - 5 * t / 72 + 40+ for interval, reach in ((15, 7), (17.5, 9)):+ for beat in (interval, interval / 2):+ rise = 3 * np.cos(2 * np.pi * t / beat)+ left = local_cycle.off_flow(list(flow + rise), interval)+ assert left.size == FRAMES - 2 * reach+ inner, u = rise[reach:FRAMES - reach], np.arange(FRAMES - 2 * reach)+ whole = inner - np.polyval(np.polyfit(u, inner, 1), u)+ assert np.max(np.abs(left - whole)) < (1e-9 if interval == 15 else 0.05)+ assert np.max(np.abs(local_cycle.off_flow(list(flow), interval))) < 1e-9@pytest.mark.parametrize("verdict, named", [("uncertain", True), ("two", False)])