# Path: photutils/morphology/core.py
# def data_properties(data, mask=None, background=None):
#     """
#     Calculate the morphological properties (and centroid) of a 2D array
#     (e.g., an image cutout of an object) using image moments.
# 
#     Parameters
#     ----------
#     data : array_like or `~astropy.units.Quantity`
#         The 2D array of the image.
# 
#     mask : array_like (bool), optional
#         A boolean mask, with the same shape as ``data``, where a `True`
#         value indicates the corresponding element of ``data`` is masked.
#         Masked data are excluded from all calculations.
# 
#     background : float, array_like, or `~astropy.units.Quantity`, optional
#         The background level that was previously present in the input
#         ``data``.  ``background`` may either be a scalar value or a 2D
#         image with the same shape as the input ``data``.  Inputting the
#         ``background`` merely allows for its properties to be measured
#         within each source segment.  The input ``background`` does *not*
#         get subtracted from the input ``data``, which should already be
#         background-subtracted.
# 
#     Returns
#     -------
#     result : `~photutils.segmentation.SourceCatalog` instance
#         A `~photutils.segmentation.SourceCatalog` object.
#     """
#     # prevent circular imports
#     from ..segmentation import SegmentationImage, SourceCatalog
# 
#     segment_image = SegmentationImage(np.ones(data.shape, dtype=int))
# 
#     if background is not None:
#         background = np.atleast_1d(background)
#         if background.shape == (1,):
#             background = np.zeros(data.shape) + background
# 
#     return SourceCatalog(data, segment_image, mask=mask,
#                          background=background)[0]
# 
# Path: photutils/utils/_optional_deps.py
# def __getattr__(name):


import numpy as np
import pytest
from numpy.testing import assert_allclose
from ..core import data_properties
from ...utils._optional_deps import HAS_SKIMAGE  # noqa
# Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
Tests for the core module.
"""




XCS = [25.7]
YCS = [26.2]
XSTDDEVS = [3.2, 4.0]
YSTDDEVS = [5.7, 4.1]
THETAS = np.array([30., 45.]) * np.pi / 180.
DATA = np.zeros((3, 3))
DATA[0:2, 1] = 1.
DATA[1, 0:2] = 1.
DATA[1, 1] = 2.


@pytest.mark.skipif('not HAS_SKIMAGE')
def test_data_properties():
    data = np.ones((2, 2)).astype(float)
    mask = np.array([[False, False], [True, True]])
    props = data_properties(data, mask=None)

# Path: photutils/morphology/core.py
# def data_properties(data, mask=None, background=None):
#     """
#     Calculate the morphological properties (and centroid) of a 2D array
#     (e.g., an image cutout of an object) using image moments.
# 
#     Parameters
#     ----------
#     data : array_like or `~astropy.units.Quantity`
#         The 2D array of the image.
# 
#     mask : array_like (bool), optional
#         A boolean mask, with the same shape as ``data``, where a `True`
#         value indicates the corresponding element of ``data`` is masked.
#         Masked data are excluded from all calculations.
# 
#     background : float, array_like, or `~astropy.units.Quantity`, optional
#         The background level that was previously present in the input
#         ``data``.  ``background`` may either be a scalar value or a 2D
#         image with the same shape as the input ``data``.  Inputting the
#         ``background`` merely allows for its properties to be measured
#         within each source segment.  The input ``background`` does *not*
#         get subtracted from the input ``data``, which should already be
#         background-subtracted.
# 
#     Returns
#     -------
#     result : `~photutils.segmentation.SourceCatalog` instance
#         A `~photutils.segmentation.SourceCatalog` object.
#     """
#     # prevent circular imports
#     from ..segmentation import SegmentationImage, SourceCatalog
# 
#     segment_image = SegmentationImage(np.ones(data.shape, dtype=int))
# 
#     if background is not None:
#         background = np.atleast_1d(background)
#         if background.shape == (1,):
#             background = np.zeros(data.shape) + background
# 
#     return SourceCatalog(data, segment_image, mask=mask,
#                          background=background)[0]
# 
# Path: photutils/utils/_optional_deps.py
# def __getattr__(name):


# Path: photutils/morphology/tests/test_core.py
import numpy as np
import pytest
from numpy.testing import assert_allclose
from ..core import data_properties
from ...utils._optional_deps import HAS_SKIMAGE  # noqa

# Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
Tests for the core module.
"""




XCS = [25.7]
YCS = [26.2]
XSTDDEVS = [3.2, 4.0]
YSTDDEVS = [5.7, 4.1]
THETAS = np.array([30., 45.]) * np.pi / 180.
DATA = np.zeros((3, 3))
DATA[0:2, 1] = 1.
DATA[1, 0:2] = 1.
DATA[1, 1] = 2.


@pytest.mark.skipif('not HAS_SKIMAGE')
def test_data_properties():
    data = np.ones((2, 2)).astype(float)
    mask = np.array([[False, False], [True, True]])
    props = data_properties(data, mask=None)

    props2 = data_properties(data, mask=mask)