Skip to content

Commit 0c6a551

Browse files
committed
Merge pull request #423 from matthew-brett/add-numpy-pre-testing
MRG: testing on numpy 1.12 plus fixes Numpy 1.12 (not yet released) breaks some stuff; have travis test against daily numpy builds and fix problems.
2 parents 23bc068 + c6582ca commit 0c6a551

File tree

5 files changed

+32
-12
lines changed

5 files changed

+32
-12
lines changed

.travis.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ sudo: false
1212
cache:
1313
directories:
1414
- $HOME/.cache/pip
15-
1615
addons:
1716
apt:
1817
packages:
1918
- libhdf5-serial-dev
20-
19+
# For numpy --pre wheels
20+
- libatlas-base-dev
2121
env:
2222
global:
2323
- DEPENDS="numpy scipy matplotlib h5py"
@@ -49,6 +49,10 @@ matrix:
4949
- python: 2.7
5050
env:
5151
- PYDICOM="v1.0"
52+
# test against pre-release builds
53+
- python: 2.7
54+
env:
55+
- EXTRA_PIP_FLAGS="--pre"
5256
# Documentation doctests
5357
- python: 2.7
5458
env:
@@ -75,7 +79,7 @@ before_install:
7579
- python --version # just to check
7680
- pip install -U pip wheel # upgrade to latest pip find 3.5 wheels; wheel to avoid errors
7781
- retry pip install nose flake8 # always
78-
- wheelhouse_pip_install $DEPENDS
82+
- wheelhouse_pip_install $EXTRA_PIP_FLAGS $DEPENDS
7983
# pydicom <= 0.9.8 doesn't install on python 3
8084
- if [ "${TRAVIS_PYTHON_VERSION:0:1}" == "2" ]; then
8185
if [ "$PYDICOM" == "1" ]; then
@@ -96,13 +100,13 @@ install:
96100
elif [ "$INSTALL_TYPE" == "sdist" ]; then
97101
python setup_egg.py egg_info # check egg_info while we're here
98102
python setup_egg.py sdist
99-
wheelhouse_pip_install dist/*.tar.gz
103+
wheelhouse_pip_install $EXTRA_PIP_FLAGS dist/*.tar.gz
100104
elif [ "$INSTALL_TYPE" == "wheel" ]; then
101105
pip install wheel
102106
python setup_egg.py bdist_wheel
103-
wheelhouse_pip_install dist/*.whl
107+
wheelhouse_pip_install $EXTRA_PIP_FLAGS dist/*.whl
104108
elif [ "$INSTALL_TYPE" == "requirements" ]; then
105-
wheelhouse_pip_install -r requirements.txt
109+
wheelhouse_pip_install $EXTRA_PIP_FLAGS -r requirements.txt
106110
python setup.py install
107111
fi
108112
# Point to nibabel data directory

nibabel/nicom/dicomwrappers.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
processing that needs to raise an error, should be in a method, rather
1212
than in a property, or property-like thing.
1313
"""
14+
from __future__ import division
1415

1516
import operator
1617

@@ -724,7 +725,7 @@ class MosaicWrapper(SiemensWrapper):
724725
Adds attributes:
725726
726727
* n_mosaic : int
727-
* mosaic_size : float
728+
* mosaic_size : int
728729
"""
729730
is_mosaic = True
730731

@@ -758,7 +759,7 @@ def __init__(self, dcm_data, csa_header=None, n_mosaic=None):
758759
'header; is this really '
759760
'Siemens mosiac data?')
760761
self.n_mosaic = n_mosaic
761-
self.mosaic_size = np.ceil(np.sqrt(n_mosaic))
762+
self.mosaic_size = int(np.ceil(np.sqrt(n_mosaic)))
762763

763764
@one_time
764765
def image_shape(self):

nibabel/orientations.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,8 @@ def inv_ornt_aff(ornt, shape):
220220
# ornt indicates the transpose that has occurred to get the current
221221
# ordering, relative to canonical, so we just use that.
222222
# undo_reorder is a row permutatation matrix
223-
undo_reorder = np.eye(p + 1)[list(ornt[:, 0]) + [p], :]
223+
axis_transpose = [int(v) for v in ornt[:, 0]]
224+
undo_reorder = np.eye(p + 1)[axis_transpose + [p], :]
224225
undo_flip = np.diag(list(ornt[:, 1]) + [1.0])
225226
center_trans = -(shape - 1) / 2.0
226227
undo_flip[:p, p] = (ornt[:, 1] * center_trans) - center_trans

nibabel/tests/test_fileslice.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,13 @@
77
from io import BytesIO
88
from itertools import product
99
from functools import partial
10+
from distutils.version import LooseVersion
1011

1112
import numpy as np
1213

14+
# np > 1.11 makes double ellipsis illegal in indices
15+
HAVE_NP_GT_1p11 = LooseVersion(np.__version__) > '1.11'
16+
1317
from ..fileslice import (is_fancy, canonical_slicers, fileslice,
1418
predict_shape, read_segments, _positive_slice,
1519
threshold_heuristic, optimize_slicer, slice2len,
@@ -41,7 +45,11 @@ def test_is_fancy():
4145
for slice0 in slices:
4246
_check_slice(slice0)
4347
_check_slice((slice0,)) # tuple is same
48+
# Double ellipsis illegal in np 1.12dev - set up check for that case
49+
maybe_bad = HAVE_NP_GT_1p11 and slice0 is Ellipsis
4450
for slice1 in slices:
51+
if maybe_bad and slice1 is Ellipsis:
52+
continue
4553
_check_slice((slice0, slice1))
4654
assert_false(is_fancy((None,)))
4755
assert_false(is_fancy((None, 1)))

tools/travis_tools.sh

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
# Tools for working with travis-ci
2-
export WHEELHOST="travis-wheels.scikit-image.org"
3-
export WHEELHOUSE="http://${WHEELHOST}/"
2+
WHEELHOSTS="travis-wheels.scikit-image.org travis-dev-wheels.scipy.org"
3+
4+
PIP_FLAGS="--timeout=60 --no-index"
5+
6+
for host in $WHEELHOSTS; do
7+
PIP_FLAGS="${PIP_FLAGS} --trusted-host ${host} --find-links=http://${host}"
8+
done
9+
410

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

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

0 commit comments

Comments
 (0)