'Construct an AveragePrecisionCalculator to calculate average precision.
This class is used to calculate the average precision for a single label.
Args:
top_n: A positive Integer specifying the average precision at n, or
None to use all provided data points.
Raises:
ValueError: An error occurred when the top_n is not a positive integer.'

def __init__(self, top_n=None):

    if (not ((isinstance(top_n, int) and (top_n >= 0)) or (top_n is None))):
        raise ValueError('top_n    must    be    a    positive    integer    or    None.')
    self._top_n = top_n
    self._total_positives = 0
    self._heap = []
