rohitg00/ai-engineering-from-scratch · error · ValueError

quantile must be between zero and one

Error message

quantile must be between zero and one

What it means

Error "quantile must be between zero and one" thrown in rohitg00/ai-engineering-from-scratch.

Source

Thrown at certifications/claude/lessons/14-evals-testing-debugging-and-observability/code/main.py:95


def classify_error(exc: Exception) -> str:
    if isinstance(exc, TimeoutError):
        return "transport_timeout"
    if isinstance(exc, PermissionError):
        return "policy_denial"
    if isinstance(exc, json.JSONDecodeError):
        return "contract_parse_error"
    if isinstance(exc, ValueError):
        return "application_validation_error"
    return "unexpected_application_error"


def percentile(values: list[float], quantile: float) -> float:
    if not values:
        return 0.0
    if not 0 <= quantile <= 1:
        raise ValueError("quantile must be between zero and one")
    ordered = sorted(values)
    index = round((len(ordered) - 1) * quantile)
    return ordered[index]


def validate_release_gate(gate: dict[str, Any]) -> list[str]:
    """Validate severe-case, regression, trace, and failure-class coverage."""
    errors: list[str] = []
    thresholds = gate.get("thresholds")
    required_thresholds = {
        "severeCasePassRate",
        "maximumOverallRegressionPoints",
        "maximumSliceRegressionPoints",
        "maximumP95LatencyIncreasePercent",
        "maximumMeanCostIncreasePercent",
    }
    if not isinstance(thresholds, dict) or required_thresholds - set(thresholds):
        errors.append("thresholds are incomplete")

View on GitHub (pinned to 39ea8a1c6d)

When it happens

Trigger: Thrown at certifications/claude/lessons/14-evals-testing-debugging-and-observability/code/main.py:95 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/b74e03755d312434. Report an issue: GitHub.