def _lv_box_ends(self, vals, k_depth='proportion', outlier_prop=None):
        """Get the number of data points and calculate `depth` of
        letter-value plot."""
        vals = np.asarray(vals)
        vals = vals[np.isfinite(vals)]
        n = len(vals)
        # If p is not set, calculate it so that 8 points are outliers
        if not outlier_prop:
            # Conventional boxplots assume this proportion of the data are
            # outliers.
            p = 0.007
        else:
            if ((outlier_prop > 1.) or (outlier_prop < 0.)):
                raise ValueError('outlier_prop not in range [0, 1]!')
            p = outlier_prop
        # Select the depth, i.e. number of boxes to draw, based on the method
        k_dict = {'proportion': (np.log2(n)) - int(np.log2(n*p)) + 1,
                  'tukey': (np.log2(n)) - 3,
                  'trustworthy': (np.log2(n) -
                                  np.log2(2*stats.norm.ppf((1-p))**2)) + 1}
        k = k_dict[k_depth]
        try:
            k = int(k)
        except __HOLE__:
            k = 1
        # If the number happens to be less than 0, set k to 0
        if k < 1.:
            k = 1
        # Calculate the upper box ends
        upper = [100*(1 - 0.5**(i+2)) for i in range(k, -1, -1)]
        # Calculate the lower box ends
        lower = [100*(0.5**(i+2)) for i in range(k, -1, -1)]
        # Stitch the box ends together
        percentile_ends = [(i, j) for i, j in zip(lower, upper)]
        box_ends = [np.percentile(vals, q) for q in percentile_ends]
        return box_ends, k
dataset/ETHPy150Open mwaskom/seaborn/seaborn/categorical.py/_LVPlotter._lv_box_ends