astropy/ccdproc

Failing gain tests with astropy 3.1rc1

Closed this issue · 1 comments

I'm not sure it's an astropy or ccdproc issue, but seeing these on master with the new RC:

================================================= test session starts ==================================================
platform darwin -- Python 3.6.6, pytest-3.10.1, py-1.7.0, pluggy-0.8.0

Running tests with ccdproc version 2.0.dev1410.
Running tests in ccdproc docs.

Date: 2018-11-15T17:32:41

Platform: Darwin-17.7.0-x86_64-i386-64bit

Executable: /Users/bsipocz/.pyenv/versions/3.6.6/bin/python

Full Python Version: 
3.6.6 (default, Oct  1 2018, 18:42:25) 
[GCC 4.2.1 Compatible Apple LLVM 10.0.0 (clang-1000.10.44.2)]

encodings: sys: utf-8, locale: UTF-8, filesystem: utf-8
byteorder: little
float info: dig: 15, mant_dig: 15

Numpy: 1.15.4
Scipy: 1.1.0
Matplotlib: 3.0.2
Pandas: not available
Astropy: 3.1rc1
astroscrappy: 1.0.5
reproject: 0.4
astropy_helpers: 3.1rc1
Using Astropy options: remote_data: any.

rootdir: /private/var/folders/dc/hsm7tqpx2d57n7vb3k1l81xw0000gq/T/ccdproc-test-3i7a637t/lib/python3.6/site-packages, inifile: setup.cfg
plugins: remotedata-0.3.1, openfiles-0.3.0, doctestplus-0.2.0, arraydiff-0.2
collected 296 items                                                                                                    

ccdproc/combiner.py .                                                                                            [  0%]
ccdproc/core.py ....ss...                                                                                        [  3%]
ccdproc/extern/bitfield.py ..                                                                                    [  4%]
ccdproc/tests/test_bitfield.py ............                                                                      [  8%]
ccdproc/tests/test_ccdmask.py ...                                                                                [  9%]
ccdproc/tests/test_ccdproc.py ....................................................................               [ 32%]
ccdproc/tests/test_ccdproc_logging.py .......                                                                    [ 34%]
ccdproc/tests/test_combine_open_files.py ..                                                                      [ 35%]
ccdproc/tests/test_combiner.py ...................................................                               [ 52%]
ccdproc/tests/test_cosmicray.py ...............                                                                  [ 57%]
ccdproc/tests/test_gain.py FFFFF                                                                                 [ 59%]
ccdproc/tests/test_image_collection.py ......................................................................    [ 82%]
ccdproc/tests/test_keyword.py ..........                                                                         [ 86%]
ccdproc/tests/test_rebin.py ........                                                                             [ 88%]
ccdproc/tests/test_wrapped_external_funcs.py ...                                                                 [ 89%]
ccdproc/utils/slices.py .                                                                                        [ 90%]
ccdproc/utils/tests/test_slices.py ..................                                                            [ 96%]
docs/authors_for_sphinx.rst .                                                                                    [ 96%]
docs/changelog.rst .                                                                                             [ 96%]
docs/index.rst .                                                                                                 [ 97%]
docs/license.rst .                                                                                               [ 97%]
docs/ccdproc/ccddata.rst .                                                                                       [ 97%]
docs/ccdproc/image_combination.rst .                                                                             [ 98%]
docs/ccdproc/image_management.rst .                                                                              [ 98%]
docs/ccdproc/index.rst .                                                                                         [ 98%]
docs/ccdproc/install.rst .                                                                                       [ 99%]
docs/ccdproc/reduction_examples.rst .                                                                            [ 99%]
docs/ccdproc/reduction_toolbox.rst .                                                                             [100%]

======================================================= FAILURES =======================================================
____________________________________________ test_linear_gain_correct[3.0] _____________________________________________

ccd_data = CCDData([[1.0856306 , 0.99734545, 0.2829785 , ..., 1.36347154, 0.37940061,
          0.37917643],
         [0.64205469...        0.82190772],
         [0.66845311, 2.15776154, 0.88186588, ..., 0.47226641, 0.58196437,
          0.97061286]])
