# Path: ccdproc/core.py
# @deprecated('1.1',
#             message='The rebin function will be removed in ccdproc 3.0 '
#                     'Use block_reduce or block_replicate instead.')
# def rebin(ccd, newshape):
#     """
#     Rebin an array to have a new shape.
# 
#     Parameters
#     ----------
#     ccd : `~astropy.nddata.CCDData` or `numpy.ndarray`
#         Data to rebin.
# 
#     newshape : tuple
#         Tuple containing the new shape for the array.
# 
#     Returns
#     -------
#     output : `~astropy.nddata.CCDData` or `numpy.ndarray`
#         An array with the new shape. It will have the same type as the input
#         object.
# 
#     Raises
#     ------
#     TypeError
#         A type error is raised if data is not an `numpy.ndarray` or
#         `~astropy.nddata.CCDData`.
# 
#     ValueError
#         A value error is raised if the dimension of the new shape is not equal
#         to the data's.
# 
#     Notes
#     -----
#     This is based on the scipy cookbook for rebinning:
#     http://wiki.scipy.org/Cookbook/Rebinning
# 
#     If rebinning a CCDData object to a smaller shape, the masking and
#     uncertainty are not handled correctly.
# 
#     Examples
#     --------
#     Given an array that is 100x100::
# 
#         import numpy as np
#         from astropy import units as u
#         arr1 = CCDData(np.ones([10, 10]), unit=u.adu)
# 
#     The syntax for rebinning an array to a shape
#     of (20,20) is::
# 
#         rebin(arr1, (20,20))
#     """
#     # check to see that is in a nddata type
#     if isinstance(ccd, np.ndarray):
# 
#         # check to see that the two arrays are going to be the same length
#         if len(ccd.shape) != len(newshape):
#             raise ValueError('newshape does not have the same dimensions as '
#                              'ccd.')
# 
#         slices = [slice(0, old, old/new) for old, new in
#                   zip(ccd.shape, newshape)]
#         coordinates = np.mgrid[slices]
#         indices = coordinates.astype('i')
#         return ccd[tuple(indices)]
# 
#     elif isinstance(ccd, CCDData):
#         # check to see that the two arrays are going to be the same length
#         if len(ccd.shape) != len(newshape):
#             raise ValueError('newshape does not have the same dimensions as '
#                              'ccd.')
# 
#         nccd = ccd.copy()
#         # rebin the data plane
#         nccd.data = rebin(nccd.data, newshape)
# 
#         # rebin the uncertainty plane
#         if nccd.uncertainty is not None:
#             nccd.uncertainty.array = rebin(nccd.uncertainty.array, newshape)
# 
#         # rebin the mask plane
#         if nccd.mask is not None:
#             nccd.mask = rebin(nccd.mask, newshape)
# 
#         return nccd
#     else:
#         raise TypeError('ccd is not an ndarray or a CCDData object.')
# 
# Path: ccdproc/tests/pytest_fixtures.py
# def ccd_data(data_size=DEFAULT_DATA_SIZE,
#              data_scale=DEFAULT_DATA_SCALE,
#              data_mean=DEFAULT_DATA_MEAN,
#              rng_seed=DEFAULT_SEED):
#     """
#     Return a CCDData object with units of ADU.
# 
#     The size of the data array is 100x100 but can be changed using the marker
#     @pytest.mark.data_size(N) on the test function, where N should be the
#     desired dimension.
# 
#     Data values are initialized to random numbers drawn from a normal
#     distribution with mean of 0 and scale 1.
# 
#     The scale can be changed with the marker @pytest.marker.scale(s) on the
#     test function, where s is the desired scale.
# 
#     The mean can be changed with the marker @pytest.marker.scale(m) on the
#     test function, where m is the desired mean.
#     """
#     size = data_size
#     scale = data_scale
#     mean = data_mean
# 
#     with NumpyRNGContext(rng_seed):
#         data = np.random.normal(loc=mean, size=[size, size], scale=scale)
# 
#     fake_meta = {'my_key': 42, 'your_key': 'not 42'}
#     ccd = CCDData(data, unit=u.adu)
#     ccd.header = fake_meta
#     return ccd


import numpy as np
import pytest
from astropy.nddata import StdDevUncertainty
from astropy.utils.exceptions import AstropyDeprecationWarning
from ccdproc.core import rebin
from ccdproc.tests.pytest_fixtures import ccd_data as ccd_data_func
# Licensed under a 3-clause BSD style license - see LICENSE.rst






# test rebinning ndarray
def test_rebin_ndarray():
    with pytest.raises(TypeError), pytest.warns(AstropyDeprecationWarning):
        rebin(1, (5, 5))


# test rebinning dimensions
def test_rebin_dimensions():

