# Path: py/dynesty/utils.py
# def unitcheck(u, nonbounded=None):
#     """Check whether `u` is inside the unit cube. Given a masked array
#     `nonbounded`, also allows periodic boundaries conditions to exceed
#     the unit cube."""
# 
#     if nonbounded is None:
#         # No periodic boundary conditions provided.
#         return np.min(u) > 0 and np.max(u) < 1
#     else:
#         # Alternating periodic and non-periodic boundary conditions.
#         unb = u[nonbounded]
#         # pylint: disable=invalid-unary-operand-type
#         ub = u[~nonbounded]
#         return (unb.min() > 0 and unb.max() < 1 and ub.min() > -0.5
#                 and ub.max() < 1.5)
# 
# def get_seed_sequence(rstate, nitems):
#     """
#     Return the list of seeds to initialize random generators
#     This is useful when distributing work across a pool
#     """
#     seeds = np.random.SeedSequence(rstate.integers(0, 2**63 - 1,
#                                                    size=4)).spawn(nitems)
#     return seeds
# 
# def get_random_generator(seed=None):
#     """
#     Return a random generator (using the seed provided if available)
#     """
#     return np.random.Generator(np.random.PCG64(seed))


import warnings
import math
import numpy as np
from numpy import linalg
from numpy import cov as mle_cov
from scipy import spatial
from scipy import cluster
from scipy import linalg as lalg
from scipy.special import logsumexp, gammaln
from .utils import unitcheck, get_seed_sequence, get_random_generator
from scipy.cluster.vq import kmeans2

    Parameters
    ----------
    points : `~numpy.ndarray` with shape (npoints, ndim)
        A set of coordinates.

    Returns
    -------
    mell : :class:`MultiEllipsoid` object
        The :class:`MultiEllipsoid` object used to bound the
        collection of points.

    """

    # Calculate the bounding ellipsoid for the points possibly
    # enlarged to a minimum volume.
    ell = bounding_ellipsoid(points)

    # Recursively split the bounding ellipsoid
    ells = _bounding_ellipsoids(points, ell)

    return MultiEllipsoid(ells=ells)


def _bootstrap_points(points, rseed):
    """
    Select the bootstrap set from points.
    Return:
    Tuple with selected, and not-selected points
    """

# Path: py/dynesty/utils.py
# def unitcheck(u, nonbounded=None):
#     """Check whether `u` is inside the unit cube. Given a masked array
#     `nonbounded`, also allows periodic boundaries conditions to exceed
#     the unit cube."""
# 
#     if nonbounded is None:
#         # No periodic boundary conditions provided.
#         return np.min(u) > 0 and np.max(u) < 1
#     else:
#         # Alternating periodic and non-periodic boundary conditions.
#         unb = u[nonbounded]
#         # pylint: disable=invalid-unary-operand-type
#         ub = u[~nonbounded]
#         return (unb.min() > 0 and unb.max() < 1 and ub.min() > -0.5
#                 and ub.max() < 1.5)
# 
# def get_seed_sequence(rstate, nitems):
#     """
#     Return the list of seeds to initialize random generators
#     This is useful when distributing work across a pool
#     """
#     seeds = np.random.SeedSequence(rstate.integers(0, 2**63 - 1,
#                                                    size=4)).spawn(nitems)
#     return seeds
# 
# def get_random_generator(seed=None):
#     """
#     Return a random generator (using the seed provided if available)
#     """
#     return np.random.Generator(np.random.PCG64(seed))


# Path: py/dynesty/bounding.py
import warnings
import math
import numpy as np
from numpy import linalg
from numpy import cov as mle_cov
from scipy import spatial
from scipy import cluster
from scipy import linalg as lalg
from scipy.special import logsumexp, gammaln
from .utils import unitcheck, get_seed_sequence, get_random_generator
from scipy.cluster.vq import kmeans2


    Parameters
    ----------
    points : `~numpy.ndarray` with shape (npoints, ndim)
        A set of coordinates.

    Returns
    -------
    mell : :class:`MultiEllipsoid` object
        The :class:`MultiEllipsoid` object used to bound the
        collection of points.

    """

    # Calculate the bounding ellipsoid for the points possibly
    # enlarged to a minimum volume.
    ell = bounding_ellipsoid(points)

    # Recursively split the bounding ellipsoid
    ells = _bounding_ellipsoids(points, ell)

    return MultiEllipsoid(ells=ells)


def _bootstrap_points(points, rseed):
    """
    Select the bootstrap set from points.
    Return:
    Tuple with selected, and not-selected points
    """

    rstate = get_random_generator(rseed)