-
Notifications
You must be signed in to change notification settings - Fork 261
Revert implementation of Epoch and Event to not use array annotations machinery for label and duration #659
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
Revert implementation of Epoch and Event to not use array annotations machinery for label and duration #659
Conversation
…durations" are handled as direct attributes rather than as array annotations.
First of all, yes, I can confirm that this had also been an issue on NeuralEnsemble/elephant#203. Also, semantically, I agree that labels and durations should not be considered as array annotations. Therefore, for now, I would support the suggested revert of I understand the rationale behind making durations and labels is to use the same mechanism for ensuring consistent lengths of the arrays. In the reverted version, the array lengths of durations and labels are not checked. On the one hand, this is good, because the check had prevented re-assigning the values of an Epoch object before (i.e., typing something like I think a question for the future is whether to be lazy and Pythonic in allowing Neo objects even when they are "intrinsically inconsistent", or whether to enforce consistent Neo objects. An assertion function could be provided that a user can call to validate a given Neo object. In such a function, maybe one could still find a way to have labels, durations and array annotations resort to a similar mechanism (as currently implemented for array annotations) internally to check/validate their lengths. This way, labels and durations would not appear as array annotations, but the code overhead would still be minimized. |
Sorry for the long delay. Indeed the idea behind using the array annotation mechanism also for attributes like I agree with @apdavison in (i) that having them listed in as in the @mdenker: I find the example of directly reassigning the times of an event artificial. When would you reassign the times instead of generating a new object by slicing/addition? |
I hadn't realized this. I will update the PR to check them.
I can't see anything good about that! We definitely want to enforce consistent Neo objects, otherwise we might as well just use plain NumPy arrays.
I'm not saying they should be handled differently, but in the current master they are handled differently. I think the particular case I had trouble with was in the |
So the problem with the |
One option to guarantee in this scenario that This would lead to code such as:
|
# Conflicts: # neo/core/event.py
# Conflicts: # neo/test/coretest/test_epoch.py
Hello @apdavison! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:
|
please could someone merge this? |
Oups. Sorry. |
@apdavison: So what do you think of @mdenker and my alternative suggestions above for future implementations? |
@JuliaSprenger because the thread got a bit complex, I'm not sure exactly what you're proposing. |
I failed to notice during the review of #606 and #472 that the implementation of
Event.labels
,Epoch.labels
andEpoch.durations
had been changed to store these attributes as array annotations.I think this change is a mistake, because (i) semantically labels and durations are not annotations, they are fundamental data attributes for these objects, so it is confusing to handle them as annotations; (ii) annotations are treated differently to data attributes during copying and merging, and this can lead to problems.
I encountered this specifically while trying to fix problems with the
Container.merge()
method; I suspect it is also related to NeuralEnsemble/elephant#203