# Path: diffprivlib/tools/quantiles.py
# def percentile(array, percent, epsilon=1.0, bounds=None, axis=None, keepdims=False, accountant=None, **unused_args):
#     r"""
#     Compute the differentially private percentile of the array.
# 
#     This method calls :obj:`.quantile`, where quantile = percentile / 100.
# 
#     Parameters
#     ----------
#     array : array_like
#         Array containing numbers whose percentile is sought.  If `array` is not an array, a conversion is attempted.
# 
#     percent : float or array-like
#         Percentile or list of percentiles sought.  Each percentile must be in [0, 100].  If percent is array-like,
#         percentiles are returned over the flattened array.
# 
#     epsilon : float, default: 1.0
#         Privacy parameter :math:`\epsilon`.  Differential privacy is achieved over the entire output, with epsilon split
#         evenly between each output value.
# 
#     bounds : tuple, optional
#         Bounds of the values of the array, of the form (min, max).
# 
#     axis : None or int or tuple of ints, optional
#         Axis or axes along which a sum is performed.  The default, axis=None, will sum all of the elements of the input
#         array.  If axis is negative it counts from the last to the first axis.
# 
#         If axis is a tuple of ints, a sum is performed on all of the axes specified in the tuple instead of a single
#         axis or all the axes as before.
# 
#     keepdims : bool, default: False
#         If this is set to True, the axes which are reduced are left in the result as dimensions with size one.  With
#         this option, the result will broadcast correctly against the input array.
# 
#         If the default value is passed, then `keepdims` will not be passed through to the `mean` method of sub-classes
#         of `ndarray`, however any non-default value will be.  If the sub-class' method does not implement `keepdims` any
#         exceptions will be raised.
# 
#     accountant : BudgetAccountant, optional
#         Accountant to keep track of privacy budget.
# 
#     Returns
#     -------
#     m : ndarray
#         Returns a new array containing the percentile values.
# 
#     See Also
#     --------
#     numpy.percentile : Equivalent non-private method.
# 
#     quantile, median
# 
#     """
#     warn_unused_args(unused_args)
# 
#     quant = np.asarray(percent) / 100
# 
#     if np.any(quant < 0) or np.any(quant > 1):
#         raise ValueError("Percentiles must be between 0 and 100 inclusive")
# 
#     return quantile(array, quant, epsilon=epsilon, bounds=bounds, axis=axis, keepdims=keepdims, accountant=accountant)


from unittest import TestCase
from diffprivlib.tools.quantiles import percentile
import numpy as np
import pytest




class TestPercentile(TestCase):
    def test_not_none(self):
        mech = percentile
        self.assertIsNotNone(mech)

    def test_bad_percents(self):
        a = np.array([1, 2, 3])
        self.assertRaises(ValueError, percentile, a, -1)

# Path: diffprivlib/tools/quantiles.py
# def percentile(array, percent, epsilon=1.0, bounds=None, axis=None, keepdims=False, accountant=None, **unused_args):
#     r"""
#     Compute the differentially private percentile of the array.
# 
#     This method calls :obj:`.quantile`, where quantile = percentile / 100.
# 
#     Parameters
#     ----------
#     array : array_like
#         Array containing numbers whose percentile is sought.  If `array` is not an array, a conversion is attempted.
# 
#     percent : float or array-like
#         Percentile or list of percentiles sought.  Each percentile must be in [0, 100].  If percent is array-like,
#         percentiles are returned over the flattened array.
# 
#     epsilon : float, default: 1.0
#         Privacy parameter :math:`\epsilon`.  Differential privacy is achieved over the entire output, with epsilon split
#         evenly between each output value.
# 
#     bounds : tuple, optional
#         Bounds of the values of the array, of the form (min, max).
# 
#     axis : None or int or tuple of ints, optional
#         Axis or axes along which a sum is performed.  The default, axis=None, will sum all of the elements of the input
#         array.  If axis is negative it counts from the last to the first axis.
# 
#         If axis is a tuple of ints, a sum is performed on all of the axes specified in the tuple instead of a single
#         axis or all the axes as before.
# 
#     keepdims : bool, default: False
#         If this is set to True, the axes which are reduced are left in the result as dimensions with size one.  With
#         this option, the result will broadcast correctly against the input array.
# 
#         If the default value is passed, then `keepdims` will not be passed through to the `mean` method of sub-classes
#         of `ndarray`, however any non-default value will be.  If the sub-class' method does not implement `keepdims` any
#         exceptions will be raised.
# 
#     accountant : BudgetAccountant, optional
#         Accountant to keep track of privacy budget.
# 
#     Returns
#     -------
#     m : ndarray
#         Returns a new array containing the percentile values.
# 
#     See Also
#     --------
#     numpy.percentile : Equivalent non-private method.
# 
#     quantile, median
# 
#     """
#     warn_unused_args(unused_args)
# 
#     quant = np.asarray(percent) / 100
# 
#     if np.any(quant < 0) or np.any(quant > 1):
#         raise ValueError("Percentiles must be between 0 and 100 inclusive")
# 
#     return quantile(array, quant, epsilon=epsilon, bounds=bounds, axis=axis, keepdims=keepdims, accountant=accountant)


# Path: tests/tools/test_percentile.py
from unittest import TestCase
from diffprivlib.tools.quantiles import percentile
import numpy as np
import pytest





class TestPercentile(TestCase):
    def test_not_none(self):
        mech = percentile
        self.assertIsNotNone(mech)

    def test_bad_percents(self):
        a = np.array([1, 2, 3])
        self.assertRaises(ValueError, percentile, a, -1)

        self.assertRaises(ValueError, percentile, a, 101)