paces 0.0.25__tar.gz → 0.0.26__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. {paces-0.0.25 → paces-0.0.26}/PKG-INFO +1 -1
  2. {paces-0.0.25 → paces-0.0.26}/paces/ask.py +16 -0
  3. {paces-0.0.25 → paces-0.0.26}/paces/ask_contract.py +8 -1
  4. {paces-0.0.25 → paces-0.0.26}/paces/data/ask/ask.js +12 -1
  5. {paces-0.0.25 → paces-0.0.26}/pyproject.toml +1 -1
  6. {paces-0.0.25 → paces-0.0.26}/tests/test_ask.py +37 -0
  7. {paces-0.0.25 → paces-0.0.26}/.gitignore +0 -0
  8. {paces-0.0.25 → paces-0.0.26}/LICENSE +0 -0
  9. {paces-0.0.25 → paces-0.0.26}/README.md +0 -0
  10. {paces-0.0.25 → paces-0.0.26}/docs/README.md +0 -0
  11. {paces-0.0.25 → paces-0.0.26}/docs/alignment/README.md +0 -0
  12. {paces-0.0.25 → paces-0.0.26}/docs/poc-reference/README.md +0 -0
  13. {paces-0.0.25 → paces-0.0.26}/docs/poc-reference/artifacts/clips.json +0 -0
  14. {paces-0.0.25 → paces-0.0.26}/paces/__init__.py +0 -0
  15. {paces-0.0.25 → paces-0.0.26}/paces/__main__.py +0 -0
  16. {paces-0.0.25 → paces-0.0.26}/paces/bodies/__init__.py +0 -0
  17. {paces-0.0.25 → paces-0.0.26}/paces/bodies/_base.py +0 -0
  18. {paces-0.0.25 → paces-0.0.26}/paces/bodies/derivation.py +0 -0
  19. {paces-0.0.25 → paces-0.0.26}/paces/bodies/document.py +0 -0
  20. {paces-0.0.25 → paces-0.0.26}/paces/bodies/signal.py +0 -0
  21. {paces-0.0.25 → paces-0.0.26}/paces/bodies/step.py +0 -0
  22. {paces-0.0.25 → paces-0.0.26}/paces/corrections.py +0 -0
  23. {paces-0.0.25 → paces-0.0.26}/paces/cues.py +0 -0
  24. {paces-0.0.25 → paces-0.0.26}/paces/data/ask/ask.css +0 -0
  25. {paces-0.0.25 → paces-0.0.26}/paces/data/ask/ask.html +0 -0
  26. {paces-0.0.25 → paces-0.0.26}/paces/derivation.py +0 -0
  27. {paces-0.0.25 → paces-0.0.26}/paces/edits.py +0 -0
  28. {paces-0.0.25 → paces-0.0.26}/paces/evidence.py +0 -0
  29. {paces-0.0.25 → paces-0.0.26}/paces/excerpts.py +0 -0
  30. {paces-0.0.25 → paces-0.0.26}/paces/measure.py +0 -0
  31. {paces-0.0.25 → paces-0.0.26}/paces/model.py +0 -0
  32. {paces-0.0.25 → paces-0.0.26}/paces/pose.py +0 -0
  33. {paces-0.0.25 → paces-0.0.26}/paces/projection.py +0 -0
  34. {paces-0.0.25 → paces-0.0.26}/paces/render.py +0 -0
  35. {paces-0.0.25 → paces-0.0.26}/paces/segmentation.py +0 -0
  36. {paces-0.0.25 → paces-0.0.26}/paces/segmenters.py +0 -0
  37. {paces-0.0.25 → paces-0.0.26}/paces/timed_text.py +0 -0
  38. {paces-0.0.25 → paces-0.0.26}/paces/tools.py +0 -0
  39. {paces-0.0.25 → paces-0.0.26}/tests/audio_synth.py +0 -0
  40. {paces-0.0.25 → paces-0.0.26}/tests/data/body_schemas.json +0 -0
  41. {paces-0.0.25 → paces-0.0.26}/tests/data/routine.json +0 -0
  42. {paces-0.0.25 → paces-0.0.26}/tests/poc_fixture.py +0 -0
  43. {paces-0.0.25 → paces-0.0.26}/tests/test_chapters.py +0 -0
  44. {paces-0.0.25 → paces-0.0.26}/tests/test_cli_surface.py +0 -0
  45. {paces-0.0.25 → paces-0.0.26}/tests/test_corrections.py +0 -0
  46. {paces-0.0.25 → paces-0.0.26}/tests/test_cues.py +0 -0
  47. {paces-0.0.25 → paces-0.0.26}/tests/test_derivation.py +0 -0
  48. {paces-0.0.25 → paces-0.0.26}/tests/test_edit_protection_residuals.py +0 -0
  49. {paces-0.0.25 → paces-0.0.26}/tests/test_edits.py +0 -0
  50. {paces-0.0.25 → paces-0.0.26}/tests/test_evidence.py +0 -0
  51. {paces-0.0.25 → paces-0.0.26}/tests/test_evidence_schemas.py +0 -0
  52. {paces-0.0.25 → paces-0.0.26}/tests/test_excerpts.py +0 -0
  53. {paces-0.0.25 → paces-0.0.26}/tests/test_measure.py +0 -0
  54. {paces-0.0.25 → paces-0.0.26}/tests/test_pose.py +0 -0
  55. {paces-0.0.25 → paces-0.0.26}/tests/test_render_media.py +0 -0
  56. {paces-0.0.25 → paces-0.0.26}/tests/test_roundtrip_poc.py +0 -0
  57. {paces-0.0.25 → paces-0.0.26}/tests/test_segment.py +0 -0
  58. {paces-0.0.25 → paces-0.0.26}/tests/test_smoke.py +0 -0
  59. {paces-0.0.25 → paces-0.0.26}/tests/test_vertical_slice.py +0 -0
  60. {paces-0.0.25 → paces-0.0.26}/tests/video_synth.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: paces
