8000 MRG: Fix bleeding-edge library bugs by larsoner · Pull Request #5811 · mne-tools/mne-python · GitHub
[go: up one dir, main page]

Skip to content

MRG: Fix bleeding-edge library bugs #5811

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 4 commits into from
Dec 21, 2018
Merged

MRG: Fix bleeding-edge library bugs #5811

merged 4 commits into from
Dec 21, 2018

Conversation

larsoner
Copy link
Member
@larsoner larsoner commented Dec 20, 2018

Since SciPy 1.2.0 just came out and NumPy 1.16.0 is in RC status, I updated all my libs locally and hunted down errors. This PR thus (in three separate commits):

  1. Fixes a bug with how we warm-started a sklearn var (we shouldn't ever set clf.coefs_ = None, sklearn can't handle this anymore). I also fixed PEP8 errors while in the file.
  2. Works around an obscure scipy.io.savemat bug when subselecting fields from a structured array in test_eeglab.py. I also fixed PEP8 errors while in the file.
  3. Unifies how we deal with matplotlib tests. I noticed mine had been horribly slow for some time. Turns out it's because I added interactive=True to my matplotlibrc. We now use a package-wide pytest fixture to set matplotlib params. This allows us to stop nesting our plt imports in tests, and no longer need matploltlib.use at the top of every test file that has viz tests. This makes our code more DRY and lowers maintenance and new-contributor burden! (I am really starting to appreciate all that pytest brings to the table.)

clf = MultiTaskLasso(alpha=alpha / len(M), tol=tol / sum_squared(M),
normalize=False, fit_intercept=False, max_iter=maxit,
warm_start=True)
clf.coef_ = init
if init is not None:
clf.coef_ = init.T
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI these +2 / -4 are the ones that fixed the mxne_optim bug

nopos_chanlocs[ind][dt[fld][0]] = vals[fld]
# In theory this should work and be simpler, but there is an obscure
# SciPy writing bug that pops up sometimes:
# nopos_chanlocs = np.array(chanlocs[['labels', 'Z']])
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And these are the lines that fixed the obscure savemat bug

@larsoner
Copy link
Member Author

Turns out that the "fix" for sklearn master does not work on the latest release, so I'll revert that change and fix sklearn directly instead.

@larsoner
Copy link
Member Author


import numpy as np
from numpy.testing import (assert_array_almost_equal, assert_array_equal,
assert_allclose, assert_equal)
import pytest
import matplotlib.pyplot as plt
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you need this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was moved up from below in test_find_layout

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Eventually there is lout.plot and plt.close)

@agramfort
Copy link
Member

@larsoner we had this conversation in the past that matplotlib should not be a hard dep of mne:

14ab6b6#diff-d859f370c264e1ee2bcb22eefd2c5c2d

does this PR change this?

@larsoner
Copy link
Member Author

No, just a dependency to run tests as usual

@agramfort
Copy link
Member

LGTM

ok for you @massich ?



@pytest.fixture(scope='package')
def matplotlib_config():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1000

@massich massich merged commit 1532f98 into mne-tools:master Dec 21, 2018
@larsoner larsoner deleted the dev branch December 21, 2018 15:06
larsoner added a commit that referenced this pull request Jan 15, 2019
* ENH: Bump maint Travis to 3.7

* FIX: Warnings

Contains parts of #5811 and #5831
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0