def check_pv(pv):
    """
    Check input argument `pv`.

    Parameters
    ----------
    pv : int
        Percentile of the pairwise distance distribution at which to truncate
        during variogram fitting.

    Returns
    -------
    int

    Raises
    ------
    ValueError : `pv` lies outside range (0, 100]

    """
    try:
        pv = int(pv)
    except ValueError:
        raise ValueError("parameter 'pv' must be an integer in (0,100]")
    if pv <= 0 or pv > 100:
        raise ValueError("parameter 'pv' must be in (0,100]")
    return pv