commaai/openpilot · error · ValueError
Custom series returned an empty result
Error message
Custom series returned an empty result
What it means
math_eval converts the evaluated result's time and value arrays to float64 1-D arrays and requires both to be non-empty. An empty result means the user's code returned empty arrays (or sliced an input down to nothing), so there is no data to write to the output vector files, and it fails fast.
Source
Thrown at openpilot/tools/jotpluggler/math_eval.py:131
if globals_code.strip():
exec(globals_code, env, env)
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
- Debug the expression: print(len(result_v)) and intermediate masks in the code file to find where rows drop to zero
- Fix the filter/threshold so it selects at least some samples, or guard: 'return src_v[mask] if mask.any() else src_v'
- If an input series is unexpectedly empty, check the input vector files fed to the metric
Example fix
# before
return src_v[src_v > 100.0] # all values below 100 -> empty
# after
mask = src_v > 100.0
if not mask.any():
raise ValueError("no samples above threshold - check units")
return src_v[mask] Defensive patterns
Strategy: validation
Validate before calling
out = np.asarray(result_v if isinstance(result, tuple) else result, dtype=np.float64).reshape(-1)
if out.size == 0:
raise SystemExit('expression produced zero samples - check filters/thresholds and input data') Try / catch
try:
main()
except ValueError as e:
if 'empty result' in str(e):
print('mask kept no samples; loosen filters or verify input vectors')
raise SystemExit(2)
raise Prevention
- Guard masks in metric code: 'if not mask.any(): raise ValueError(diagnostic)' with a specific message
- Sanity-check input vector lengths before running the metric; empty inputs yield empty outputs
When it happens
Trigger: User code returns [], np.array([]), or an empty tuple element; boolean masking that filtered out every sample (e.g. wrong comparison direction); result derived from an empty input series.
Common situations: A filter like src_v[src_v > 100] where no values exceed the threshold; time-window slice outside the data range returning zero rows; upstream input file empty.
Related errors
- No reference series found. Set an input timeseries or return
- Function body is empty
- Time/value arrays must have the same shape, got {result_t.sh
- invalid config backup: {backup}
- No camera file for segment {seg_idx}
AI-assisted analysis of commaai/openpilot@516ec1e682 (2026-08-15).
Data as JSON: /api/errors/91e8d51fd28e4f05.
Report an issue: GitHub.