Repository navigation
FIX: Addressing raw reading regression - #429
Conversation
There was a problem hiding this comment.
detail : I prefer the use of one.reshape rather than touching the attributes manually
There was a problem hiding this comment.
You probably know this, but the two methods actually differ in terms of their implications:
http://docs.scipy.org/doc/numpy/reference/generated/numpy.reshape.html
"If you want an error to be raise if the data is copied, you should assign the new shape to the shape attribute of the array."
Numpy actually checks to make sure that the new shape attribute will work in terms of returning a modified view instead of making a copy. That's why I used it here -- if we implement a change in the future in the reading functions that causes a copy to be necessary, it will slow down our code, and we should re-code the change if possible. Thus I see the error as a check on future changes. I figured if we get to that point and it's not possible to do it without a copy, we could then move to .reshape(). Does that make sense?
|
LGTM +1 for merge |
FIX: Addressing raw reading regression
@agramfort I was apparently too hasty in one assumption I made about raw reading. Specifically, the line
if this['ent'] is None:when reading throughraw.rawdirscan happen even if the skip is not being read (!). I had changed this to throw an error in a previous PR, since I thought that should only happen if skip was being read.The behavior I have it set to now is to wait until it gets a valid tag to choose the dtype (which fixes what would have been a regression before regarding assuming real dtype), and if no valid tags are ever read, it will return an array of zeros of the correct size. I could also have it throw a warning if no valid tags are ever read if we want.
It's a little hard to discern the changes I made since GitHub tracks indentation changes poorly. Basically I 1) indented the reading lines in one more, to only run if the tag is not
None(whereas before having it beNonewould have thrown an error), 2) moved the allocation to a helper function since it is now used in two places (on demand after finding a good tag, or after all tags are found to be invalid), and 3) speeding/cleaning up the calibration lines a tiny bit by moving it outside the loop.In any case, we don't have a test file with this property, so I can't really add a test for it. And I'm not the sole owner of the data file that I found the error on, so I can't add that to the test suite... but I can at least verify it now works on the file that used to throw an error.