3
- Version: 0.0.25
3
+ Version: 0.0.26
4
4
  Summary: Turn instructional media into structured, interactive learning material
5
5
  Project-URL: Homepage, https://github.com/thorwhalen/paces
6
6
  Project-URL: Repository, https://github.com/thorwhalen/paces
@@ -85,6 +85,21 @@ def _grid_ticks(seg: Segmentation, lo: float, hi: float, *, limit: int) -> list[
85
85
  return [time_str(origin + n * spu) for n in range(first, last + 1)]
86
86
 
87
87
 
88
+ def _meets(seg: Segmentation, cut: str) -> bool:
89
+ """Whether one step ends at ``cut`` and another begins there (no gap).
90
+
91
+ Unnamed segmentations (no steps) are spans between cuts, so every cut meets.
92
+
93
+ >>> from paces.segmenters import segment
94
+ >>> propose(segment(boundaries=[0, 10, 20]))["cutMeets"]
95
+ [True]
96
+ """
97
+ if not seg.steps:
98
+ return True
99
+ spans = [(time_str(a), time_str(b)) for step in seg.steps for a, b in step.spans]
100
+ return any(b == cut for _, b in spans) and any(a == cut for a, _ in spans)
101
+
102
+
88
103
  def propose(
89
104
  seg: Segmentation,
90
105
  *,
@@ -129,6 +144,7 @@ def propose(
129
144
  k_evidence=why,
130
145
  extent=tuple(time_str(t) for t in extent) if extent else None,
131
146
  cuts=[time_str(t) for t in interior],
147
+ cut_meets=[_meets(seg, time_str(t)) for t in interior],
132
148
  steps=[
133
149
  ProposedStep(
134
150
  id=step.id,
@@ -50,7 +50,13 @@ class Snap(_Wire):
50
50
 
51
51
 
52
52
  class Proposal(_Wire):
53
- """What the machine pre-computes for a human to confirm (:func:`paces.ask.propose`)."""
53
+ """What the machine pre-computes for a human to confirm (:func:`paces.ask.propose`).
54
+
55
+ ``cut_meets`` is aligned with ``cuts``: ``True`` where one step ends and
56
+ another begins (so striking the cut merges them), ``False`` at the edge of a
57
+ gap between steps, where there is nothing to merge. Empty (an older proposal)
58
+ reads as all ``True``.
59
+ """
54
60
 
55
61
  kind: Literal["PacesAskProposal"] = PROPOSAL_KIND
56
62
  version: Literal[1] = CONTRACT_VERSION
@@ -63,6 +69,7 @@ class Proposal(_Wire):
63
69
  k_evidence: str
64
70
  extent: tuple[str, str] | None
65
71
  cuts: list[str]
72
+ cut_meets: list[bool] = []
66
73
  steps: list[ProposedStep]
67
74
  min_step_s: str
68
75
  snap: Snap
@@ -84,6 +84,13 @@ function nearest(values, t) {
84
84
 
85
85
  const same = (state, message = "") => ({ state, message });
86
86
 
87
+ /** True unless the proposal says no two steps meet at this cut (the edge of a gap). */
88
+ const meets = (proposal, cut) => !proposal.cutMeets || proposal.cutMeets[proposal.cuts.indexOf(cut)] !== false;
89
+
90
+ /** The steps have gaps, so a time between two steps belongs to none. */
91
+ const inGap = (proposal, t) =>
92
+ proposal.steps.length > 0 && !proposal.steps.some((step) => step.spans.some(([a, b]) => Number(a) <= t && t <= Number(b)));
93
+
87
94
  // One rule per action: (proposal, state, action) -> { state, message, fresh? }.
88
95
  // A refusal returns the same state and says why.
89
96
  const RULES = {
@@ -104,6 +111,7 @@ const RULES = {
104
111
  return same(s, `Not added: ${at} is outside the part being checked (${mmss(lo)}–${mmss(hi)}).`);
105
112
  }
106
113
  }
114
+ if (inGap(p, t)) return same(s, `Not added: ${at} falls in a gap between steps, where no step spans that time.`);
107
115
  const inside = absentSpans(p, s).find(([a, b]) => a < t && t < b);
108
116
  if (inside) {
109
117
  return same(s, `Not added: ${at} is inside a step you marked as not in the video (${mmss(inside[0])}–${mmss(inside[1])}).`);
@@ -118,6 +126,7 @@ const RULES = {
118
126
 
119
127
  strike(p, s, { cut }) {
120
128
  if (!p.cuts.includes(cut) || s.struck.includes(cut)) return same(s);
129
+ if (!meets(p, cut)) return same(s, `No two steps meet at ${mmss(cut)} (it is the edge of a gap), so there is nothing to merge.`);
121
130
  const t = Number(cut);
122
131
  const border = p.steps.find(
123
132
  (step, i) => isAbsent(s, i) && step.spans.some((span) => span.map(Number).includes(t)),
@@ -248,7 +257,7 @@ function buildAnswers(proposal, state) {
248
257
 
249
258
  /** Each cut the page lists: proposed (maybe struck) and added, in time order. */
250
259
  function cutRows(proposal, state) {
251
- const rows = proposal.cuts.map((t) => ({ t, kind: state.struck.includes(t) ? "struck" : "proposed" }));
260
+ const rows = proposal.cuts.map((t) => ({ t, kind: state.struck.includes(t) ? "struck" : "proposed", meets: meets(proposal, t) }));
252
261
  for (const t of new Set(state.added)) if (!proposal.cuts.includes(t)) rows.push({ t, kind: "added" });
253
262
  return rows.sort((a, b) => byTime(a.t, b.t));
254
263
  }
@@ -408,6 +417,8 @@ function startPage(doc) {
408
417
  if (row.kind === "added") {
409
418
  li.append(button("Remove", () => dispatch({ type: "remove", cut: row.t })));
410
419
  li.lastChild.dataset.focusKey = `act:${row.t}`;
420
+ } else if (!row.meets) {
421
+ label.textContent = "edge of a gap";
411
422
  } else {
412
423
  const struck = row.kind === "struck";
413
424
  li.append(button(struck ? "Keep it" : "Not a cut", () => dispatch({ type: struck ? "keep" : "strike", cut: row.t })));
@@ -6,7 +6,7 @@ build-backend = "hatchling.build"
6
6
 
7
7
  [project]
8
8
  name = "paces"
9
- version = "0.0.25"
9
+ version = "0.0.26"
10
10
  description = "Turn instructional media into structured, interactive learning material"
11
11
  readme = "README.md"
12
12
  license = "MIT"
@@ -553,3 +553,40 @@ def test_the_contract_is_declared_as_models():
553
553
  assert schemas["proposal"]["properties"]["minStepS"]["type"] == "string"
554
554
  assert schemas["answers"]["additionalProperties"] is False
555
555
  assert AnswersDocument.model_validate(_answers()).k == 4
556
+
557
+
558
+ def test_a_gap_cut_does_not_meet():
559
+ seg = segment(boundaries=[0, 10, 30], steps=["a", "b"])
560
+ assert propose(seg)["cutMeets"] == [True]
561
+ gapped = Segmentation(
562
+ boundaries=(0, 10, 20, 30),
563
+ steps=(
564
+ segment(boundaries=[0, 10, 20, 30], steps=["a", "b", "c"]).steps[0],
565
+ ),
566
+ )
567
+ p = propose(gapped)
568
+ assert p["cuts"] == ["10", "20"] and p["cutMeets"] == [False, False]
569
+
570
+
571
+ @needs_node
572
+ def test_js_refuses_striking_a_gap_edge_and_tapping_a_gap():
573
+ proposal = {
574
+ "k": 2, "extent": ["0", "30"], "cuts": ["10", "20"], "cutMeets": [False, True],
575
+ "steps": [
576
+ {"id": "a", "name": "a", "spans": [["0", "10"]]},
577
+ {"id": "b", "name": "b", "spans": [["20", "30"]]},
578
+ ],
579
+ "minStepS": "0.2", "snap": {"windowS": "0", "targets": ["10", "20"]},
580
+ }
581
+ import json as _j
582
+
583
+ out = _run_js(
584
+ f"(() => {{ const p = {_j.dumps(proposal)}; const s = core.freshState(p);"
585
+ "const a = core.reduce(p, s, {type: 'strike', cut: '10'});"
586
+ "const b = core.reduce(p, s, {type: 'tap', t: 15});"
587
+ "const c = core.reduce(p, s, {type: 'tap', t: 25});"
588
+ "return [a.state.struck, a.message, b.state.added, b.message, c.state.added]; })()"
589
+ )
590
+ assert out[0] == [] and "nothing to merge" in out[1]
591
+ assert out[2] == [] and "gap between steps" in out[3]
592
+ assert out[4] == ["25"]
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes