def _compute_average_precision(self, recall_curve: np.ndarray, precision_curve: np.ndarray):
    assert ((recall_curve.ndim == 1) and (precision_curve.ndim == 1))
    mean_recall = np.concatenate(([0.0], recall_curve, [1.0]))
    mean_precision = np.concatenate(([0.0], precision_curve, [0.0]))
    for i in range((mean_precision.size - 1), 0, (- 1)):
        mean_precision[(i - 1)] = np.maximum(mean_precision[(i - 1)], mean_precision[i])
    i = np.where((mean_recall[1:] != mean_recall[:(- 1)]))[0]
    ap = np.sum(((mean_recall[(i + 1)] - mean_recall[i]) * mean_precision[(i + 1)]))
    return ap
def _compute_average_precision(self, recall_curve: np.ndarray, precision_curve: np.ndarray):
    assert ((recall_curve.ndim == 1) and (precision_curve.ndim == 1))
    mean_recall = np.concatenate(([0.0], recall_curve, [1.0]))
    mean_precision = np.concatenate(([0.0], precision_curve, [0.0]))
    for i in range((mean_precision.size - 1), 0, (- 1)):
        mean_precision[(i - 1)] = np.maximum(mean_precision[(i - 1)], mean_precision[i])
    i = np.where((mean_recall[1:] != mean_recall[:(- 1)]))[0]
    ap = np.sum(((mean_recall[(i + 1)] - mean_recall[i]) * mean_precision[(i + 1)]))
    return ap