Skip to content

Commit

Permalink
Merge b41097b into bdeb4c6
Browse files Browse the repository at this point in the history
  • Loading branch information
astrofrog committed Mar 2, 2020
2 parents bdeb4c6 + b41097b commit ee53fee
Show file tree
Hide file tree
Showing 18 changed files with 65 additions and 24 deletions.
44 changes: 21 additions & 23 deletions .travis.yml
Expand Up @@ -23,38 +23,36 @@ env:
matrix:
include:

- python: 3.7
env: TOXENV='py37-test'
name: "Python 3.7 with minimal dependencies"
- language: c
os: osx
env: PYTHON_VERSION=3.7 TOXENV='py37-test-all'
name: "Python 3.7 with all dependencies (except CASA) on MacOS X"

- python: 3.7
env: TOXENV='py37-test-all'
name: "Python 3.7 with all dependencies (except CASA)"
- language: c
os: windows
env: PYTHON_VERSION=3.7 TOXENV='py37-test-all'
name: "Python 3.7 with all dependencies (except CASA) on Windows"

- python: 3.6
env: TOXENV='py36-test-casa'
name: "Python 3.6 with minimal dependencies and CASA"

- python: 3.6
env: TOXENV='py36-test-casa-dev'
name: "Python 3.6, CASA, and dev versions of key dependencies"

- python: 3.8
env: TOXENV='py38-test-all-dev'
name: "Python 3.8, all dependencies, and dev versions of key dependencies"

- python: 3.8
env: TOXENV='build_docs'
name: "Documentation"

before_install:
# We need a full clone to make sure setuptools_scm
# works properly
- git fetch --unshallow .
- git fetch --depth=1000000

- export DISPLAY=:99.0
- /sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -screen 0 1920x1200x24 -ac +extension GLX +render -noreset
- if [[ $TRAVIS_OS_NAME == linux ]]; then
export DISPLAY=:99.0;
/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -screen 0 1920x1200x24 -ac +extension GLX +render -noreset;
fi

install:
# language: python is only available for Linux, so for other platforms
# we need to use ci-helpers to set up Python.
- if [[ $TRAVIS_OS_NAME == osx || $TRAVIS_OS_NAME == windows ]]; then
git clone git://github.com/astropy/ci-helpers.git;
source ci-helpers/travis/setup_conda.sh;
fi


script:
- pip install tox
Expand Down
1 change: 1 addition & 0 deletions spectral_cube/io/tests/test_casa_wcs.py
Expand Up @@ -90,6 +90,7 @@ def header_copy_with(**kwargs):


ALL_HEADERS = [
header_copy_with(),
header_copy_with(CTYPE1='GLON-TAN', CTYPE2='GLAT-TAN'),
header_copy_with(CTYPE1='SLON-TAN', CTYPE2='SLAT-TAN'),
header_copy_with(CTYPE1='ELON-TAN', CTYPE2='ELAT-TAN'),
Expand Down
7 changes: 6 additions & 1 deletion spectral_cube/spectral_cube.py
Expand Up @@ -15,6 +15,7 @@
from pathlib import PosixPath
import six
from six.moves import zip, range
import dask.array

import astropy.wcs
from astropy import units as u
Expand Down Expand Up @@ -1315,7 +1316,11 @@ def unmasked_data(self, view):
data : Quantity instance
The unmasked data
"""
return u.Quantity(self._data[view], self.unit, copy=False)
values = self._data[view]
# Astropy Quantities don't play well with dask arrays with shape ()
if isinstance(values, dask.array.core.Array) and values.shape == ():
values = values.compute()
return u.Quantity(values, self.unit, copy=False)

def unmasked_copy(self):
"""
Expand Down
Binary file not shown.
Binary file not shown.
4 changes: 4 additions & 0 deletions spectral_cube/tests/data/basic.image/logtable/table.info
@@ -0,0 +1,4 @@
Type = Log message
SubType =

Repository for software-generated logging messages
Binary file not shown.
Binary file added spectral_cube/tests/data/basic.image/mask0/table.dat
Binary file not shown.
Binary file added spectral_cube/tests/data/basic.image/mask0/table.f0
Binary file not shown.
1 change: 1 addition & 0 deletions spectral_cube/tests/data/basic.image/mask0/table.f0_TSM0
@@ -0,0 +1 @@
���������������
3 changes: 3 additions & 0 deletions spectral_cube/tests/data/basic.image/mask0/table.info
@@ -0,0 +1,3 @@
Type = Paged Array
SubType =

Binary file not shown.
Binary file added spectral_cube/tests/data/basic.image/table.dat
Binary file not shown.
Binary file added spectral_cube/tests/data/basic.image/table.f0
Binary file not shown.
Binary file added spectral_cube/tests/data/basic.image/table.f0_TSM0
Binary file not shown.
3 changes: 3 additions & 0 deletions spectral_cube/tests/data/basic.image/table.info
@@ -0,0 +1,3 @@
Type = Image
SubType =

Binary file added spectral_cube/tests/data/basic.image/table.lock
Binary file not shown.
26 changes: 26 additions & 0 deletions spectral_cube/tests/test_casafuncs.py
Expand Up @@ -6,6 +6,7 @@
import pytest
import numpy as np
from numpy.testing import assert_allclose
from astropy.tests.helper import assert_quantity_allclose

from astropy import units as u

Expand All @@ -24,6 +25,8 @@
except ImportError:
CASA_INSTALLED = False

DATA = os.path.join(os.path.dirname(__file__), 'data')


def make_casa_testimage(infile, outname):

Expand Down Expand Up @@ -69,6 +72,29 @@ def filename(request):
return request.getfixturevalue(request.param)


def test_casa_read_basic():

# Check that SpectralCube.read works for an example CASA dataset stored
# in the tests directory. This test should NOT require CASA, whereas a
# number of tests below require CASA to generate test datasets. The present
# test is to ensure CASA is not required for reading.

cube = SpectralCube.read(os.path.join(DATA, 'basic.image'))
assert cube.shape == (3, 4, 5)
assert_allclose(cube.wcs.pixel_to_world_values(1, 2, 3),
[2.406271e+01, 2.993521e+01, 1.421911e+09])

# Carry out an operation to make sure the underlying data array works

cube.moment0()

# Slice the dataset

assert_quantity_allclose(cube.unmasked_data[0, 0, :],
[1, 1, 1, 1, 1] * u.Jy / u.beam)
assert_quantity_allclose(cube.unmasked_data[0, 1, 2], 1 * u.Jy / u.beam)


@pytest.mark.skipif(not CASA_INSTALLED, reason='CASA tests must be run in a CASA environment.')
@pytest.mark.parametrize('filename', ('data_adv', 'data_advs', 'data_sdav',
'data_vad', 'data_vsad'),
Expand Down

0 comments on commit ee53fee

Please sign in to comment.