# Path: photutils/utils/_optional_deps.py
# def __getattr__(name):


import astropy.units as u
import numpy as np
    import bottleneck as bn
from ..utils._optional_deps import HAS_BOTTLENECK
    array_new = np.moveaxis(array, axis, destination)

    # Collapse the dimensions being operated on into a single dimension
    # so that we can then use axis=0 with the bottleneck functions
    array_new = array_new.reshape((-1,) + array_new.shape[naxis:])

    return array_new


def nanmean(array, axis=None):
    """
    A nanmean function that uses bottleneck if available.
    """
    if HAS_BOTTLENECK:
        if isinstance(axis, tuple):
            array = move_tuple_axes_first(array, axis=axis)
            axis = 0

        if isinstance(array, u.Quantity):
            return array.__array_wrap__(bn.nanmean(array, axis=axis))
        else:
            return bn.nanmean(array, axis=axis)
    else:
        return np.nanmean(array, axis=axis)


def nanmedian(array, axis=None):
    """
    A nanmedian function that uses bottleneck if available.
    """

# Path: photutils/utils/_optional_deps.py
# def __getattr__(name):


# Path: photutils/background/_utils.py
import astropy.units as u
import numpy as np
    import bottleneck as bn
from ..utils._optional_deps import HAS_BOTTLENECK

    array_new = np.moveaxis(array, axis, destination)

    # Collapse the dimensions being operated on into a single dimension
    # so that we can then use axis=0 with the bottleneck functions
    array_new = array_new.reshape((-1,) + array_new.shape[naxis:])

    return array_new


def nanmean(array, axis=None):
    """
    A nanmean function that uses bottleneck if available.
    """
    if HAS_BOTTLENECK:
        if isinstance(axis, tuple):
            array = move_tuple_axes_first(array, axis=axis)
            axis = 0

        if isinstance(array, u.Quantity):
            return array.__array_wrap__(bn.nanmean(array, axis=axis))
        else:
            return bn.nanmean(array, axis=axis)
    else:
        return np.nanmean(array, axis=axis)


def nanmedian(array, axis=None):
    """
    A nanmedian function that uses bottleneck if available.
    """

    if HAS_BOTTLENECK: