Skip to content

[MRG+1] Convert channel names to str - #4427

Merged
larsoner merged 3 commits into
mne-tools:masterfrom
cbrnr:fix_montages
Jul 28, 2017
Merged

larsoner merged 3 commits into
mne-tools:masterfrom
cbrnr:fix_montages

Conversation

@cbrnr

@cbrnr cbrnr commented Jul 26, 2017

Copy link
Copy Markdown
Contributor

Fixes one issue mentioned in #4403 - the channel names had different types (np.str_, str, np.bytes_). This converts them all to simple str.

Comment thread mne/channels/montage.py Outdated
selection = selection[sel]
else:
ch_names_ = list(ch_names_)
ch_names_ = [str(ch) for ch in ch_names_] # convert names to str

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.

I think it would be cleaner to set tolist() in places we are using np.str.

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.

Does this take care of np.bytes_ too?

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.

Why are they bytes?

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.

Agreed, we shouldn't end up with bytes, it means some earlier function needs to be fixed.

FYI with bytes we usually use b.decode(utf-8) instead of str because it's UTF-8 on Python 2.

@codecov-io

codecov-io commented Jul 26, 2017 •

Copy link
Copy Markdown

Codecov Report

❗ No coverage uploaded for pull request base (master@1376596). Click here to learn what that means.
The diff coverage is 100%.

@@            Coverage Diff            @@
##             master    #4427   +/-   ##
=========================================
  Coverage          ?   82.75%           
=========================================
  Files             ?      349           
  Lines             ?    64252           
  Branches          ?     9907           
=========================================
  Hits              ?    53173           
  Misses            ?     8341           
  Partials          ?     2738

@cbrnr

cbrnr commented Jul 27, 2017 •

Copy link
Copy Markdown
Contributor Author

OK, done. All channel names are now lists of str. I have tested the extensions sfp, elc, txt, csd, and elp. The changes in hpts and loc/locs/eloc were straightforward, but please check. In the latter, I've set the dtype argument to the previously unused dtype variable; please confirm if this is correct. I don't have a bvef file to test, but I didn't change anything there anyway.

@agramfort

Copy link
Copy Markdown
Member

LGTM

@agramfort agramfort changed the title Convert channel names to str [MRG+1] Convert channel names to str Jul 27, 2017
@larsoner
larsoner merged commit 5d8d11a into mne-tools:master Jul 28, 2017
@larsoner

Copy link
Copy Markdown
Member

Thanks @cbrnr

@cbrnr
cbrnr deleted the fix_montages branch July 28, 2017 07:32
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