MCPcopy Create free account
hub / github.com/smacke/ffsubsync / test_fit_assembles_sparse_signal

Function test_fit_assembles_sparse_signal

tests/test_multi_segment.py:63–79  ·  view source on GitHub ↗
(monkeypatch)

Source from the content-addressed store, hash-verified

61
62
63def test_fit_assembles_sparse_signal(monkeypatch):
64 _stub_probe(monkeypatch, 120.0)
65 t = _transformer(segment_count=3, segment_duration=10)
66 # each segment returns a constant-1 window; everything else stays zero
67 monkeypatch.setattr(
68 t, "_extract_segment_speech", lambda fname, start: (start, np.ones(10 * SR))
69 )
70 t.fit("ref.mkv")
71 speech = t.transform()
72 assert len(speech) == int(120 * SR) + 2
73 starts = t._segment_starts(120.0)
74 for s in starts:
75 assert np.all(speech[s * SR : s * SR + 10 * SR] == 1.0)
76 # a point well outside any sampled window is zero
77 gap = starts[0] * SR + 10 * SR + 5
78 if gap < starts[1] * SR:
79 assert speech[gap] == 0.0
80
81
82def test_fit_tolerates_partial_segment_failures(monkeypatch):

Callers

nothing calls this directly

Calls 5

_stub_probeFunction · 0.85
_segment_startsMethod · 0.80
_transformerFunction · 0.70
fitMethod · 0.45
transformMethod · 0.45

Tested by

no test coverage detected