Skip to content

Commit

Permalink
Merge pull request #427 from matthew-brett/test-pre-wheels
Browse files Browse the repository at this point in the history
MRG: test against pre-release numpy / scipy

Use pre-release numpy / scipy wheels for testing.
  • Loading branch information
matthew-brett committed Mar 10, 2017
2 parents d09cb68 + 0679948 commit 281276b
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 27 deletions.
27 changes: 18 additions & 9 deletions .travis.yml
Expand Up @@ -5,11 +5,6 @@
# - There can't be any leading "-"s - All newlines will be removed, so use
# ";"s
sudo: false # To use travis container infrastructure
addons:
apt:
packages:
- libblas-dev
- liblapack-dev
language: python
cache:
directories:
Expand All @@ -18,6 +13,10 @@ env:
global:
- DEPENDS="numpy scipy sympy matplotlib nibabel"
- INSTALL_TYPE="setup"
- EXTRA_WHEELS="https://5cf40426d9f06eb7461d-6fe47d9331aba7cd62fc36c7196769e4.ssl.cf2.rackcdn.com"
- PRE_WHEELS="https://7933911d6844c6c53a7d-47bd50c35cd79bd838daf386af554a83.ssl.cf2.rackcdn.com"
- EXTRA_PIP_FLAGS="--find-links=$EXTRA_WHEELS"
- PRE_PIP_FLAGS="--pre $EXTRA_PIP_FLAGS --find-links $PRE_WHEELS"
python:
- 3.4
- 3.5
Expand All @@ -38,6 +37,11 @@ matrix:
- python: 3.4
env:
- NIPY_EXTERNAL_LAPACK=1
addons:
apt:
packages:
- libblas-dev
- liblapack-dev
- python: 2.7
env:
- INSTALL_TYPE=sdist
Expand All @@ -51,6 +55,10 @@ matrix:
- INSTALL_TYPE=requirements
- DEPENDS=
- python: 3.6
# test 3.5 against pre-release builds of everything
- python: 3.5
env:
- EXTRA_PIP_FLAGS="$PRE_PIP_FLAGS"

