"""Shared temporal sampling for coaf_dataset_24_25. RGB (I2V target): 24 frames via uniform indices over raw episode steps. Reason modalities + state + action: 25 frames via a separate uniform index array so each reason frame k uses state[k] and action[k] from the same raw timestep. """ from __future__ import annotations import numpy as np RGB_FRAMES = 24 REASON_FRAMES = 25 def sampled_indices(length: int, target: int) -> np.ndarray: """Uniformly sample `target` indices in [0, length - 1].""" if length < 1: raise ValueError(f"length must be >= 1, got {length}") if target < 1: raise ValueError(f"target must be >= 1, got {target}") if length < target: raise ValueError(f"length {length} < target {target}") return np.linspace(0, length - 1, target).astype(np.int64) def rgb_indices(num_steps: int) -> np.ndarray: return sampled_indices(num_steps, RGB_FRAMES) def reason_indices(num_steps: int) -> np.ndarray: return sampled_indices(num_steps, REASON_FRAMES)