gain = 3.0

    @pytest.mark.parametrize('gain', [
                             3.0,
                             3.0 * u.photon / u.adu,
                             3.0 * u.electron / u.adu,
                             Keyword('gainval', unit=u.electron / u.adu)])
    @pytest.mark.data_unit(u.adu)
    def test_linear_gain_correct(ccd_data, gain):
        # The data values should be positive, so the poisson noise calculation
        # works without throwing warnings
        ccd_data.data = np.absolute(ccd_data.data)
        ccd_data = create_deviation(ccd_data, readnoise=1.0 * u.adu)
        ccd_data.meta['gainval'] = 3.0
        orig_data = ccd_data.data
        ccd = gain_correct(ccd_data, gain)
        if isinstance(gain, Keyword):
            gain = gain.value   # convert to Quantity...
        try:
            gain_value = gain.value
        except AttributeError:
            gain_value = gain
    
        np.testing.assert_array_equal(ccd.data, gain_value * orig_data)
        np.testing.assert_array_equal(ccd.uncertainty.array,
>                                     gain_value * ccd_data.uncertainty.array)
E       AssertionError: 
E       Arrays are not equal
E       
E       (mismatch 22.75%)
E        x: array([4.332514, 4.239824, 3.398059, ..., 3.64011 , 3.773285, 4.211356])
E        y: array([4.332514, 4.239824, 3.398059, ..., 3.64011 , 3.773285, 4.211356])

ccdproc/tests/test_gain.py:35: AssertionError
___________________________________________ test_linear_gain_correct[gain1] ____________________________________________

ccd_data = CCDData([[1.0856306 , 0.99734545, 0.2829785 , ..., 1.36347154, 0.37940061,
          0.37917643],
         [0.64205469...        0.82190772],
         [0.66845311, 2.15776154, 0.88186588, ..., 0.47226641, 0.58196437,
          0.97061286]])
gain = <Quantity 3. ph / adu>

    @pytest.mark.parametrize('gain', [
                             3.0,
                             3.0 * u.photon / u.adu,
                             3.0 * u.electron / u.adu,
                             Keyword('gainval', unit=u.electron / u.adu)])
    @pytest.mark.data_unit(u.adu)
    def test_linear_gain_correct(ccd_data, gain):
        # The data values should be positive, so the poisson noise calculation
        # works without throwing warnings
        ccd_data.data = np.absolute(ccd_data.data)
        ccd_data = create_deviation(ccd_data, readnoise=1.0 * u.adu)
        ccd_data.meta['gainval'] = 3.0
        orig_data = ccd_data.data
        ccd = gain_correct(ccd_data, gain)
        if isinstance(gain, Keyword):
            gain = gain.value   # convert to Quantity...
        try:
            gain_value = gain.value
        except AttributeError:
            gain_value = gain
    
        np.testing.assert_array_equal(ccd.data, gain_value * orig_data)
        np.testing.assert_array_equal(ccd.uncertainty.array,
>                                     gain_value * ccd_data.uncertainty.array)
E       AssertionError: 
E       Arrays are not equal
E       
E       (mismatch 22.75%)
E        x: array([4.332514, 4.239824, 3.398059, ..., 3.64011 , 3.773285, 4.211356])
E        y: array([4.332514, 4.239824, 3.398059, ..., 3.64011 , 3.773285, 4.211356])

ccdproc/tests/test_gain.py:35: AssertionError
___________________________________________ test_linear_gain_correct[gain2] ____________________________________________

ccd_data = CCDData([[1.0856306 , 0.99734545, 0.2829785 , ..., 1.36347154, 0.37940061,
          0.37917643],
         [0.64205469...        0.82190772],
         [0.66845311, 2.15776154, 0.88186588, ..., 0.47226641, 0.58196437,
          0.97061286]])
gain = <Quantity 3. electron / adu>

    @pytest.mark.parametrize('gain', [
                             3.0,
                             3.0 * u.photon / u.adu,
                             3.0 * u.electron / u.adu,
                             Keyword('gainval', unit=u.electron / u.adu)])
    @pytest.mark.data_unit(u.adu)
    def test_linear_gain_correct(ccd_data, gain):
        # The data values should be positive, so the poisson noise calculation
        # works without throwing warnings
        ccd_data.data = np.absolute(ccd_data.data)
        ccd_data = create_deviation(ccd_data, readnoise=1.0 * u.adu)
        ccd_data.meta['gainval'] = 3.0
        orig_data = ccd_data.data
        ccd = gain_correct(ccd_data, gain)
        if isinstance(gain, Keyword):
            gain = gain.value   # convert to Quantity...
        try:
            gain_value = gain.value
        except AttributeError:
            gain_value = gain
    
        np.testing.assert_array_equal(ccd.data, gain_value * orig_data)
        np.testing.assert_array_equal(ccd.uncertainty.array,
>                                     gain_value * ccd_data.uncertainty.array)
E       AssertionError: 
E       Arrays are not equal
E       
E       (mismatch 22.75%)
E        x: array([4.332514, 4.239824, 3.398059, ..., 3.64011 , 3.773285, 4.211356])
E        y: array([4.332514, 4.239824, 3.398059, ..., 3.64011 , 3.773285, 4.211356])