before_install:
- source tools/travis_tools.sh
Expand All @@ -62,9 +70,9 @@ before_install:
- pip install -U pip
- pip install nose mock # always
- if [ -n "$PRE_DEPENDS" ]; then
pip install $PRE_DEPENDS;
pip install $EXTRA_PIP_FLAGS $PRE_DEPENDS;
fi
- pip install $DEPENDS
- pip install $EXTRA_PIP_FLAGS $DEPENDS
- if [ "${COVERAGE}" == "1" ]; then
pip install coverage;
pip install coveralls codecov;
Expand All @@ -78,12 +86,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
pip install dist/*.tar.gz
pip install $EXTRA_PIP_FLAGS dist/*.tar.gz
elif [ "$INSTALL_TYPE" == "wheel" ]; then
pip install wheel
python setup_egg.py bdist_wheel
pip install dist/*.whl
pip install $EXTRA_PIP_FLAGS dist/*.whl
elif [ "$INSTALL_TYPE" == "requirements" ]; then
pip install $EXTRA_PIP_FLAGS -r requirements.txt
pip install -r requirements.txt
python setup.py install
fi
Expand Down
2 changes: 0 additions & 2 deletions nipy/algorithms/diagnostics/tsdiffplot.py
Expand Up @@ -68,11 +68,9 @@ def xmax_labels(ax, val, xlabel, ylabel):

# slice plots min max mean
ax = axes[3]
ax.hold(True)
ax.plot(np.mean(scaled_slice_diff, 0), 'k')
ax.plot(np.min(scaled_slice_diff, 0), 'b')
ax.plot(np.max(scaled_slice_diff, 0), 'r')
ax.hold(False)
xmax_labels(ax, S+1,
'Slice number',
'Max/mean/min \n slice variation')
Expand Down
2 changes: 1 addition & 1 deletion nipy/algorithms/group/parcel_analysis.py
Expand Up @@ -46,7 +46,7 @@ def _gaussian_filter(x, msk, sigma):
x[msk] = 0.
gx = nd.gaussian_filter(x, sigma)
norma = 1 - nd.gaussian_filter(msk.astype(float), sigma)
gx[True - msk] /= norma[True - msk]
gx[~msk] /= norma[~msk]
gx[msk] = 0.
return gx

Expand Down
4 changes: 2 additions & 2 deletions nipy/algorithms/segmentation/tests/test_segmentation.py
Expand Up @@ -44,11 +44,11 @@ def _test_brain_seg(model, niters=3, beta=0, ngb_size=6, init_params=None,
_check_dims(S.sigma, 1, S.mixmat.shape[0])
# Check that probabilities are zero outside the mask and sum up to
# one inside the mask
assert_almost_equal(S.ppm[True - S.mask].sum(-1).max(), 0)
assert_almost_equal(S.ppm[~S.mask].sum(-1).max(), 0)
assert_almost_equal(S.ppm[S.mask].sum(-1).min(), 1)
# Check that labels are zero outside the mask and > 1 inside the
# mask
assert_almost_equal(S.label[True - S.mask].max(), 0)
assert_almost_equal(S.label[~S.mask].max(), 0)
assert_almost_equal(S.label[S.mask].min(), 1)


Expand Down
2 changes: 1 addition & 1 deletion nipy/algorithms/statistics/formula/formulae.py
Expand Up @@ -734,7 +734,7 @@ def _setup_design(self):

# This renaming is here principally because of the intercept.

random_offset = np.random.random_integers(low=0, high=2**30)
random_offset = np.random.randint(low=0, high=2**30)

terms = getterms(self.mean)

Expand Down
2 changes: 1 addition & 1 deletion nipy/algorithms/statistics/tests/test_intrinsic_volumes.py
Expand Up @@ -39,7 +39,7 @@ def randombox(shape):
"""
Generate a random box, returning the box and the edge lengths
"""
edges = [np.random.random_integers(0, shape[j], size=(2,))
edges = [np.random.randint(0, shape[j] + 1, size=(2,))
for j in range(len(shape))]

for j in range(len(shape)):
Expand Down
17 changes: 9 additions & 8 deletions nipy/algorithms/tests/test_kernel_smooth.py
Expand Up @@ -3,7 +3,7 @@
""" Test for smoothing with kernels """
from __future__ import absolute_import
import numpy as np
from numpy.random import random_integers as randint
from numpy.random import randint

from ... import load_image
from ..kernel_smooth import LinearFilter, sigma2fwhm, fwhm2sigma
Expand Down Expand Up @@ -76,20 +76,21 @@ def test_kernel():
tol = 0.9999
sdtol = 1.0e-8
for x in range(6):
shape = randint(30,60,(3,))
shape = randint(30, 60 + 1, (3,))
# pos of delta
ii, jj, kk = randint(11,17, (3,))
ii, jj, kk = randint(11, 17 + 1, (3,))
# random affine coordmap (diagonal and translations)
coordmap = AffineTransform.from_start_step('ijk', 'xyz',
randint(5,20,(3,))*0.25,
randint(5,10,(3,))*0.5)
coordmap = AffineTransform.from_start_step(
'ijk', 'xyz',
randint(5, 20 + 1, (3,)) * 0.25,
randint(5, 10 + 1, (3,)) * 0.5)
# delta function in 3D array
signal = np.zeros(shape)
signal[ii,jj,kk] = 1.
signal = Image(signal, coordmap=coordmap)
# A filter with coordmap, shape matched to image
kernel = LinearFilter(coordmap, shape,
fwhm=randint(50,100)/10.)
kernel = LinearFilter(coordmap, shape,
fwhm=randint(50, 100 + 1) / 10.)
# smoothed normalized 3D array
ssignal = kernel.smooth(signal).get_data()
ssignal[:] *= kernel.norms[kernel.normalization]
Expand Down
1 change: 1 addition & 0 deletions nipy/core/image/image.py
Expand Up @@ -402,6 +402,7 @@ def __iter__(self):

def __eq__(self, other):
return (isinstance(other, self.__class__)
and self.shape == other.shape
and np.all(self.get_data() == other.get_data())
and np.all(self.affine == other.affine)
and (self.axes.coord_names == other.axes.coord_names))
Expand Down
2 changes: 1 addition & 1 deletion nipy/labs/datasets/volumes/tests/test_volume_grid.py
Expand Up @@ -62,7 +62,7 @@ def test_trivial_grid():
img = VolumeGrid(data=data,
transform=identity,
)
x, y, z = np.random.random_integers(N, size=(3, 10)) - 1
x, y, z = np.random.randint(1, N + 1, size=(3, 10)) - 1
data_ = img.values_in_world(x, y, z)
# Check that passing in arrays with different shapes raises an error
yield np.testing.assert_raises, ValueError, \
Expand Down
4 changes: 2 additions & 2 deletions nipy/modalities/fmri/hemodynamic_models.py
Expand Up @@ -34,7 +34,7 @@ def _gamma_difference_hrf(tr, oversampling=16, time_length=32., onset=0.,
hrf sampling on the oversampled time grid
"""
dt = tr / oversampling
time_stamps = np.linspace(0, time_length, float(time_length) / dt)
time_stamps = np.linspace(0, time_length, int(float(time_length) / dt))
time_stamps -= onset / dt
hrf = gamma.pdf(time_stamps, delay / dispersion, dt / dispersion) - \
ratio * gamma.pdf(
Expand Down Expand Up @@ -177,7 +177,7 @@ def _sample_condition(exp_condition, frametimes, oversampling=16,

hr_frametimes = np.linspace(frametimes.min() + min_onset,
frametimes.max() * (1 + 1. / (n - 1)),
n_hr)
int(n_hr))

# Get the condition information
onsets, durations, values = tuple(map(np.asanyarray, exp_condition))
Expand Down

0 comments on commit 281276b

Please sign in to comment.