diff --git a/.travis.yml b/.travis.yml index 08ddb7eab..031287af6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,6 +16,7 @@ env: - ASTROPY_VERSION=stable - CONDA_INSTALL='conda install -c astropy-ci-extras --yes' - PIP_INSTALL='pip install' + - BOTTLENECK=no matrix: - SETUP_CMD='egg_info' @@ -34,7 +35,7 @@ matrix: # Try Astropy development version - python: 2.7 env: ASTROPY_VERSION=development SETUP_CMD='test' - - python: 3.3 + - python: 3.4 env: ASTROPY_VERSION=development SETUP_CMD='test' # Try all python versions with the latest numpy @@ -59,6 +60,12 @@ matrix: - python: 2.7 env: NUMPY_VERSION=1.5 SETUP_CMD='test' + # Test with bottleneck + - python: 2.7 + env: ASTROPY_VERSION=stable SETUP_CMD='test' bottleneck=yes NUMPY_VERSION=1.8 + - python: 3.4 + env: ASTROPY_VERSION=stable SETUP_CMD='test' bottleneck=yes NUMPY_VERSION=1.8 + before_install: # Use utf8 encoding. Should be default, but this is insurance against @@ -90,6 +97,10 @@ install: # YT - if [[ $SETUP_CMD != egg_info ]] && [[ $TRAVIS_PYTHON_VERSION == 2.7 ]] && [[ $NUMPY_VERSION == 1.8 ]]; then $CONDA_INSTALL numpy=$NUMPY_VERSION yt; fi + # Bottleneck + # asmeurer currently (8/26/2014) supports numpy 1.8 + - if [[ $SETUP_CMD != egg_info ]] && [[ $BOTTLENECK == yes ]] && [[ $NUMPY_VERSION == 1.8 ]]; then $CONDA_INSTALL --channel https://conda.binstar.org/asmeurer bottleneck; fi + # OPTIONAL DEPENDENCIES # Here you can add any dependencies your package may have. You can use # conda for packages available through conda, or pip for any other diff --git a/spectral_cube/spectral_cube.py b/spectral_cube/spectral_cube.py index bfb6e8119..f3d61ea52 100644 --- a/spectral_cube/spectral_cube.py +++ b/spectral_cube/spectral_cube.py @@ -613,7 +613,9 @@ def median(self, axis=None, **kwargs): projection=True, check_endian=True, **kwargs) except ImportError: - return self.apply_function(np.median, axis=axis, **kwargs) + result = self.apply_function(np.median, axis=axis, **kwargs) + + return result def percentile(self, q, axis=None, **kwargs): """ diff --git a/spectral_cube/tests/test_spectral_cube.py b/spectral_cube/tests/test_spectral_cube.py index 9c666235d..73eb58162 100644 --- a/spectral_cube/tests/test_spectral_cube.py +++ b/spectral_cube/tests/test_spectral_cube.py @@ -22,6 +22,12 @@ yt_version = StrictVersion('0.0.0') ytOK = False +try: + import bottleneck + bottleneckOK = True +except ImportError: + bottleneckOK = False + def cube_and_raw(filename): p = path(filename) @@ -475,3 +481,37 @@ def test_ds9region(): #region = 'circle(2,2,2)' #subcube = cube.subcube_from_ds9region(region) + +@pytest.mark.skipif(not bottleneckOK, reason='Bottleneck could not be imported') +def test_endians(): + """ + Test that the endianness checking returns something in Native form + (this is only needed for non-numpy functions that worry about the + endianness of their data) + + WARNING: Because the endianness is machine-dependent, this may fail on + different architectures! This is because numpy automatically converts + little-endian to native in the dtype parameter; I need a workaround for + this. + """ + big = np.array([[[1],[2]]], dtype='>f4') + lil = np.array([[[1],[2]]], dtype='' + assert xlil.dtype.byteorder == '='