# Path: ccdproc/core.py
# @deprecated('1.1',
#             message='The rebin function will be removed in ccdproc 3.0 '
#                     'Use block_reduce or block_replicate instead.')
# def rebin(ccd, newshape):
#     """
#     Rebin an array to have a new shape.
# 
#     Parameters
#     ----------
#     ccd : `~astropy.nddata.CCDData` or `numpy.ndarray`
#         Data to rebin.
# 
#     newshape : tuple
#         Tuple containing the new shape for the array.
# 
#     Returns
#     -------
#     output : `~astropy.nddata.CCDData` or `numpy.ndarray`
#         An array with the new shape. It will have the same type as the input
#         object.
# 
#     Raises
#     ------
#     TypeError
#         A type error is raised if data is not an `numpy.ndarray` or
#         `~astropy.nddata.CCDData`.
# 
#     ValueError
#         A value error is raised if the dimension of the new shape is not equal
#         to the data's.
# 
#     Notes
#     -----
#     This is based on the scipy cookbook for rebinning:
#     http://wiki.scipy.org/Cookbook/Rebinning
# 
#     If rebinning a CCDData object to a smaller shape, the masking and
#     uncertainty are not handled correctly.
# 
#     Examples
#     --------
#     Given an array that is 100x100::
# 
#         import numpy as np
#         from astropy import units as u
#         arr1 = CCDData(np.ones([10, 10]), unit=u.adu)
# 
#     The syntax for rebinning an array to a shape
#     of (20,20) is::
# 
#         rebin(arr1, (20,20))
#     """
#     # check to see that is in a nddata type
#     if isinstance(ccd, np.ndarray):
# 
#         # check to see that the two arrays are going to be the same length
#         if len(ccd.shape) != len(newshape):
#             raise ValueError('newshape does not have the same dimensions as '
#                              'ccd.')
# 
#         slices = [slice(0, old, old/new) for old, new in
#                   zip(ccd.shape, newshape)]
#         coordinates = np.mgrid[slices]
#         indices = coordinates.astype('i')
#         return ccd[tuple(indices)]
# 
#     elif isinstance(ccd, CCDData):
#         # check to see that the two arrays are going to be the same length
#         if len(ccd.shape) != len(newshape):
#             raise ValueError('newshape does not have the same dimensions as '
#                              'ccd.')
# 
#         nccd = ccd.copy()
#         # rebin the data plane
#         nccd.data = rebin(nccd.data, newshape)
# 
#         # rebin the uncertainty plane
#         if nccd.uncertainty is not None:
#             nccd.uncertainty.array = rebin(nccd.uncertainty.array, newshape)
# 
#         # rebin the mask plane
#         if nccd.mask is not None:
#             nccd.mask = rebin(nccd.mask, newshape)
# 
#         return nccd
#     else:
#         raise TypeError('ccd is not an ndarray or a CCDData object.')
# 
# Path: ccdproc/tests/pytest_fixtures.py
# def ccd_data(data_size=DEFAULT_DATA_SIZE,
#              data_scale=DEFAULT_DATA_SCALE,
#              data_mean=DEFAULT_DATA_MEAN,
#              rng_seed=DEFAULT_SEED):
#     """
#     Return a CCDData object with units of ADU.
# 
#     The size of the data array is 100x100 but can be changed using the marker
#     @pytest.mark.data_size(N) on the test function, where N should be the
#     desired dimension.
# 
#     Data values are initialized to random numbers drawn from a normal
#     distribution with mean of 0 and scale 1.
# 
#     The scale can be changed with the marker @pytest.marker.scale(s) on the
#     test function, where s is the desired scale.
# 
#     The mean can be changed with the marker @pytest.marker.scale(m) on the
#     test function, where m is the desired mean.
#     """
#     size = data_size
#     scale = data_scale
#     mean = data_mean
# 
#     with NumpyRNGContext(rng_seed):
#         data = np.random.normal(loc=mean, size=[size, size], scale=scale)
# 
#     fake_meta = {'my_key': 42, 'your_key': 'not 42'}
#     ccd = CCDData(data, unit=u.adu)
#     ccd.header = fake_meta
#     return ccd


# Path: ccdproc/tests/test_rebin.py
import numpy as np
import pytest
from astropy.nddata import StdDevUncertainty
from astropy.utils.exceptions import AstropyDeprecationWarning
from ccdproc.core import rebin
from ccdproc.tests.pytest_fixtures import ccd_data as ccd_data_func

# Licensed under a 3-clause BSD style license - see LICENSE.rst






# test rebinning ndarray
def test_rebin_ndarray():
    with pytest.raises(TypeError), pytest.warns(AstropyDeprecationWarning):
        rebin(1, (5, 5))


# test rebinning dimensions
def test_rebin_dimensions():

    ccd_data = ccd_data_func(data_size=10)