# Path: photutils/utils/exceptions.py
# class NoDetectionsWarning(AstropyWarning):
#     """
#     A warning class to indicate no sources were detected.
#     """
# 
# Path: photutils/utils/_misc.py
# def _get_version_info():
#     """
#     Return a dictionary of the installed version numbers for photutils
#     and its dependencies.
# 
#     Returns
#     -------
#     result : dict
#         A dictionary containing the version numbers for photutils and
#         its dependencies.
#     """
#     versions = {'Python': sys.version.split()[0]}
# 
#     packages = ('photutils', 'astropy', 'numpy', 'scipy', 'skimage',
#                 'sklearn', 'matplotlib', 'gwcs', 'bottleneck')
#     for package in packages:
#         try:
#             pkg = __import__(package)
#             version = pkg.__version__
#         except ImportError:
#             version = None
# 
#         versions[package] = version
# 
#     return versions


import warnings
import numpy as np
from astropy.table import QTable
from ..utils.exceptions import NoDetectionsWarning
from ..utils._misc import _get_version_info
    from scipy.ndimage import maximum_filter
        from ..centroids import centroid_sources  # prevents circular import
        data_max = maximum_filter(data, size=box_size, mode='constant',
                                  cval=0.0)

    peak_goodmask = (data == data_max)  # good pixels are True

    if mask is not None:
        mask = np.asanyarray(mask)
        if data.shape != mask.shape:
            raise ValueError('data and mask must have the same shape')
        peak_goodmask = np.logical_and(peak_goodmask, ~mask)

    if border_width is not None:
        for i in range(peak_goodmask.ndim):
            peak_goodmask = peak_goodmask.swapaxes(0, i)
            peak_goodmask[:border_width] = False
            peak_goodmask[-border_width:] = False
            peak_goodmask = peak_goodmask.swapaxes(0, i)

    peak_goodmask = np.logical_and(peak_goodmask, (data > threshold))
    y_peaks, x_peaks = peak_goodmask.nonzero()
    peak_values = data[y_peaks, x_peaks]

    nxpeaks = len(x_peaks)
    if nxpeaks > npeaks:
        idx = np.argsort(peak_values)[::-1][:npeaks]
        x_peaks = x_peaks[idx]
        y_peaks = y_peaks[idx]
        peak_values = peak_values[idx]

    if nxpeaks == 0:

# Path: photutils/utils/exceptions.py
# class NoDetectionsWarning(AstropyWarning):
#     """
#     A warning class to indicate no sources were detected.
#     """
# 
# Path: photutils/utils/_misc.py
# def _get_version_info():
#     """
#     Return a dictionary of the installed version numbers for photutils
#     and its dependencies.
# 
#     Returns
#     -------
#     result : dict
#         A dictionary containing the version numbers for photutils and
#         its dependencies.
#     """
#     versions = {'Python': sys.version.split()[0]}
# 
#     packages = ('photutils', 'astropy', 'numpy', 'scipy', 'skimage',
#                 'sklearn', 'matplotlib', 'gwcs', 'bottleneck')
#     for package in packages:
#         try:
#             pkg = __import__(package)
#             version = pkg.__version__
#         except ImportError:
#             version = None
# 
#         versions[package] = version
# 
#     return versions


# Path: photutils/detection/peakfinder.py
import warnings
import numpy as np
from astropy.table import QTable
from ..utils.exceptions import NoDetectionsWarning
from ..utils._misc import _get_version_info
    from scipy.ndimage import maximum_filter
        from ..centroids import centroid_sources  # prevents circular import

        data_max = maximum_filter(data, size=box_size, mode='constant',
                                  cval=0.0)

    peak_goodmask = (data == data_max)  # good pixels are True

    if mask is not None:
        mask = np.asanyarray(mask)
        if data.shape != mask.shape:
            raise ValueError('data and mask must have the same shape')
        peak_goodmask = np.logical_and(peak_goodmask, ~mask)

    if border_width is not None:
        for i in range(peak_goodmask.ndim):
            peak_goodmask = peak_goodmask.swapaxes(0, i)
            peak_goodmask[:border_width] = False
            peak_goodmask[-border_width:] = False
            peak_goodmask = peak_goodmask.swapaxes(0, i)

    peak_goodmask = np.logical_and(peak_goodmask, (data > threshold))
    y_peaks, x_peaks = peak_goodmask.nonzero()
    peak_values = data[y_peaks, x_peaks]

    nxpeaks = len(x_peaks)
    if nxpeaks > npeaks:
        idx = np.argsort(peak_values)[::-1][:npeaks]
        x_peaks = x_peaks[idx]
        y_peaks = y_peaks[idx]
        peak_values = peak_values[idx]

    if nxpeaks == 0:

        warnings.warn('No local peaks were found.', NoDetectionsWarning)