Skip to content

Commit

Permalink
Skip test that uses np.nanmedian for older versions of Numpy, and do …
Browse files Browse the repository at this point in the history
…other skip-related cleanup.
  • Loading branch information
astrofrog committed Jan 6, 2016
1 parent 0d3ceec commit e48cad5
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions spectral_cube/tests/test_spectral_cube.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import pytest
import operator
import itertools
import warnings
import mmap
from distutils.version import StrictVersion, LooseVersion

# needed to test for warnings later
warnings.simplefilter('always', UserWarning)

import pytest

from astropy.io import fits
from astropy import units as u
Expand All @@ -23,23 +24,20 @@
from . import path
from .helpers import assert_allclose, assert_array_equal

from distutils.version import StrictVersion

try:
import yt
ytOK = True
yt_version = (StrictVersion(yt.__version__[:-4])
if 'dev' in yt.__version__ else
StrictVersion(yt.__version__))
YT_INSTALLED = True
YT_LT_301 = LooseVersion(yt.__version__) < LooseVersion('3.0.1')
except ImportError:
yt_version = StrictVersion('0.0.0')
ytOK = False
YT_INSTALLED = False
YT_LT_301 = False

try:
import bottleneck
bottleneckOK = True
BOTTLENECK_INSTALLED = True
except ImportError:
bottleneckOK = False
BOTTLENECK_INSTALLED = False

try:
from radio_beam import Beam
Expand All @@ -48,6 +46,9 @@
RADIO_BEAM_INSTALLED = False


NUMPY_LT_19 = LooseVersion(np.__version__) < LooseVersion('1.9.0')


def cube_and_raw(filename):
p = path(filename)

Expand Down Expand Up @@ -444,6 +445,7 @@ def test_median(self, iterate_rays):
assert not np.any(np.isnan(scmed.value))
assert scmed.unit == self.c.unit

@pytest.mark.skipif('NUMPY_LT_19')
def test_bad_median_apply(self):
# this is a test for manually-applied numpy medians, which are different
# from the cube.median method that does "the right thing"
Expand Down Expand Up @@ -563,7 +565,7 @@ def test_repr_withunit(self):
""".strip()


@pytest.mark.skipif(not ytOK, reason='Could not import yt')
@pytest.mark.skipif('not YT_INSTALLED')
class TestYt():
def setup_method(self, method):
self.cube = SpectralCube.read(path('adv.fits'))
Expand Down Expand Up @@ -602,7 +604,7 @@ def test_yt(self):
ds2.quan(1.0,unit2)
ds3.quan(1.0,unit3)

@pytest.mark.skipif(yt_version < StrictVersion('3.0.1'), reason='yt 3.0 has a FITS-related bug')
@pytest.mark.skipif('YT_LT_301')
def test_yt_fluxcompare(self):
# Now check that we can compute quantities of the flux
# and that they are equal
Expand Down Expand Up @@ -749,7 +751,7 @@ def test_preserve_spectral_unit():
assert new_cube.spectral_axis.unit is u.GHz


@pytest.mark.skipif(not bottleneckOK, reason='Bottleneck could not be imported')
@pytest.mark.skipif('not BOTTLENECK_INSTALLED')
def test_endians():
"""
Test that the endianness checking returns something in Native form
Expand Down Expand Up @@ -974,7 +976,7 @@ def test_preserve_bunit():
assert cube.unit == u.Jy
assert cube.header['BUNIT'] == 'Jy'

@pytest.mark.skipif("not RADIO_BEAM_INSTALLED")
@pytest.mark.skipif('not RADIO_BEAM_INSTALLED')
def test_preserve_beam():

cube, data = cube_and_raw('advs.fits')
Expand All @@ -983,7 +985,7 @@ def test_preserve_beam():

assert cube.beam == beam

@pytest.mark.skipif("not RADIO_BEAM_INSTALLED")
@pytest.mark.skipif('not RADIO_BEAM_INSTALLED')
def test_append_beam_to_hdr():

cube, data = cube_and_raw('advs.fits')
Expand Down Expand Up @@ -1034,7 +1036,7 @@ def test_jybeam_whitespace():
np.testing.assert_almost_equal(cube.beam.sr.value,
(((1*u.arcsec/np.sqrt(8*np.log(2)))**2).to(u.sr)*2*np.pi).value)

@pytest.mark.skipif("not RADIO_BEAM_INSTALLED")
@pytest.mark.skipif('not RADIO_BEAM_INSTALLED')
def test_beam_proj_meta():

cube, data = cube_and_raw('advs.fits')
Expand Down

0 comments on commit e48cad5

Please sign in to comment.