Skip to content

MRG: testing on numpy 1.12 plus fixes #423

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 16, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ sudo: false
cache:
directories:
- $HOME/.cache/pip

addons:
apt:
packages:
- libhdf5-serial-dev

# For numpy --pre wheels
- libatlas-base-dev
env:
global:
- DEPENDS="numpy scipy matplotlib h5py"
Expand Down Expand Up @@ -45,6 +45,10 @@ matrix:
- python: 2.7
env:
- PYDICOM="v1.0"
# test against pre-release builds
- python: 2.7
env:
- EXTRA_PIP_FLAGS="--pre"
# Documentation doctests
- python: 2.7
env:
Expand All @@ -71,7 +75,7 @@ before_install:
- python --version # just to check
- pip install -U pip wheel # upgrade to latest pip find 3.5 wheels; wheel to avoid errors
- retry pip install nose flake8 # always
- wheelhouse_pip_install $DEPENDS
- wheelhouse_pip_install $EXTRA_PIP_FLAGS $DEPENDS
# pydicom <= 0.9.8 doesn't install on python 3
- if [ "${TRAVIS_PYTHON_VERSION:0:1}" == "2" ]; then
if [ "$PYDICOM" == "1" ]; then
Expand All @@ -92,13 +96,13 @@ install:
elif [ "$INSTALL_TYPE" == "sdist" ]; then
python setup_egg.py egg_info # check egg_info while we're here
python setup_egg.py sdist
wheelhouse_pip_install dist/*.tar.gz
wheelhouse_pip_install $EXTRA_PIP_FLAGS dist/*.tar.gz
elif [ "$INSTALL_TYPE" == "wheel" ]; then
pip install wheel
python setup_egg.py bdist_wheel
wheelhouse_pip_install dist/*.whl
wheelhouse_pip_install $EXTRA_PIP_FLAGS dist/*.whl
elif [ "$INSTALL_TYPE" == "requirements" ]; then
wheelhouse_pip_install -r requirements.txt
wheelhouse_pip_install $EXTRA_PIP_FLAGS -r requirements.txt
python setup.py install
fi
# Point to nibabel data directory
Expand Down
5 changes: 3 additions & 2 deletions nibabel/nicom/dicomwrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
processing that needs to raise an error, should be in a method, rather
than in a property, or property-like thing.
"""
from __future__ import division

import operator

Expand Down Expand Up @@ -724,7 +725,7 @@ class MosaicWrapper(SiemensWrapper):
Adds attributes:

* n_mosaic : int
* mosaic_size : float
* mosaic_size : int
"""
is_mosaic = True

Expand Down Expand Up @@ -758,7 +759,7 @@ def __init__(self, dcm_data, csa_header=None, n_mosaic=None):
'header; is this really '
'Siemens mosiac data?')
self.n_mosaic = n_mosaic
self.mosaic_size = np.ceil(np.sqrt(n_mosaic))
self.mosaic_size = int(np.ceil(np.sqrt(n_mosaic)))

@one_time
def image_shape(self):
Expand Down
3 changes: 2 additions & 1 deletion nibabel/orientations.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,8 @@ def inv_ornt_aff(ornt, shape):
# ornt indicates the transpose that has occurred to get the current
# ordering, relative to canonical, so we just use that.
# undo_reorder is a row permutatation matrix
undo_reorder = np.eye(p + 1)[list(ornt[:, 0]) + [p], :]
axis_transpose = [int(v) for v in ornt[:, 0]]
undo_reorder = np.eye(p + 1)[axis_transpose + [p], :]
undo_flip = np.diag(list(ornt[:, 1]) + [1.0])
center_trans = -(shape - 1) / 2.0
undo_flip[:p, p] = (ornt[:, 1] * center_trans) - center_trans
Expand Down
8 changes: 8 additions & 0 deletions nibabel/tests/test_fileslice.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@
from io import BytesIO
from itertools import product
from functools import partial
from distutils.version import LooseVersion

import numpy as np

# np > 1.11 makes double ellipsis illegal in indices
HAVE_NP_GT_1p11 = LooseVersion(np.__version__) > '1.11'

from ..fileslice import (is_fancy, canonical_slicers, fileslice,
predict_shape, read_segments, _positive_slice,
threshold_heuristic, optimize_slicer, slice2len,
Expand Down Expand Up @@ -41,7 +45,11 @@ def test_is_fancy():
for slice0 in slices:
_check_slice(slice0)
_check_slice((slice0,)) # tuple is same
# Double ellipsis illegal in np 1.12dev - set up check for that case
maybe_bad = HAVE_NP_GT_1p11 and slice0 is Ellipsis
for slice1 in slices:
if maybe_bad and slice1 is Ellipsis:
continue
_check_slice((slice0, slice1))
assert_false(is_fancy((None,)))
assert_false(is_fancy((None, 1)))
Expand Down
12 changes: 9 additions & 3 deletions tools/travis_tools.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# Tools for working with travis-ci
export WHEELHOST="travis-wheels.scikit-image.org"
export WHEELHOUSE="http://${WHEELHOST}/"
WHEELHOSTS="travis-wheels.scikit-image.org travis-dev-wheels.scipy.org"

PIP_FLAGS="--timeout=60 --no-index"

for host in $WHEELHOSTS; do
PIP_FLAGS="${PIP_FLAGS} --trusted-host ${host} --find-links=http://${host}"
done


retry () {
# https://gist.github.com/fungusakafungus/1026804
Expand All @@ -22,5 +28,5 @@ retry () {

wheelhouse_pip_install() {
# Install pip requirements via travis wheelhouse
retry pip install --timeout=60 --no-index --trusted-host $WHEELHOST --find-links $WHEELHOUSE $@
retry pip install $PIP_FLAGS $@
}