python-neo icon indicating copy to clipboard operation
python-neo copied to clipboard

copy behaviour of annotations and object identity

Open JuliaSprenger opened this issue 5 years ago • 3 comments

Annotations of objects are by default not deepcopied when manipulating an object, e.g. upon slicing of a signal. However, array annotations are explicitly deepcopied (see https://github.com/NeuralEnsemble/python-neo/issues/809#issuecomment-619902320), whereas this is not the case for regular annotations. This can lead to unexpected behaviour, e.g. when identifying objects via annotations (see #809).

I am not sure at which point it would be best to fix this behaviour. There are multiple options here:

  • extend the __get_item__ methods in a similar fashion as implemented for array_annotations. This would lead to multiple steps in the process of slicing. First linking of annotations by __array_finalize and then explicit deepcopying later on.
  • extend the __array_finalize__ methods as these are called also during the process of slicing
  • introduce unique object identifiers within neo. This would require an extended discussion first about the concept of identifiers to use and their expected behaviour in Neo.

@apdavison @samuelgarcia Do you have a preference regarding the different options here?

JuliaSprenger avatar Apr 28 '20 13:04 JuliaSprenger

Hi Julia. I think really prefer deepcopy of annotation. I forget why we did not copy annotations yet.

Having uid for neo object is not a solution I like.

And about the when to make the copy, I don't known choose the simpler!!

Cheers,

Samuel

samuelgarcia avatar May 04 '20 12:05 samuelgarcia

I think this is important to put in 0.9 no ? Even with something very simple. This is the last stuff. No ?

samuelgarcia avatar Nov 09 '20 16:11 samuelgarcia

I don't think this will go into the next release as there is not enough time to implement and review it properly. @samuelgarcia @apdavison I suggest to postpone this to 0.11.0. even though it is labeled as blocker.

JuliaSprenger avatar Jul 09 '21 09:07 JuliaSprenger