MCPcopy Create free account
hub / github.com/Breakthrough/PySceneDetect / test_arithmetic_with_bare_timecode

Function test_arithmetic_with_bare_timecode

tests/test_timecode.py:446–463  ·  view source on GitHub ↗

`FrameTimecode` arithmetic should accept a bare :class:`Timecode` operand by treating it as an absolute time in seconds.

()

Source from the content-addressed store, hash-verified

444
445
446def test_arithmetic_with_bare_timecode():
447 """`FrameTimecode` arithmetic should accept a bare :class:`Timecode` operand by treating
448 it as an absolute time in seconds."""
449 fps = 30.0
450 base = FrameTimecode(timecode=10, fps=fps) # 10 frames @ 30fps == ~0.333s
451 # 1/30s expressed in a 1/1000 time base is pts=33 (rounded).
452 one_frame_at_30 = Timecode(pts=33, time_base=Fraction(1, 1000))
453
454 plus = base + one_frame_at_30
455 assert plus.frame_num == 11
456
457 minus = base - one_frame_at_30
458 assert minus.frame_num == 9
459
460 # Reverse direction: a Timecode-backed FrameTimecode plus a bare Timecode.
461 pts_base = FrameTimecode(timecode=Timecode(pts=1, time_base=Fraction(1, 1000)), fps=fps)
462 pts_plus = pts_base + Timecode(pts=2, time_base=Fraction(1, 1000))
463 assert pts_plus.seconds == pytest.approx(0.003)
464
465
466def test_comparisons_with_bare_timecode():

Callers

nothing calls this directly

Calls 2

FrameTimecodeClass · 0.90
TimecodeClass · 0.90

Tested by

no test coverage detected