MRG: Add pip requirements.txt and Travis runs (#5251)

* ENH: Test pip

* FIX: Bash

* FIX: More bash plus xdist

* FIX: Tweak

* FIX: ?

* FIX: Qt

* FIX: Remove Travis NumPy

* FIX: Mayavi req numpy

* FIX: Requirements

* FIX: Local fixes

* FIX: Speed up more

* FIX: Remove unneeded option

* ENH: Speed up CTF reading by using structured arrays

* ENH: Speed up beamforming tests

* FIX: Uncomment

* WIP: Use an extra split to get it to pass

* FIX: CTF

* FIX: Speed up?

* FIX: Fix Travis

* FIX: Dipole

* FIX: No skips

* FIX: Switch from sample to testing
This commit is contained in:
Eric Larson
2018-07-13 08:42:07 -04:00
committed by Alexandre Gramfort
parent 1f70786a6b
commit 039cb1bf52
17 changed files with 168 additions and 212 deletions
+39 -20
View File
@@ -3,6 +3,7 @@ dist: trusty
sudo: false
cache:
apt: true
pip: true
env:
# TRAVIS_PYTHON_VERSION is only needed for neo's setup.py
global: PYTHON_VERSION=3.6 DISPLAY=:99.0 MNE_LOGGING_LEVEL=warning TEST_LOCATION=src
@@ -26,22 +27,30 @@ matrix:
env: CONDA_ENVIRONMENT="environment.yml"
SPLIT=1
# OSX
# OSX conda
- os: osx
env: CONDA_ENVIRONMENT="environment.yml"
SPLIT=0
- os: osx
env: CONDA_ENVIRONMENT="environment.yml"
SPLIT=1
# 2.7 + non-default stim channel
- os: linux
env: CONDA_ENVIRONMENT="environment2.yml" MNE_STIM_CHANNEL=STI101
SPLIT=0
- os: linux
env: CONDA_ENVIRONMENT="environment2.yml" MNE_STIM_CHANNEL=STI101
- os: osx
env: CONDA_ENVIRONMENT="environment.yml"
SPLIT=1
# PIP + non-default stim channel
# OPENBLAS_NUM_THREADS=1 avoid slowdowns:
# https://github.com/xianyi/OpenBLAS/issues/731
- os: linux
env: MNE_STIM_CHANNEL=STI101
OPENBLAS_NUM_THREADS=1
SPLIT=0
language: python
python: "3.6"
- os: linux
env: MNE_STIM_CHANNEL=STI101
OPENBLAS_NUM_THREADS=1
SPLIT=1
language: python
python: "3.6"
# 2.7 Old dependencies
- os: linux
env: PYTHON_VERSION=2.7
@@ -67,14 +76,20 @@ before_install:
- if [ "${TRAVIS_OS_NAME}" == "linux" ]; then
/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -screen 0 1400x900x24 -ac +extension GLX +render -noreset;
fi;
- git clone https://github.com/astropy/ci-helpers.git
- source ci-helpers/travis/setup_conda.sh
- if [ ! -z $CONDA_ENVIRONMENT ]; then
pip uninstall --yes mne;
fi;
- if [ "${TRAVIS_OS_NAME}" == "osx" ]; then
pip install --upgrade pyqt5>=5.10;
fi;
- if [ -z "$CONDA_ENVIRONMENT" ] && [ -z "$CONDA_DEPENDENCIES" ]; then
pip uninstall -y numpy;
pip install numpy scipy vtk;
pip install -r requirements.txt;
else
git clone https://github.com/astropy/ci-helpers.git;
source ci-helpers/travis/setup_conda.sh;
if [ ! -z "$CONDA_ENVIRONMENT" ]; then
pip uninstall --yes mne;
fi;
if [ "${TRAVIS_OS_NAME}" == "osx" ]; then
pip install --upgrade pyqt5>=5.10;
fi;
fi
# Don't source mne_setup_sh here because changing PATH etc. can't be done in a script
- if [ "${DEPS}" == "" ]; then
export MNE_ROOT="${PWD}/minimal_cmds";
@@ -158,8 +173,12 @@ script:
else
if [ "${SPLIT}" == "0" ]; then
MNE_DIRS=". beamformer channels commands connectivity datasets decoding forward gui inverse_sparse io";
else
elif [ "${SPLIT}" == "1" ]; then
MNE_DIRS="minimum_norm preprocessing realtime simulation stats time_frequency viz";
elif [ "${SPLIT}" == "2" ]; then
MNE_DIRS=".";
else
MNE_DIRS="beamformer channels commands connectivity datasets decoding forward gui inverse_sparse io";
fi;
USE_DIRS="";
for DIR in ${MNE_DIRS}; do
+1
View File
@@ -1,6 +1,7 @@
include *.rst
include CODE_OF_CONDUCT.md
include LICENSE.txt
include requirements.txt
include mne/__init__.py
recursive-include examples *.py
-44
View File
@@ -1,44 +0,0 @@
name: mne27
channels:
- defaults
dependencies:
- pip
- mkl
- numpy
- scipy
- matplotlib
- pyqt=5
- vtk
- pandas
- scikit-learn
- h5py
- pillow
- statsmodels
- jupyter
- pytest
- pytest-cov
- sphinx
- joblib
- psutil
- numpydoc
- flake8
- spyder
- numexpr
- pip:
- mne
- "git+https://github.com/enthought/traits.git@a7a83182048c08923953e302658b51b68c802132"
- "git+https://github.com/enthought/pyface.git@13a064de48adda3c880350545717d8cf8929afad"
- "git+https://github.com/enthought/traitsui.git@ee8ef0a34dfc1db18a8e2c0301cc18d96b7a3e2f"
- "git+https://github.com/enthought/mayavi.git"
- "git+https://github.com/nipy/PySurfer.git"
- nitime
- nibabel
- nilearn
- neo
- pytest-sugar
- pytest-faulthandler
- pydocstyle
- sphinx_bootstrap_theme
- git+https://github.com/sphinx-gallery/sphinx-gallery.git
- python-picard
- sphinx_fontawesome
+3
View File
@@ -77,6 +77,9 @@ def _simulate_data(fwd):
# Create an info object that holds information about the sensors
info = mne.create_info(fwd['info']['ch_names'], sfreq, ch_types='grad')
info.update(fwd['info']) # Merge in sensor position information
# heavily decimate sensors to make it much faster
info = mne.pick_info(info, np.arange(info['nchan'])[::5])
fwd = mne.pick_channels_forward(fwd, info['ch_names'])
# Run the simulated signal through the forward model, obtaining
# simulated sensor data.
+17 -18
View File
@@ -6,7 +6,8 @@ import numpy as np
from scipy import linalg
from scipy.spatial.distance import cdist
from numpy.testing import (assert_array_almost_equal, assert_array_equal,
assert_almost_equal, assert_allclose)
assert_almost_equal, assert_allclose,
assert_array_less)
import warnings
import mne
@@ -26,8 +27,6 @@ fname_raw = op.join(data_path, 'MEG', 'sample', 'sample_audvis_trunc_raw.fif')
fname_cov = op.join(data_path, 'MEG', 'sample', 'sample_audvis_trunc-cov.fif')
fname_fwd = op.join(data_path, 'MEG', 'sample',
'sample_audvis_trunc-meg-eeg-oct-4-fwd.fif')
fname_bem = op.join(data_path, 'subjects', 'sample', 'bem',
'sample-1280-1280-1280-bem-sol.fif')
fname_fwd_vol = op.join(data_path, 'MEG', 'sample',
'sample_audvis_trunc-meg-vol-7-fwd.fif')
fname_event = op.join(data_path, 'MEG', 'sample',
@@ -37,6 +36,9 @@ fname_label = op.join(data_path, 'MEG', 'sample', 'labels', 'Aud-lh.label')
warnings.simplefilter('always') # enable b/c these tests throw warnings
reject = dict(grad=4000e-13, mag=4e-12)
def _read_forward_solution_meg(*args, **kwargs):
fwd = mne.read_forward_solution(*args)
fwd = mne.convert_forward_solution(fwd, **kwargs)
@@ -67,18 +69,17 @@ def _get_data(tmin=-0.1, tmax=0.15, all_forward=True, epochs=True,
raw.info['bads'] = ['MEG 2443', 'EEG 053'] # 2 bad channels
# Set up pick list: MEG - bad channels
left_temporal_channels = mne.read_selection('Left-temporal')
picks = mne.pick_types(raw.info, meg=True, eeg=False, stim=True,
eog=True, ref_meg=False, exclude='bads',
selection=left_temporal_channels)
picks = mne.pick_types(raw.info, selection=left_temporal_channels)
picks = picks[::4] # decimate for speed
raw.pick_channels([raw.ch_names[ii] for ii in picks])
del picks
raw.info.normalize_proj() # avoid projection warnings
if epochs:
# Read epochs
epochs = mne.Epochs(
raw, events, event_id, tmin, tmax, proj=True,
baseline=(None, 0), preload=epochs_preload,
reject=dict(grad=4000e-13, mag=4e-12, eog=150e-6))
baseline=(None, 0), preload=epochs_preload, reject=reject)
if epochs_preload:
epochs.resample(200, npad=0, n_jobs=2)
epochs.crop(0, None)
@@ -195,7 +196,7 @@ def test_lcmv():
max_stc = stc.data[idx]
tmax = stc.times[np.argmax(max_stc)]
assert 0.09 < tmax < 0.105, tmax
assert 0.09 < tmax < 0.12, tmax
assert 0.9 < np.max(max_stc) < 3., np.max(max_stc)
if fwd is forward:
@@ -211,7 +212,7 @@ def test_lcmv():
max_stc = stc_normal.data[idx]
tmax = stc_normal.times[np.argmax(max_stc)]
assert 0.04 < tmax < 0.11, tmax
assert 0.04 < tmax < 0.12, tmax
assert 0.4 < np.max(max_stc) < 2., np.max(max_stc)
# The amplitude of normal orientation results should always be
@@ -228,7 +229,7 @@ def test_lcmv():
max_stc = np.abs(stc_max_power.data[idx])
tmax = stc.times[np.argmax(max_stc)]
assert 0.08 < tmax < 0.11, tmax
assert 0.08 < tmax < 0.12, tmax
assert 0.8 < np.max(max_stc) < 3., np.max(max_stc)
stc_max_power.data[:, :] = np.abs(stc_max_power.data)
@@ -243,7 +244,7 @@ def test_lcmv():
mean_stc_max_pow = \
stc_max_power.extract_label_time_course(label, fwd['src'],
mode='mean')
assert ((np.abs(mean_stc - mean_stc_max_pow) < 0.5).all())
assert_array_less(np.abs(mean_stc - mean_stc_max_pow), 0.6)
# Test NAI weight normalization:
filters = make_lcmv(evoked.info, fwd, data_cov, reg=0.01,
@@ -285,7 +286,7 @@ def test_lcmv():
max_stc = stc_sphere.data[idx]
tmax = stc_sphere.times[np.argmax(max_stc)]
assert 0.08 < tmax < 0.11, tmax
assert 0.08 < tmax < 0.15, tmax
assert 0.4 < np.max(max_stc) < 2., np.max(max_stc)
# Test if fixed forward operator is detected when picking normal or
@@ -478,17 +479,15 @@ def test_tf_lcmv():
# Set up pick list: MEG - bad channels
left_temporal_channels = mne.read_selection('Left-temporal')
picks = mne.pick_types(raw.info, meg=True, eeg=False,
stim=True, eog=True, exclude='bads',
selection=left_temporal_channels)
picks = mne.pick_types(raw.info, selection=left_temporal_channels)
picks = picks[::4] # decimate for speed
raw.pick_channels([raw.ch_names[ii] for ii in picks])
raw.info.normalize_proj() # avoid projection warnings
del picks
# Read epochs
epochs = mne.Epochs(raw, events, event_id, tmin, tmax, proj=True,
baseline=None, preload=False,
reject=dict(grad=4000e-13, mag=4e-12, eog=150e-6))
baseline=None, preload=False, reject=reject)
epochs.load_data()
freq_bins = [(4, 12), (15, 40)]
+2 -1
View File
@@ -97,7 +97,8 @@ def _gamma_map_opt(M, G, alpha, maxit=10000, tol=1e-6, update_mode=1,
n_active = active_set.size
G = G[:, gidx]
CM = alpha * np.eye(n_sensors) + np.dot(G * gammas[np.newaxis, :], G.T)
CM = np.dot(G * gammas[np.newaxis, :], G.T)
CM.flat[::n_sensors + 1] += alpha
# Invert CM keeping symmetry
U, S, V = linalg.svd(CM, full_matrices=False)
S = S[np.newaxis, :]
+4 -5
View File
@@ -6,8 +6,7 @@ import os.path as op
import pytest
import numpy as np
from numpy.testing import (assert_array_almost_equal, assert_equal,
assert_allclose)
from numpy.testing import assert_array_almost_equal, assert_allclose
import mne
from mne.datasets import testing
@@ -36,7 +35,7 @@ def _check_stc(stc, evoked, idx, ratio=50.):
order = np.argsort(amps)[::-1]
amps = amps[order]
verts = np.concatenate(stc.vertices)[order]
assert_equal(idx, verts[0], err_msg=str(list(verts)))
assert idx == verts[0], str(list(verts))
assert amps[0] > ratio * amps[1]
@@ -61,7 +60,7 @@ def test_gamma_map():
evoked = read_evokeds(fname_evoked, condition=0, baseline=(None, 0),
proj=False)
evoked.resample(50, npad=100)
evoked.crop(tmin=0.1, tmax=0.16) # crop to window around peak
evoked.crop(tmin=0.1, tmax=0.14) # crop to window around peak
cov = read_cov(fname_cov)
cov = regularize(cov, evoked.info)
@@ -103,7 +102,7 @@ def test_gamma_map_vol_sphere():
info = evoked.info
sphere = mne.make_sphere_model(r0=(0., 0., 0.), head_radius=0.080)
src = mne.setup_volume_source_space(subject=None, pos=15., mri=None,
src = mne.setup_volume_source_space(subject=None, pos=30., mri=None,
sphere=(0.0, 0.0, 0.0, 80.0),
bem=None, mindist=5.0,
exclude=2.0)
+40 -51
View File
@@ -69,61 +69,29 @@ def _read_filter(fid):
return f
def _read_channel(fid):
"""Read channel information."""
ch = dict()
ch['sensor_type_index'] = _read_int2(fid)
ch['original_run_no'] = _read_int2(fid)
ch['coil_type'] = _read_int(fid)
ch['proper_gain'] = _read_double(fid)[0]
ch['qgain'] = _read_double(fid)[0]
ch['io_gain'] = _read_double(fid)[0]
ch['io_offset'] = _read_double(fid)[0]
ch['num_coils'] = _read_int2(fid)
ch['grad_order_no'] = int(_read_int2(fid))
_read_int(fid) # pad
ch['coil'] = dict()
ch['head_coil'] = dict()
for coil in (ch['coil'], ch['head_coil']):
coil['pos'] = list()
coil['norm'] = list()
coil['turns'] = np.empty(CTF.CTFV_MAX_COILS)
coil['area'] = np.empty(CTF.CTFV_MAX_COILS)
for k in range(CTF.CTFV_MAX_COILS):
# It would have been wonderful to use meters in the first place
coil['pos'].append(_read_double(fid, 3) / 100.)
fid.seek(8, 1) # dummy double
coil['norm'].append(_read_double(fid, 3))
fid.seek(8, 1) # dummy double
coil['turns'][k] = _read_int2(fid)
_read_int(fid) # pad
_read_int2(fid) # pad
# Looks like this is given in cm^2
coil['area'][k] = _read_double(fid)[0] * 1e-4
return ch
def _read_comp_coeff(fid, d):
"""Read compensation coefficients."""
# Read the coefficients and initialize
d['ncomp'] = _read_int2(fid)
d['comp'] = list()
# Read each record
dt = np.dtype([
('sensor_name', 'S32'),
('coeff_type', '>i4'), ('d0', '>i4'),
('ncoeff', '>i2'),
('sensors', 'S%s' % CTF.CTFV_SENSOR_LABEL, CTF.CTFV_MAX_BALANCING),
('coeffs', '>f8', CTF.CTFV_MAX_BALANCING)])
comps = np.fromfile(fid, dt, d['ncomp'])
for k in range(d['ncomp']):
comp = dict()
d['comp'].append(comp)
comp['sensor_name'] = _read_string(fid, 32)
comp['coeff_type'] = _read_int(fid)
_read_int(fid) # pad
comp['ncoeff'] = _read_int2(fid)
comp['coeffs'] = np.zeros(comp['ncoeff'])
comp['sensors'] = [_read_string(fid, CTF.CTFV_SENSOR_LABEL)
for p in range(comp['ncoeff'])]
unused = CTF.CTFV_MAX_BALANCING - comp['ncoeff']
comp['sensors'] += [''] * unused
fid.seek(unused * CTF.CTFV_SENSOR_LABEL, 1)
comp['coeffs'][:comp['ncoeff']] = _read_double(fid, comp['ncoeff'])
fid.seek(unused * 8, 1)
comp['sensor_name'] = \
comps['sensor_name'][k].split(b'\x00')[0].decode('utf-8')
comp['coeff_type'] = comps['coeff_type'][k]
comp['ncoeff'] = comps['ncoeff'][k]
comp['sensors'] = [s.split(b'\x00')[0].decode('utf-8')
for s in comps['sensors'][k][:comp['ncoeff']]]
comp['coeffs'] = comps['coeffs'][k][:comp['ncoeff']]
comp['scanno'] = d['ch_names'].index(comp['sensor_name'])
@@ -194,16 +162,37 @@ def _read_res4(dsdir):
for k in range(res['nfilt']):
res['filters'].append(_read_filter(fid))
# Channel information
res['chs'] = list()
# Channel information (names, then data)
res['ch_names'] = list()
for k in range(res['nchan']):
res['chs'].append(dict())
ch_name = _read_string(fid, 32)
res['chs'][k]['ch_name'] = ch_name
res['ch_names'].append(ch_name)
_coil_dt = np.dtype([
('pos', '>f8', 3), ('d0', '>f8'),
('norm', '>f8', 3), ('d1', '>f8'),
('turns', '>i2'), ('d2', '>i4'), ('d3', '>i2'),
('area', '>f8')])
_ch_dt = np.dtype([
('sensor_type_index', '>i2'),
('original_run_no', '>i2'),
('coil_type', '>i4'),
('proper_gain', '>f8'),
('qgain', '>f8'),
('io_gain', '>f8'),
('io_offset', '>f8'),
('num_coils', '>i2'),
('grad_order_no', '>i2'), ('d0', '>i4'),
('coil', _coil_dt, CTF.CTFV_MAX_COILS),
('head_coil', _coil_dt, CTF.CTFV_MAX_COILS)])
chs = np.fromfile(fid, _ch_dt, res['nchan'])
for coil in (chs['coil'], chs['head_coil']):
coil['pos'] /= 100.
coil['area'] *= 1e-4
# convert to dict
chs = [dict(zip(chs.dtype.names, x)) for x in chs]
res['chs'] = chs
for k in range(res['nchan']):
res['chs'][k].update(_read_channel(fid))
res['chs'][k]['ch_name'] = res['ch_names'][k]
# The compensation coefficients
_read_comp_coeff(fid, res)
+5 -2
View File
@@ -1750,8 +1750,11 @@ def _cortex_parcellation(subject, n_parcel, hemis, vertices_, graphs,
vert_from = edge.pop(0)
# add neighbors within allowable distance
row = graph[vert_from, :]
for vert_to, dist in zip(row.indices, row.data):
# row = graph[vert_from, :]
# row_indices, row_data = row.indices, row.data
sl = slice(graph.indptr[vert_from], graph.indptr[vert_from + 1])
row_indices, row_data = graph.indices[sl], graph.data[sl]
for vert_to, dist in zip(row_indices, row_data):
vert_to_label = parc[vert_to]
# abort if the vertex is already occupied
+2 -2
View File
@@ -69,8 +69,8 @@ def _skip_check_picard(method):
if method == 'picard':
try:
import picard # noqa, analysis:ignore
except Exception:
raise SkipTest("Picard is not installed.")
except Exception as exp:
raise SkipTest("Picard is not installed (%s)." % (exp,))
@requires_sklearn
+9 -6
View File
@@ -7,11 +7,11 @@ import pytest
from mne import (Epochs, read_events, read_epochs, find_events, create_info,
pick_channels, pick_types)
pick_channels, pick_types, concatenate_raws)
from mne.io import RawArray, read_raw_fif
from mne.utils import run_tests_if_main
from mne.realtime import MockRtClient, RtEpochs
from mne.datasets import sample
from mne.datasets import testing
# Set our plotters to test mode
import matplotlib
@@ -320,11 +320,11 @@ def test_rejection(buffer_size):
assert_array_equal(rt_data, epochs_data)
@sample.requires_sample_data
def test_events_sampledata():
@testing.requires_testing_data
def test_events_long():
"""Test events."""
data_path = sample.data_path()
raw_fname = data_path + '/MEG/sample/sample_audvis_filt-0-40_raw.fif'
data_path = testing.data_path()
raw_fname = data_path + '/MEG/sample/sample_audvis_trunc_raw.fif'
raw = read_raw_fif(raw_fname, preload=True)
raw_tmin, raw_tmax = 0, 90
@@ -336,6 +336,9 @@ def test_events_sampledata():
stim=True, exclude=raw.info['bads'])
# load data with usual Epochs for later verification
raw = concatenate_raws([raw, raw.copy(), raw.copy(), raw.copy(),
raw.copy(), raw.copy()])
assert 110 < raw.times[-1] < 130
raw_cropped = raw.copy().crop(raw_tmin, raw_tmax)
events_offline = find_events(raw_cropped)
epochs_offline = Epochs(raw_cropped, events_offline, event_id=event_id,
+5 -5
View File
@@ -644,8 +644,9 @@ def test_compute_covariance_auto_reg():
@requires_version('sklearn', '0.15')
def test_cov_ctf():
"""Test basic cov computation on ctf data with/without compensation."""
raw = read_raw_ctf(ctf_fname, preload=True)
raw = read_raw_ctf(ctf_fname).crop(0., 2.).load_data()
events = make_fixed_length_events(raw, 99999)
assert len(events) == 2
ch_names = [raw.info['ch_names'][pick]
for pick in pick_types(raw.info, meg=True, eeg=False,
ref_meg=False)]
@@ -653,20 +654,19 @@ def test_cov_ctf():
for comp in [0, 1]:
raw.apply_gradient_compensation(comp)
epochs = Epochs(raw, events, None, -0.2, 0.2, preload=True)
noise_cov = compute_covariance(epochs, tmax=0., method=['shrunk'])
noise_cov = compute_covariance(epochs, tmax=0., method=['empirical'])
prepare_noise_cov(noise_cov, raw.info, ch_names)
raw.apply_gradient_compensation(0)
epochs = Epochs(raw, events, None, -0.2, 0.2, preload=True)
noise_cov = compute_covariance(epochs, tmax=0., method=['shrunk'])
noise_cov = compute_covariance(epochs, tmax=0., method=['empirical'])
raw.apply_gradient_compensation(1)
# TODO This next call in principle should fail.
prepare_noise_cov(noise_cov, raw.info, ch_names)
# make sure comps matrices was not removed from raw
if not raw.info['comps']:
raise RuntimeError('Comps matrices removed')
assert raw.info['comps'], 'Comps matrices removed'
run_tests_if_main()
+8 -1
View File
@@ -1,3 +1,4 @@
import os
import os.path as op
import warnings
@@ -170,7 +171,13 @@ def test_dipole_fitting():
axis=1)))]
amp_errs += [np.sqrt(np.mean((amp - d.amplitude) ** 2))]
gofs += [np.mean(d.gof)]
factor = 0.8
if os.getenv('TRAVIS', 'false').lower() == 'true' and \
'OPENBLAS_NUM_THREADS' in os.environ:
# XXX possibly some OpenBLAS numerical differences make
# things slightly worse for us
factor = 0.7
else:
factor = 0.8
assert dists[0] / factor >= dists[1], 'dists: %s' % dists
assert corrs[0] * factor <= corrs[1], 'corrs: %s' % corrs
assert gc_dists[0] / factor >= gc_dists[1] * 0.8, \
+2 -2
View File
@@ -774,8 +774,8 @@ def test_random_parcellation():
"""Test generation of random cortical parcellation."""
hemi = 'both'
n_parcel = 50
surface = 'white'
subject = 'sample'
surface = 'sphere.reg'
subject = 'sample_ds'
rng = np.random.RandomState(0)
# Parcellation
+1 -8
View File
@@ -26,7 +26,7 @@ from mne.utils import (set_log_level, set_log_file, _TempDir,
set_memmap_min_size, _get_stim_channel, _check_fname,
create_slices, _time_mask, random_permutation,
_get_call_line, compute_corr, sys_info, verbose,
check_fname, requires_ftp, get_config_path,
check_fname, get_config_path,
object_size, buggy_mkl_svd, _get_inst_data,
copy_doc, copy_function_doc_to_method_doc, ProgressBar)
@@ -519,13 +519,6 @@ def test_fetch_file_html():
_test_fetch('http://google.com')
@requires_ftp
@requires_good_network
def test_fetch_file_ftp():
"""Test file downloading over ftp."""
_test_fetch('ftp://speedtest.tele2.net/1KB.zip')
def test_sum_squared():
"""Test optimized sum of squares."""
X = np.random.RandomState(0).randint(0, 50, (3, 3))
+4 -47
View File
@@ -11,7 +11,6 @@ from collections import Iterable
from contextlib import contextmanager
from distutils.version import LooseVersion
from functools import wraps
import ftplib
from functools import partial
import hashlib
import inspect
@@ -1059,10 +1058,6 @@ requires_good_network = partial(
requires_module, name='good network connection',
call='if int(os.environ.get("MNE_SKIP_NETWORK_TESTS", 0)):\n'
' raise ImportError')
requires_ftp = partial(
requires_module, name='ftp downloading capability',
call='if int(os.environ.get("MNE_SKIP_FTP_TESTS", 0)):\n'
' raise ImportError')
requires_nitime = partial(requires_module, name='nitime')
requires_h5py = partial(requires_module, name='h5py')
requires_numpydoc = partial(requires_module, name='numpydoc')
@@ -1828,45 +1823,6 @@ def _get_terminal_width():
return shutil.get_terminal_size((80, 20)).columns
def _get_ftp(url, temp_file_name, initial_size, file_size, timeout,
verbose_bool):
"""Safely (resume a) download to a file from FTP."""
# Adapted from: https://pypi.python.org/pypi/fileDownloader.py
# but with changes
parsed_url = urllib.parse.urlparse(url)
file_name = os.path.basename(parsed_url.path)
server_path = parsed_url.path.replace(file_name, "")
unquoted_server_path = urllib.parse.unquote(server_path)
data = ftplib.FTP()
if parsed_url.port is not None:
data.connect(parsed_url.hostname, parsed_url.port, timeout=timeout)
else:
data.connect(parsed_url.hostname, timeout=timeout)
data.login()
if len(server_path) > 1:
data.cwd(unquoted_server_path)
data.sendcmd("TYPE I")
data.sendcmd("REST " + str(initial_size))
down_cmd = "RETR " + file_name
assert file_size == data.size(file_name)
progress = ProgressBar(file_size, initial_value=initial_size,
spinner=True, mesg='file_sizes',
verbose_bool=verbose_bool)
# Callback lambda function that will be passed the downloaded data
# chunk and will write it to file and update the progress bar
mode = 'ab' if initial_size > 0 else 'wb'
with open(temp_file_name, mode) as local_file:
def chunk_write(chunk):
return _chunk_write(chunk, local_file, progress)
data.retrbinary(down_cmd, chunk_write)
data.close()
sys.stdout.write('\n')
sys.stdout.flush()
def _get_http(url, temp_file_name, initial_size, file_size, timeout,
verbose_bool):
"""Safely (resume a) download to a file from http(s)."""
@@ -1997,9 +1953,10 @@ def _fetch_file(url, file_name, print_destination=True, resume=True,
else:
# Need to resume or start over
scheme = urllib.parse.urlparse(url).scheme
fun = _get_http if scheme in ('http', 'https') else _get_ftp
fun(url, temp_file_name, initial_size, file_size, timeout,
verbose_bool)
if scheme not in ('http', 'https'):
raise NotImplementedError('Cannot use %s' % (scheme,))
_get_http(url, temp_file_name, initial_size, file_size, timeout,
verbose_bool)
# check md5sum
if hash_ is not None:
+26
View File
@@ -0,0 +1,26 @@
numpy
scipy
matplotlib
mayavi
pyqt5
pyqt5-sip
sip
scikit-learn
nibabel
h5py
pandas
numexpr
python-picard
statsmodels
pytest
pytest-cov
pytest-sugar
joblib
psutil
numpydoc
https://api.github.com/repos/nipy/PySurfer/zipball/master
nitime
nilearn
neo
pydocstyle
flake8