ccdproc/tests/test_gain.py:35: AssertionError
___________________________________________ test_linear_gain_correct[gain3] ____________________________________________

ccd_data = CCDData([[1.0856306 , 0.99734545, 0.2829785 , ..., 1.36347154, 0.37940061,
          0.37917643],
         [0.64205469...        0.82190772],
         [0.66845311, 2.15776154, 0.88186588, ..., 0.47226641, 0.58196437,
          0.97061286]])
gain = <Quantity 3. electron / adu>

    @pytest.mark.parametrize('gain', [
                             3.0,
                             3.0 * u.photon / u.adu,
                             3.0 * u.electron / u.adu,
                             Keyword('gainval', unit=u.electron / u.adu)])
    @pytest.mark.data_unit(u.adu)
    def test_linear_gain_correct(ccd_data, gain):
        # The data values should be positive, so the poisson noise calculation
        # works without throwing warnings
        ccd_data.data = np.absolute(ccd_data.data)
        ccd_data = create_deviation(ccd_data, readnoise=1.0 * u.adu)
        ccd_data.meta['gainval'] = 3.0
        orig_data = ccd_data.data
        ccd = gain_correct(ccd_data, gain)
        if isinstance(gain, Keyword):
            gain = gain.value   # convert to Quantity...
        try:
            gain_value = gain.value
        except AttributeError:
            gain_value = gain
    
        np.testing.assert_array_equal(ccd.data, gain_value * orig_data)
        np.testing.assert_array_equal(ccd.uncertainty.array,
>                                     gain_value * ccd_data.uncertainty.array)
E       AssertionError: 
E       Arrays are not equal
E       
E       (mismatch 22.75%)
E        x: array([4.332514, 4.239824, 3.398059, ..., 3.64011 , 3.773285, 4.211356])
E        y: array([4.332514, 4.239824, 3.398059, ..., 3.64011 , 3.773285, 4.211356])

ccdproc/tests/test_gain.py:35: AssertionError
____________________________________________ test_linear_gain_unit_keyword _____________________________________________

ccd_data = CCDData([[1.0856306 , 0.99734545, 0.2829785 , ..., 1.36347154, 0.37940061,
          0.37917643],
         [0.64205469...        0.82190772],
         [0.66845311, 2.15776154, 0.88186588, ..., 0.47226641, 0.58196437,
          0.97061286]])

    @pytest.mark.data_unit(u.adu)
    def test_linear_gain_unit_keyword(ccd_data):
        # The data values should be positive, so the poisson noise calculation
        # works without throwing warnings
        ccd_data.data = np.absolute(ccd_data.data)
    
        ccd_data = create_deviation(ccd_data, readnoise=1.0 * u.adu)
        orig_data = ccd_data.data
        gain = 3.0
        gain_unit = u.electron / u.adu
        ccd = gain_correct(ccd_data, gain, gain_unit=gain_unit)
        np.testing.assert_array_equal(ccd.data, gain * orig_data)
        np.testing.assert_array_equal(ccd.uncertainty.array,
>                                     gain * ccd_data.uncertainty.array)
E       AssertionError: 
E       Arrays are not equal
E       
E       (mismatch 22.75%)
E        x: array([4.332514, 4.239824, 3.398059, ..., 3.64011 , 3.773285, 4.211356])
E        y: array([4.332514, 4.239824, 3.398059, ..., 3.64011 , 3.773285, 4.211356])

ccdproc/tests/test_gain.py:57: AssertionError
=================================================== warnings summary ===================================================

Oh, they've appeared about 3 weeks ago in travis, too: https://travis-ci.org/astropy/ccdproc/jobs/452751962