Repository navigation
Closed
Labels
Windowstestingzzz 💤 analytic_functionsarchived: this package no longer existsarchived: this package no longer exists
Description
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!
Metadata
Metadata
Assignees
Labels
Windowstestingzzz 💤 analytic_functionsarchived: this package no longer existsarchived: this package no longer exists
Activity
[-]Failed tests when testing dev version astropy[/-][+]Failed tests when testing astropy in Anaconda[/+]embray commentedon Sep 21, 2015
Thanks for the report.
Could you please also post the header of your test run, which reports all the version numbers.
lingxz commentedon Sep 21, 2015
Oh sure. Here's the header of the test run:
embray commentedon Sep 22, 2015
Thanks, I should be able to look into that.
MSeifert04 commentedon Oct 17, 2015
@embray @lingxz Just a question:
AppVeyoris for testing in an Windows environment? Why not change the@pytest.mark.skipif("os.environ.get('APPVEYOR')", reason="fails on AppVeyor")toplatform.system() == 'Windows'or similar if it is known that the blackbody tests will fail there? Unfortunatly I'm not really sure that will evaluate toTrueon AppVeyor and Windows systems or if it needs anorbetween the two conditions.At least with that change it worked on my (Windows) computer.
MSeifert04 commentedon Oct 17, 2015
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?
embray commentedon Oct 19, 2015
For one, it doesn't fail for me on Windows. I haven't had a chance to look into this though.
eteq commentedon Oct 26, 2015
@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!
pllim commentedon Oct 27, 2015
Somehow I missed this discussion.
test_blackbody_scipyfailed becausescipy.integratereturned ananon that particular machine/environment. So it is okay to ignore since our version actually works fine.test_blackbody_overflowfailed because ourblackbody_nu()returned ananinstead of 0. Since it is a test for overflow (invalid values), it probably means this particular machine/environment handled the special case differently.test_blackbody_synphotfailed 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.
embray commentedon Dec 11, 2015
In Python 2.7.11 32-bit from Anaconda on Windows I got failures in:
test_blackbody_overflowtest_blackbody_synphotBut 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.pllim commentedon Dec 11, 2015
@embray , did you see the latest discussions in #4275 ?
Merge pull request #4393 from embray/analytic_functions/issue-4171
Merge pull request #4393 from embray/analytic_functions/issue-4171
pllim commentedon Dec 23, 2015
Since #4393 is merged, can we close this?
embray commentedon Dec 24, 2015
Yes, thanks for the reminder @pllim