Helixbench / evaluation /src /helixbench /engines /consecutive_valid.py
Jiaming141's picture
Expose AV-only metadata and browsable evaluation source
765160f verified
Raw History Blame Contribute Delete
783 Bytes
"""Spatial v2 eligibility: consecutive valid 10 Hz samples, not total count."""
import math
PROTOCOL = 'spatial_consecutive4_v2'
def longest_valid_run(valid, times, fps=10.0):
flags=list(valid); timestamps=list(times)
if len(flags)!=len(timestamps) or fps<=0:
raise ValueError('invalid mask/timestamp lengths or fps')
longest=run=0
previous=None
for flag,t in zip(flags,timestamps):
t=float(t)
if not math.isfinite(t) or (previous is not None and t<=previous):
raise ValueError('timestamps must be finite and strictly increasing')
adjacent=previous is None or abs((t-previous)-1.0/fps)<=1e-6
run=(run+1 if adjacent else 1) if flag else 0
longest=max(longest,run)
previous=t
return longest