ENH: Speed up a couple of tests (#5348)

* ENH: Speed up a couple of tests

* FIX: Combine runs
This commit is contained in:
Eric Larson
2018-07-18 13:49:05 -04:00
committed by GitHub
parent 512fafcf40
commit 5389a456c4
5 changed files with 16 additions and 38 deletions
+2 -26
View File
@@ -22,18 +22,10 @@ matrix:
# Linux
- os: linux
env: CONDA_ENVIRONMENT="environment.yml"
SPLIT=0
- os: linux
env: CONDA_ENVIRONMENT="environment.yml"
SPLIT=1
# OSX conda
- os: osx
env: CONDA_ENVIRONMENT="environment.yml"
SPLIT=0
- os: osx
env: CONDA_ENVIRONMENT="environment.yml"
SPLIT=1
# PIP + non-default stim channel
# OPENBLAS_NUM_THREADS=1 avoid slowdowns:
@@ -41,13 +33,6 @@ matrix:
- 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"
@@ -55,21 +40,11 @@ matrix:
- os: linux
env: PYTHON_VERSION=2.7
CONDA_DEPENDENCIES="numpy=1.8 scipy=0.12 matplotlib=1.3 pandas=0.13 scikit-learn=0.15 pytest pytest-cov"
SPLIT=0
- os: linux
env: PYTHON_VERSION=2.7
CONDA_DEPENDENCIES="numpy=1.8 scipy=0.12 matplotlib=1.3 pandas=0.13 scikit-learn=0.15 pytest pytest-cov"
SPLIT=1
# Minimal
- os: linux
env: DEPS=minimial
CONDA_DEPENDENCIES="numpy scipy matplotlib pytest pytest-cov"
SPLIT=0
- os: linux
env: DEPS=minimial
CONDA_DEPENDENCIES="numpy scipy matplotlib pytest pytest-cov"
SPLIT=1
# Setup anaconda
before_install:
@@ -167,7 +142,8 @@ script:
CONDITION='not ultraslowtest';
fi;
- python -c "import mne; print(mne.sys_info())"
# Determine directories to test
# Determine directories to test (could use SPLIT=0 SPLIT=1 but currently
# we are fast enough, so disable it)
- if [ -z ${SPLIT} ]; then
USE_DIRS="mne/";
else
+1 -1
View File
@@ -1016,7 +1016,7 @@ class RawBTi(BaseRaw):
and :ref:`Logging documentation <tut_logging>` for more).
"""
@verbose
# @verbose
def __init__(self, pdf_fname, config_fname='config',
head_shape_fname='hs_file', rotation_x=0.,
translation=(0.0, 0.02, 0.11), convert=True,
+2 -1
View File
@@ -114,7 +114,8 @@ def test_raw():
assert_equal(ex.ch_names[:NCH], ra.ch_names[:NCH])
assert_array_almost_equal(ex.info['dev_head_t']['trans'],
ra.info['dev_head_t']['trans'], 7)
assert_dig_allclose(ex.info, ra.info)
assert len(ex.info['dig']) in (3563, 5154)
assert_dig_allclose(ex.info, ra.info, limit=100)
coil1, coil2 = [np.concatenate([d['loc'].flatten()
for d in r_.info['chs'][:NCH]])
for r_ in (ra, ex)]
+8 -7
View File
@@ -333,15 +333,16 @@ def test_ica_additional(method):
tempdir = _TempDir()
stop2 = 500
raw = read_raw_fif(raw_fname).crop(1.5, stop).load_data()
raw.del_proj() # avoid warnings
raw.annotations = Annotations([0.5], [0.5], ['BAD'])
# XXX This breaks the tests :(
# raw.info['bads'] = [raw.ch_names[1]]
test_cov = read_cov(test_cov_name)
events = read_events(event_name)
picks = pick_types(raw.info, meg=True, stim=False, ecg=False,
eog=False, exclude='bads')
eog=False, exclude='bads')[1::2]
epochs = Epochs(raw, events, None, tmin, tmax, picks=picks,
baseline=(None, 0), preload=True)
baseline=(None, 0), preload=True, proj=False)
epochs.decimate(3, verbose='error')
assert len(epochs) == 4
@@ -351,10 +352,10 @@ def test_ica_additional(method):
with warnings.catch_warnings(record=True):
ica.fit(epochs)
# for testing eog functionality
picks2 = pick_types(raw.info, meg=True, stim=False, ecg=False,
eog=True, exclude='bads')
picks2 = np.concatenate([picks, pick_types(raw.info, False, eog=True)])
epochs_eog = Epochs(raw, events[:4], event_id, tmin, tmax, picks=picks2,
baseline=(None, 0), preload=True)
del picks2
test_cov2 = test_cov.copy()
ica = ICA(noise_cov=test_cov2, n_components=3, max_pca_components=4,
@@ -413,7 +414,7 @@ def test_ica_additional(method):
raw_.append(raw_)
n_samples = raw_._data.shape[1]
with warnings.catch_warnings(record=True):
ica.fit(raw, picks=None, decim=3)
ica.fit(raw, picks=picks[:5], decim=3)
assert raw_._data.shape[1] == n_samples
# test expl var
@@ -440,11 +441,11 @@ def test_ica_additional(method):
ica = ICA(noise_cov=cov, n_components=2, max_pca_components=4,
n_pca_components=4, method=method, max_iter=1)
with warnings.catch_warnings(record=True): # ICA does not converge
ica.fit(raw, picks=picks, start=start, stop=stop2)
ica.fit(raw, picks=picks[:10], start=start, stop=stop2)
sources = ica.get_sources(epochs).get_data()
assert (ica.mixing_matrix_.shape == (2, 2))
assert (ica.unmixing_matrix_.shape == (2, 2))
assert (ica.pca_components_.shape == (4, len(picks)))
assert (ica.pca_components_.shape == (4, 10))
assert (sources.shape[1] == ica.n_components_)
for exclude in [[], [0], np.array([1, 2, 3])]:
+3 -3
View File
@@ -84,13 +84,13 @@ def _dig_sort_key(dig):
return (dig['kind'], dig['ident'])
def assert_dig_allclose(info_py, info_bin):
def assert_dig_allclose(info_py, info_bin, limit=None):
"""Assert dig allclose."""
# test dig positions
dig_py = sorted(info_py['dig'], key=_dig_sort_key)
dig_bin = sorted(info_bin['dig'], key=_dig_sort_key)
assert_equal(len(dig_py), len(dig_bin))
for ii, (d_py, d_bin) in enumerate(zip(dig_py, dig_bin)):
assert len(dig_py) == len(dig_bin)
for ii, (d_py, d_bin) in enumerate(zip(dig_py[:limit], dig_bin[:limit])):
for key in ('ident', 'kind', 'coord_frame'):
assert_equal(d_py[key], d_bin[key])
assert_allclose(d_py['r'], d_bin['r'], rtol=1e-5, atol=1e-5,