rohitg00/ai-engineering-from-scratch · error · ValueError
n, c >= 0 and k > 0
Error message
n, c >= 0 and k > 0
What it means
Error "n, c >= 0 and k > 0" thrown in rohitg00/ai-engineering-from-scratch.
Source
Thrown at phases/19-capstone-projects/72-code-exec-metric/code/main.py:255
if exit_code not in EXIT_CODES:
exit_code = EXIT_ERROR
if exit_code == EXIT_PASS and passed < total:
exit_code = EXIT_ASSERTION_FAIL
if exit_code == EXIT_ASSERTION_FAIL and passed == total and total > 0:
exit_code = EXIT_PASS
return ExecResult(score, exit_code, passed, total, detail=detail, per_assertion=results)
def score_code_exec(prediction: str, assertions: list[str], timeout_s: float = DEFAULT_TIMEOUT_S) -> float:
code = extract_code(prediction)
if code is None:
return 0.0
return run_candidate(code, assertions, timeout_s=timeout_s).score
def pass_at_k(n: int, c: int, k: int) -> float:
if n < 0 or c < 0 or k <= 0:
raise ValueError("n, c >= 0 and k > 0")
if c > n:
raise ValueError("c cannot exceed n")
if k > n:
return float(c > 0)
if n - c < k:
return 1.0
log_prob = 0.0
for i in range(k):
log_prob += math.log(n - c - i) - math.log(n - i)
return float(1.0 - math.exp(log_prob))
def pass_at_k_estimator(samples: list[list[bool]], ks: list[int]) -> dict[int, float]:
out: dict[int, float] = {}
for k in ks:
per_task = []
for sample in samples:
n = len(sample)View on GitHub (pinned to 39ea8a1c6d)
When it happens
Trigger: Thrown at phases/19-capstone-projects/72-code-exec-metric/code/main.py:255 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of rohitg00/ai-engineering-from-scratch@39ea8a1c6d (2026-08-26).
Data as JSON: /api/errors/dca1888813263a70.
Report an issue: GitHub.