Implement __getitem__ for Epoch#454
Conversation
|
Hello @apdavison! Thanks for updating the PR. Cheers ! There are no PEP8 issues in this Pull Request. 🍻 Comment last updated on March 01, 2018 at 11:30 Hours UTC |
|
Hi andrew. Could you fix conflict in the file. So it would trigered a new test on circleci ? |
|
I have a question about this, because I have been working on I noticed here that what you wrote works in Epoch for things like epoch[1], while it would raise an error in SpikeTrain, because when you create the new Epoch in A little example of what happens:
This is because the following happens in
Should it be like this or should a test for this be introduced? Apart from that I'd like to know if any of you has deeper knowledge of Again some code to illustrate what I mean: What currently happens:
If one would do the same as you did in Epoch for SpikeTrain, it would raise an error What happens SpikeTrain
On the other hand, calling things like I then tried creating a new SpikeTrain if I get a quantity by creating a list with a single entry:
This works for most cases, but it fails whenever calling |
|
I kept working on this problem and noticed that returning a SpikeTrain when st[int] is called would create more problems than it solves. So it seems to be fine that a scalar Quantity object is returned. But in my opinion this should be consistent across all neo objects, which means that also here in Epoch.getitem an Epoch should be returned only, when ep[slice] was called, not when ep[int] was called. Do you agree with this @apdavison @samuelgarcia? On a more general level, as I wrote in the previous comment, I want to ask if it makes sense to allow Epochs to be created with times being a scalar instead of an array. In class SpikeTrain there are checks that fail if times is not a list or an array, whereas in Epoch nothing similar happens. If times is a scalar, then ep.times is simply a scalar quantity. Are there reasons for this or should checks be implemented to make sure it's consistent? And if it should be allowed, wouldn't it make sense to wrap it in an array then? |
|
I've rebased this onto master to remove the conflicts. I suggest creating a separate issue for the inconsistencies noted by @bjoern1001001 with respect to spike trains, and a separate PR to fix them. |
|
@bjoern1001001 : could you create a sperate issue for you comment. So I could merge and close this without forgeting the issus on getitem and scalar inside neo. |
|
I have opened an issue #490 that refer this PR so I merge. |
so that durations and labels are correctly sliced. Fixes #413