{"record":{"id":"c994706b97b0a8fe","repo":"tensorflow/models","slug":"threshold-must-be-sorted-got","errorCode":null,"errorMessage":"`threshold` must be sorted, got {}","messagePattern":"`threshold` must be sorted, got (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/vision/ops/box_matcher.py","lineNumber":69,"sourceCode":"\n    Args:\n      thresholds: A list of thresholds to classify the matches into different\n        types (e.g. positive or negative or ignored match). The list needs to be\n        sorted, and will be prepended with -Inf and appended with +Inf.\n      indicators: A list of values representing match types (e.g. positive or\n        negative or ignored match). len(`indicators`) must equal to\n        len(`thresholds`) + 1.\n      force_match_for_each_col: If True, ensures that each column is matched to\n        at least one row (which is not guaranteed otherwise if the\n        positive_threshold is high). Defaults to False. If True, all force\n        matched row will be assigned to `indicators[-1]`.\n\n    Raises:\n      ValueError: If `threshold` not sorted,\n        or len(indicators) != len(threshold) + 1\n    \"\"\"\n    if not all([lo <= hi for (lo, hi) in zip(thresholds[:-1], thresholds[1:])]):\n      raise ValueError('`threshold` must be sorted, got {}'.format(thresholds))\n    self.indicators = indicators\n    if len(indicators) != len(thresholds) + 1:\n      raise ValueError('len(`indicators`) must be len(`thresholds`) + 1, got '\n                       'indicators {}, thresholds {}'.format(\n                           indicators, thresholds))\n    thresholds = thresholds[:]\n    thresholds.insert(0, -float('inf'))\n    thresholds.append(float('inf'))\n    self.thresholds = thresholds\n    self._force_match_for_each_col = force_match_for_each_col\n\n  def __call__(self,\n               similarity_matrix: tf.Tensor) -> Tuple[tf.Tensor, tf.Tensor]:\n    \"\"\"Tries to match each column of the similarity matrix to a row.\n\n    Args:\n      similarity_matrix: A float tensor of shape [num_rows, num_cols] or\n        [batch_size, num_rows, num_cols] representing any similarity metric.","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/vision/ops/box_matcher.py#L51-L87","documentation":"Error \"`threshold` must be sorted, got {}\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/vision/ops/box_matcher.py:69 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Sort the threshold list in ascending order before constructing the BoxMatcher.","Sort your configured thresholds, e.g. thresholds=sorted(thresholds)."],"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"}