commaai/openpilot · error · ValueError
Time/value arrays must have the same shape, got {result_t.sh
Error message
Time/value arrays must have the same shape, got {result_t.shape} and {result_v.shape} What it means
The evaluated result's time array and value array must have identical 1-D shapes after np.asarray(...).reshape(-1). Mismatched lengths mean the values cannot be aligned to timestamps, so writing the output vector pair would corrupt the timeseries. The message includes both shapes to make the mismatch obvious.
Source
Thrown at openpilot/tools/jotpluggler/math_eval.py:133
with open(code_path, encoding="utf-8") as f:
user_code = f.read()
result = _evaluate_user_code(user_code, env)
if isinstance(result, tuple) and len(result) == 2:
result_t, result_v = result
else:
if first_path is None:
raise ValueError("No reference series found. Set an input timeseries or return (times, values).")
result_t = series_t[first_path]
result_v = result
result_t = np.asarray(result_t, dtype=np.float64).reshape(-1)
result_v = np.asarray(result_v, dtype=np.float64).reshape(-1)
if result_t.size == 0 or result_v.size == 0:
raise ValueError("Custom series returned an empty result")
if result_t.shape != result_v.shape:
raise ValueError(f"Time/value arrays must have the same shape, got {result_t.shape} and {result_v.shape}")
_write_vector(out_t_path, result_t)
_write_vector(out_v_path, result_v)
return 0
if __name__ == "__main__":
try:
raise SystemExit(main())
except Exception as err:
traceback.print_exc()
raise SystemExit(1) from err
View on GitHub (pinned to 516ec1e682)
Solutions
- Make both arrays derive from the same source: slice/mask times and values with the identical mask
- If lengths differ by design, resample one to the other (np.interp) before returning
- Print both shapes in the code file to spot the divergence point
Example fix
# before return (series_t['a'], series_v['b']) # different lengths # after mask = series_t['a'] >= 0 return (series_t['a'][mask], np.interp(series_t['a'][mask], series_t['b'], series_v['b']))
Defensive patterns
Strategy: validation
Validate before calling
t = np.asarray(result_t, dtype=np.float64).reshape(-1)
v = np.asarray(result_v, dtype=np.float64).reshape(-1)
assert t.shape == v.shape, f"times {t.shape} vs values {v.shape} - align arrays before writing" Type guard
def aligned_timeseries(t, v) -> bool:
"""True when time and value arrays are same-length 1-D float arrays."""
t, v = np.asarray(t), np.asarray(v)
return t.ndim == 1 and v.ndim == 1 and t.shape == v.shape Try / catch
try:
_write_vector(out_t_path, result_t)
_write_vector(out_v_path, result_v)
except ValueError as e:
if 'same shape' in str(e):
raise SystemExit('time/value length mismatch - apply the same mask to both arrays')
raise Prevention
- Apply identical masks/slices to times and values in metric code; never slice only one
- When combining series, np.interp values onto the chosen timebase before returning
When it happens
Trigger: Returning (times, values) where values was computed from a differently-sized array (e.g. times from series A, values from a resampled/filtered series B); returning a tuple whose elements come from different inputs; off-by-one from slicing one array but not the other.
Common situations: Mixing two input series of different lengths in one expression; computing values on a masked array but keeping unmasked times; interpolation changing length of only one array.
Related errors
- No reference series found. Set an input timeseries or return
- Custom series returned an empty result
- Function body is empty
- bundled firmware is {expected_product!r}, expected version {
- cannot recover from the ROM bootloader without a config back
AI-assisted analysis of commaai/openpilot@516ec1e682 (2026-08-15).
Data as JSON: /api/errors/9c2b6d3725f0d823.
Report an issue: GitHub.