Skip to content
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

MRG: Test constant consistency #5332

Merged
merged 14 commits into from
Sep 13, 2018
Merged

MRG: Test constant consistency #5332

merged 14 commits into from
Sep 13, 2018

Conversation

larsoner
Copy link
Member

This test should pass.

@agramfort look at XXX in the code to see the inconsistencies identified. I will email the MEGIN folks about this, and open a PR to fiff-constants to fix them.

WIP until we can make some or all of the XXX below go away.

@codecov
Copy link

codecov bot commented Jul 10, 2018

Codecov Report

Merging #5332 into master will increase coverage by 0.62%.
The diff coverage is 96.66%.

@@            Coverage Diff             @@
##           master    #5332      +/-   ##
==========================================
+ Coverage   87.67%   88.29%   +0.62%     
==========================================
  Files         360      361       +1     
  Lines       66898    67068     +170     
  Branches    11320    11364      +44     
==========================================
+ Hits        58654    59220     +566     
+ Misses       5445     5023     -422     
- Partials     2799     2825      +26

val = [kind, dtype, unit]
if id_ not in tag_dups:
assert id_ not in tags, (tags.get(id_), val)
tags[id_] = val
Copy link
Member

Choose a reason for hiding this comment

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

you cannot fuse / merge the 3 with code blocks to avoid the duplication?

Copy link
Member Author

Choose a reason for hiding this comment

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

The formats and exceptions differ so it would lead to more branching. They have more things different than they have in common so I don't think it would make things clearer.

@agramfort
Copy link
Member

agramfort commented Jul 11, 2018 via email

@larsoner larsoner changed the title WIP: Test constant consistency MRG: Test constant consistency Sep 11, 2018
@larsoner larsoner changed the title MRG: Test constant consistency WIP: Test constant consistency Sep 11, 2018
@larsoner larsoner changed the title WIP: Test constant consistency MRG: Test constant consistency Sep 11, 2018
'FIFFV_MNE_COORD_MRI_VOXEL',
'FIFFV_MNE_COORD_RAS',
'FIFFV_MNE_COORD_TUFTS_EEG',
)
Copy link
Member Author

Choose a reason for hiding this comment

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

@agramfort this is the to-do list for fiff-constants now that I have added tests for everything, I cannot find these in that repo :(

But I think it should just require a few more enums in the fiff-constants to get most of these.

Copy link
Member

Choose a reason for hiding this comment

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

ok

this_enum = name.split('_')[1].lower()
assert val in enums[this_enum], (name, val)
elif name.startswith('FWD_'):
# XXX remove from FIFF to forward.py namespace at some point?
Copy link
Member Author

Choose a reason for hiding this comment

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

@agramfort one more decision point: We currently pollute the FIFF namespace with FIFF.FWD_ values that are not part of the FIFF spec and are not written to disk. Can we just make a new FWD. bunch in mne/forward/forward.py for these? This will break things if people use FIFF.FWD_ in their own code somewhere but I doubt it's done.

Copy link
Member

Choose a reason for hiding this comment

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

agreed.

d = _frombuffer_rows(fid, tag.size, dtype='>c', shape=shape, rlims=rlims)
return text_type(d.tostring().decode('utf-8', 'ignore'))
return text_type(d.tostring().decode('latin1', 'ignore'))
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 @agramfort I saw in the official docs that strings are written this way, not using UTF-8, so I have changed it :(

Copy link
Member

Choose a reason for hiding this comment

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

ok. Do we test IO with utf8 characters?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep though I just pushed a commit to more explicitly test it

Copy link
Member

Choose a reason for hiding this comment

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

this will not break the IO of old files?

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 might make some of the characters look different. But either way (what we have in master vs what this PR does) some files are broken on read and write. The difference is that what this PR does follows the FIF spec, what we had before did not. So this should probably be in whats_new.rst under the BUG section.

@larsoner
Copy link
Member Author

This can be merged while we wait for mne-tools/fiff-constants#8 to go in. Once that's in, I can remove the remaining XXX here.

Currently we just verify that all of our constants are in fiff-constants (other than the XXX exceptions). In the future we might want to:

  1. make sure we completely represent some of the fiff-constants fields, such as coils
  2. ensure that the coils all have entries in coil_def.dat

@agramfort
Copy link
Member

agramfort commented Sep 12, 2018 via email

@agramfort agramfort merged commit 8da6623 into mne-tools:master Sep 13, 2018
@agramfort
Copy link
Member

thanks a lot @larsoner !

@larsoner larsoner deleted the constants branch September 13, 2018 10:44
wmvanvliet pushed a commit to wmvanvliet/mne-python that referenced this pull request Sep 14, 2018
* ENH: Test constant consistency

* FIX: Update names

* FIX: Tests

* FIX: Fix constant checks

* FIX: Last fixes in this round

* ENH: Make new FWD namespace

* FIX: Use codeload

* FIX: Better redirect following

* FIX: String encoding

* FIX: Better alias

* FIX: Clearer unicode test

* FIX: Ancient pytest

* FIX: Old Pytest

* DOC: whats_new.rst
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.

2 participants