Download evaluation/src/helixbench/engines/consecutive_valid.py from NoizAI/Helixbench: direct link, hf CLI and curl.
- Browser
- Download file 783 Bytes
-
https://huggingface.co/datasets/NoizAI/Helixbench/resolve/main/evaluation/src/helixbench/engines/consecutive_valid.py
- Command line
-
hf download hf://datasets/NoizAI/Helixbench/evaluation/src/helixbench/engines/consecutive_valid.py
-
curl -L -o consecutive_valid.py https://huggingface.co/datasets/NoizAI/Helixbench/resolve/main/evaluation/src/helixbench/engines/consecutive_valid.py
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 | |