Skip to content

[ENH] ensure simulate_sparse_stc throws error when n_dipoles > len(labels) - #5976

Merged
massich merged 7 commits into
mne-tools:masterfrom
QB3:simulate_sparse_stc_assert_err
Feb 22, 2019
Merged

massich merged 7 commits into
mne-tools:masterfrom
QB3:simulate_sparse_stc_assert_err

Conversation

@QB3

@QB3 QB3 commented Feb 21, 2019

Copy link
Copy Markdown
Contributor

simulate_sparse_stc throws an assertion error when n_dipoles > len(labels) .
It should generate min(n_dipoles, len(labels)) dipoles.

Fixes #5953

Comment thread mne/simulation/source.py Resolved
@agramfort

Copy link
Copy Markdown
Member

@QB3 you'll need to make the PR mergeable not draft mode

@massich massich changed the title simulate_sparse_stc throws assertion error when n_dipoles > len(labels) [ENH] ensure simulate_sparse_stc throws error when n_dipoles > len(labels) Feb 21, 2019
@QB3
QB3 marked this pull request as ready for review February 21, 2019 13:49

@massich massich left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thx @QB3

Comment thread mne/simulation/tests/test_source.py Outdated
subjects_dir=subjects_dir) # no subject
pytest.raises(ValueError, simulate_sparse_stc, fwd['src'], len(labels),
times, labels=labels, location='foo') # bad location
pytest.raises(ValueError, simulate_sparse_stc, fwd['src'], len(labels) + 1,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The modern/clearer way to do this is:

with pytest.raises(ValueError, match='some regex str'):
    simulate_sparse_stc(...)

It's clearer and more precise.

Also there is a PEP8 error

https://travis-ci.org/mne-tools/mne-python/jobs/496513546#L3207

Otherwise LGTM

Comment thread mne/simulation/tests/test_source.py Outdated

pytest.raises(ValueError, simulate_sparse_stc, fwd['src'], len(labels) + 1,
times, labels=labels, random_state=random_state,
location=location, subjects_dir=subjects_dir)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this is not testes twice. @QB3 please remove this first one and only keep the with block

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

@codecov

codecov Bot commented Feb 21, 2019 •

Copy link
Copy Markdown

Codecov Report

Merging #5976 into master will increase coverage by 0.01%.
The diff coverage is 100%.

@@            Coverage Diff             @@
##           master    #5976      +/-   ##
==========================================
+ Coverage   88.82%   88.83%   +0.01%     
==========================================
  Files         401      401              
  Lines       72839    72871      +32     
  Branches    12172    12179       +7     
==========================================
+ Hits        64702    64738      +36     
+ Misses       5216     5215       -1     
+ Partials     2921     2918       -3

@larsoner

Copy link
Copy Markdown
Member

@QB3

QB3 commented Feb 22, 2019 •

Copy link
Copy Markdown
Contributor Author

I fixed the pep8 error, it seems to pass the tests now :)

@massich
massich merged commit 571a792 into mne-tools:master Feb 22, 2019
jeythekey pushed a commit to jeythekey/mne-python that referenced this pull request Apr 27, 2019
…ne-tools#5976)

This PR ensures that `simulate_sparse_stc` throws an error when `n_dipoles > len(labels)`

Fixes #5953r
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.

5 participants