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

ENH: add Epoch.__len__ #614

Merged
merged 1 commit into from
Jun 7, 2013
Merged

Conversation

christianbrodbeck
Copy link
Member

Consistent with indexing and iteration behavior.

@larsoner
Copy link
Member

larsoner commented Jun 4, 2013

LGTM

@dengemann
Copy link
Member

@christianmbrodbeck I proposed this one a few months ago and before me someone else did. Both times -1 ...

@dengemann
Copy link
Member

please consider #253

@christianbrodbeck
Copy link
Member Author

@dengemann What is the argument against it? Or do you remember the specific PRs?

@dengemann
Copy link
Member

see #253 --- bad experiences with dropped bads --- IIRC @agramfort and @mluessi had this before and removed it ...

@christianbrodbeck
Copy link
Member Author

Ok, bad-dropped. That's why I added the warning, to be consistent with indexing behavior (which indexes the events and issues a warning). If you think that length should be more restrictive it could raise an error if bads have not been dropped? I still think it would be useful when working with preload=True.

@larsoner
Copy link
Member

larsoner commented Jun 4, 2013

Throwing an error sounds like the safest behavior to me. We'll see what @agramfort and @mluessi think about it.

@dengemann
Copy link
Member

taking the devil's advocate's role: what's a len method that only works conditionally. In my scripts I quite often change preload flags, so I would never use this as it would imply unnecessary conditionals ...

@larsoner
Copy link
Member

larsoner commented Jun 4, 2013

Yeah, I think that would be a feature and not a bug, in the sense that you wouldn't want the len() method to work unless epochs have bad events dropped. Thus it would be a feature for people who always preload epochs or drop bad epochs from them (I am one of these people) while being protected against people using it incorrectly. That being said, I'm not sure I'd use the feature for things I do now, but who knows in the future.

@dengemann
Copy link
Member

... continuing: then this is YGNI?

@larsoner
Copy link
Member

larsoner commented Jun 4, 2013

Well, I maybe ain't gonna need it, but apparently @christianmbrodbeck has a use case...?

@dengemann
Copy link
Member

Please don't get me wrong -- I would like it. Trying to accumulate pros

@agramfort
Copy link
Member

I am still not convinced due the conditioning issue raised by @dengemann

Should we vote for it, i vote for an exception more than a warning of inaccurate result.

Also there is no test.

My vote is -0.5 :)

@larsoner
Copy link
Member

larsoner commented Jun 6, 2013

My vote is 0.0 (indifference). If abstention isn't allowed, I'll go with +0.5. I agree that it should be an exception instead of a warning if they try to get len() without bads dropped. @mluessi what do you think? If your opposition is not strong, @dengemann and @christianmbrodbeck's votes for might win the day...

@dengemann
Copy link
Member

Yeah, thinking about it for a few days, subcortically, unconsciously, etc., I'm not opposed to it. If we add an exception that should be fine. In a certain sense that would be pythonic since getting exceptions from invoking len can also happen in the world of builtin types. + 0.5

@agramfort
Copy link
Member

ok fair enough. Let me know when it's an exception so we can merge.

@christianbrodbeck
Copy link
Member Author

Made it an exception and added tests.

agramfort added a commit that referenced this pull request Jun 7, 2013
@agramfort agramfort merged commit 169f2d2 into mne-tools:master Jun 7, 2013
@agramfort
Copy link
Member

thanks !

@mluessi
Copy link
Contributor

mluessi commented Jun 7, 2013

PS: I was +1 for merge as long as it throws an exception as well.

@christianbrodbeck christianbrodbeck deleted the eplen branch June 7, 2013 14:23
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