Skip to content

Failed tests when testing astropy in Anaconda #4171

Closed

Description

@lingxz

The following tests appear to fail when I test the developer's version of astropy, and I'm not sure why:
test_blackbody_scipy
test_blackbody_overflow
test_blackbody_synphot

This happens when I go into my anaconda command line, move into my astropy repository, and run

python setup.py test

The failure message looks like this:

================================== FAILURES ===================================
____________________________ test_blackbody_scipy _____________________________

    @pytest.mark.skipif("os.environ.get('APPVEYOR')",  reason="fails on AppVeyor")
    @pytest.mark.skipif('not HAS_SCIPY')
    def test_blackbody_scipy():
        """Test Planck function.

        .. note:: Needs ``scipy`` to work.

        """
        flux_unit = u.Watt / (u.m ** 2 * u.um)
        wave = np.logspace(0, 8, 1e6) * u.AA
        temp = 100. * u.K
        with np.errstate(all='ignore'):
            bb_nu = blackbody_nu(wave, temp) * u.sr
        flux = bb_nu.to(flux_unit, u.spectral_density(wave)) / u.sr

        lum = wave.to(u.um)
        intflux = integrate.trapz(flux.value, x=lum.value)
        ans = const.sigma_sb * temp**4 / np.pi
>       np.testing.assert_allclose(intflux, ans.value, rtol=0.01)  # 1% accuracy

astropy\analytic_functions\tests\test_blackbody.py:45:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
C:\Users\User\Anaconda3\envs\astropydev\lib\site-packages\numpy\testing\utils.py:1297: in assert_allclose
    verbose=verbose, header=header)
C:\Users\User\Anaconda3\envs\astropydev\lib\site-packages\numpy\testing\utils.py:628: in assert_array_compare
    chk_same_position(x_isnan, y_isnan, hasval='nan')
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

x_id = True, y_id = False, hasval = 'nan'

    def chk_same_position(x_id, y_id, hasval='nan'):
        """Handling nan/inf: check that x and y have the nan/inf at the same
            locations."""
        try:
            assert_array_equal(x_id, y_id)
        except AssertionError:
            msg = build_err_msg([x, y],
                                err_msg + '\nx and y %s location mismatch:' \
                                % (hasval), verbose=verbose, header=header,
                                names=('x', 'y'), precision=precision)
>           raise AssertionError(msg)
E           AssertionError:
E           Not equal to tolerance rtol=0.01, atol=0
E
E           x and y nan location mismatch:
E            x: array(nan)
E            y: array(1.8049357842496399)

C:\Users\User\Anaconda3\envs\astropydev\lib\site-packages\numpy\testing\utils.py:608: AssertionError
___________________________ test_blackbody_overflow ___________________________

    @pytest.mark.skipif("os.environ.get('APPVEYOR')",  reason="fails on AppVeyor")
    def test_blackbody_overflow():
        """Test Planck function with overflow."""
        photlam = u.photon / (u.cm**2 * u.s * u.AA)
        wave = [0, 1000.0, 100000.0, 1e55]  # Angstrom
        temp = 10000.0  # Kelvin
        with np.errstate(all='ignore'):
            bb_lam = blackbody_lambda(wave, temp) * u.sr
        flux = bb_lam.to(photlam, u.spectral_density(wave * u.AA)) / u.sr

        # First element is NaN, last element is very small, others normal
        assert np.isnan(flux[0])
        assert np.log10(flux[-1].value) < -134
        np.testing.assert_allclose(
            flux.value[1:-1], [3.38131732e+16, 3.87451317e+15],
            rtol=1e-3)  # 0.1% accuracy in PHOTLAM/sr

        with np.errstate(all='ignore'):
            flux = blackbody_lambda(1, 1e4)
>       assert flux.value == 0
E       assert nan == 0
E        +  where nan = <Quantity nan erg / (Angstrom cm2 s sr)>.value

astropy\analytic_functions\tests\test_blackbody.py:67: AssertionError
___________________________ test_blackbody_synphot ____________________________

    @pytest.mark.skipif("os.environ.get('APPVEYOR')",  reason="fails on AppVeyor")
    def test_blackbody_synphot():
        """Test that it is consistent with IRAF SYNPHOT BBFUNC."""
        # Solid angle of solar radius at 1 kpc
        fac = np.pi * (const.R_sun / const.kpc) ** 2 * u.sr

        with np.errstate(all='ignore'):
            flux = blackbody_nu([100, 1, 1000, 1e4, 1e5] * u.AA, 5000) * fac
        assert flux.unit == FNU

        # Special check for overflow value (SYNPHOT gives 0)
        assert np.log10(flux[0].value) < -143

        np.testing.assert_allclose(
            flux.value[1:], [0, 2.01950807e-34, 3.78584515e-26, 1.90431881e-27],
>           rtol=0.01)  # 1% accuracy

astropy\analytic_functions\tests\test_blackbody.py:85:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
C:\Users\User\Anaconda3\envs\astropydev\lib\site-packages\numpy\testing\utils.py:1297: in assert_allclose
    verbose=verbose, header=header)
C:\Users\User\Anaconda3\envs\astropydev\lib\site-packages\numpy\testing\utils.py:628: in assert_array_compare
    chk_same_position(x_isnan, y_isnan, hasval='nan')
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

