{"record":{"id":"fd437204af19d027","repo":"tensorflow/models","slug":"n-must-be-none-or-a-positive-integer-it-was-s","errorCode":null,"errorMessage":"n must be 'None' or a positive integer. It was '%s'.","messagePattern":"n must be 'None' or a positive integer\\. It was '(.+?)'\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/projects/yt8m/eval_utils/average_precision_calculator.py","lineNumber":209,"sourceCode":"        positive in the list. If specified, it will be used in calculation.\n\n    Returns:\n      The non-interpolated average precision at n.\n      If n is larger than the length of the ranked list,\n      the average precision will be returned.\n\n    Raises:\n      ValueError: An error occurred when\n      1) the format of the input is not the numpy 1-D array;\n      2) the shape of predictions and actuals does not match;\n      3) the input n is not a positive integer.\n    \"\"\"\n    if len(predictions) != len(actuals):\n      raise ValueError(\"the shape of predictions and actuals does not match.\")\n\n    if n is not None:\n      if not isinstance(n, int) or n <= 0:\n        raise ValueError(\"n must be 'None' or a positive integer.\"\n                         \" It was '%s'.\" % n)\n\n    ap = 0.0\n\n    predictions = numpy.array(predictions)\n    actuals = numpy.array(actuals)\n\n    # add a shuffler to avoid overestimating the ap\n    predictions, actuals = AveragePrecisionCalculator._shuffle(\n        predictions, actuals)\n    sortidx = sorted(\n        range(len(predictions)), key=lambda k: predictions[k], reverse=True)\n\n    if total_num_positives is None:\n      numpos = numpy.size(numpy.where(actuals > 0))\n    else:\n      numpos = total_num_positives\n","sourceCodeStart":191,"sourceCodeEnd":227,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/projects/yt8m/eval_utils/average_precision_calculator.py#L191-L227","documentation":"Error \"n must be 'None' or a positive integer. It was '%s'.\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/projects/yt8m/eval_utils/average_precision_calculator.py:209 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e006f5f0d534913e49c1f1dae87364039fa607e2","analyzedAt":"2026-08-24T14:09:15.576Z","schemaVersion":2},"datasetVersion":"2026-08-24T17:17:21.512Z"}