x_id = array([ True, False, False, False], dtype=bool)
y_id = array([False, False, False, False], dtype=bool), hasval = 'nan'

    def chk_same_position(x_id, y_id, hasval='nan'):
        """Handling nan/inf: check that x and y have the nan/inf at the same
            locations."""
        try:
            assert_array_equal(x_id, y_id)
        except AssertionError:
            msg = build_err_msg([x, y],
                                err_msg + '\nx and y %s location mismatch:' \
                                % (hasval), verbose=verbose, header=header,
                                names=('x', 'y'), precision=precision)
>           raise AssertionError(msg)
E           AssertionError:
E           Not equal to tolerance rtol=0.01, atol=0
E
E           x and y nan location mismatch:
E            x: array([           nan,   2.018840e-34,   3.781005e-26,   1.901751e-27])
E            y: array([  0.000000e+00,   2.019508e-34,   3.785845e-26,   1.904319e-27])

C:\Users\User\Anaconda3\envs\astropydev\lib\site-packages\numpy\testing\utils.py:608: AssertionError
 3 failed, 9217 passed, 158 skipped, 76 xfailed, 2 xpassed in 1399.32 seconds =

Does anyone face the same problem? I am using Windows 8, in a python 2.7 environment, and using the latest version of astropy on github. Thanks!

Activity

  1. changed the title [-]Failed tests when testing dev version astropy[/-] [+]Failed tests when testing astropy in Anaconda[/+] on Sep 20, 2015
  2. embray commented on Sep 21, 2015

    @embray
    Member

    Thanks for the report.

    Could you please also post the header of your test run, which reports all the version numbers.

  3. lingxz commented on Sep 21, 2015

    @lingxz
    ContributorAuthor

    Oh sure. Here's the header of the test run:

    ============================= test session starts =============================
    platform win32 -- Python 2.7.10 -- pytest-2.5.1
    
    Running tests with Astropy version 1.1.dev13404.
    Running tests in astropy C:\Users\User\astropy\docs.
    
    Platform: Windows-8-6.2.9200
    
    Executable: C:\Users\User\Anaconda3\envs\astropydev\python.exe
    
    Full Python Version:
    2.7.10 |Anaconda 2.3.0 (32-bit)| (default, May 28 2015, 17:02:00) [MSC v.1500 32 bit (Intel)]
    
    encodings: sys: ascii, locale: cp1252, filesystem: mbcs, unicode bits: 15
    byteorder: little
    float info: dig: 15, mant_dig: 15
    
    Numpy: 1.9.2
    Scipy: 0.15.1
    Matplotlib: 1.4.3
    h5py: 2.5.0
    
  4. embray commented on Sep 22, 2015

    @embray
    Member

    Thanks, I should be able to look into that.

  5. MSeifert04 commented on Oct 17, 2015

    @MSeifert04
    Contributor

    @embray @lingxz Just a question: AppVeyor is for testing in an Windows environment? Why not change the @pytest.mark.skipif("os.environ.get('APPVEYOR')", reason="fails on AppVeyor") to
    platform.system() == 'Windows' or similar if it is known that the blackbody tests will fail there? Unfortunatly I'm not really sure that will evaluate to True on AppVeyor and Windows systems or if it needs an or between the two conditions.

    At least with that change it worked on my (Windows) computer.

  6. MSeifert04 commented on Oct 17, 2015

    @MSeifert04
    Contributor

    I created a branch that would fix the issue https://github.com/MSeifert04/astropy/tree/fix-4171 but maybe it should be reviewed (if there would be an easier way to solve it or if the tests can be made to work on windows too) before I create a PR?

  7. embray commented on Oct 19, 2015

    @embray
    Member

    For one, it doesn't fail for me on Windows. I haven't had a chance to look into this though.

  8. eteq commented on Oct 26, 2015

    @eteq
    Member

    @MSeifert04 - you should feel free to create a PR with that change - it's generally easier to have discussions on PRs rather than in branches. Even if it turns out we don't want to do that (i.e., it's actually appveyor specifically that's at fault rather than something with windows itself), it would be better to keep a record of that in the comment thread on the PR. Thanks!

  9. pllim commented on Oct 27, 2015

    @pllim
    Member

    Somehow I missed this discussion.

    1. test_blackbody_scipy failed because scipy.integrate returned a nan on that particular machine/environment. So it is okay to ignore since our version actually works fine.
    2. test_blackbody_overflow failed because our blackbody_nu() returned a nan instead of 0. Since it is a test for overflow (invalid values), it probably means this particular machine/environment handled the special case differently.
    3. test_blackbody_synphot failed in a similar fashion as 2 above.

    Conclusion: For 1, it is not our problem. For 2 and 3, they failed on special cases where the flux won't be meaningful anyway. So I am okay with skipping them on Windows.

  10. embray commented on Dec 11, 2015

    @embray
    Member

    In Python 2.7.11 32-bit from Anaconda on Windows I got failures in:

    • test_blackbody_overflow
    • test_blackbody_synphot

    But not in test_blackbody_scipy, but apparently only because I didn't have scipy even installed in this environment. So I'll install that and run the tests again.

  11. pllim commented on Dec 11, 2015

    @pllim
    Member

    @embray , did you see the latest discussions in #4275 ?

  12. added 2 commits that reference this issue on Dec 23, 2015
  13. pllim commented on Dec 23, 2015

    @pllim
    Member

    Since #4393 is merged, can we close this?

  14. embray commented on Dec 24, 2015

    @embray
    Member

    Yes, thanks for the reminder @pllim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions