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

parents property broken after copying analogsignalarray #220

Closed
JuliaSprenger opened this issue Nov 3, 2015 · 2 comments
Closed

parents property broken after copying analogsignalarray #220

JuliaSprenger opened this issue Nov 3, 2015 · 2 comments
Assignees
Labels
Milestone

Comments

@JuliaSprenger
Copy link
Member

After copying or time_slicing an analogsignalarray accessing the parents of the analogsignal results in an AttributeError 'AnalogSignalArray' object has no attribute 'segment'. The result is the same for a simple copy or a deep copy.

This can be seen when running:

import sys
import copy
import quantities as pq
import neo

anasigarray = neo.AnalogSignalArray(range(10)*pq.V,t_start=0*pq.s,sampling_rate=1*pq.Hz)
print 'Original: %s'%(str(anasigarray.parents))

seg = neo.Segment(name='seg1')
seg.analogsignalarrays.append(anasigarray)
print 'Appended: %s'%(str(anasigarray.parents))

anasigarray2 = anasigarray.time_slice(None,5*pq.s)
try:
    print 'After slicing: %s'%(str(anasigarray2.parents))
except AttributeError as detail:
    print 'After slicing: AttributeError %s'%detail

anasigarray3 = copy.deepcopy(anasigarray)
try:
    print 'After deep copy: %s'%(str(anasigarray3.parents))
except AttributeError as detail:
    print 'After deep copy: AttributeError %s'%detail

anasigarray4 = anasigarray.copy()
try:
    print 'After copy: %s'%(str(anasigarray4.parents))
except AttributeError as detail:
    print 'After copy: AttributeError %s'%detail

This code prints:

Original: (None, None)
Appended: (None, None)
After slicing: AttributeError 'AnalogSignalArray' object has no attribute 'segment'
After deep copy: AttributeError 'AnalogSignalArray' object has no attribute 'segment'
After copy: AttributeError 'AnalogSignalArray' object has no attribute 'segment'

In the case of time_slice this can be fixed by additionally copying the parents of the old analogsignalarray to the newly generated analogsignalarray in the time_slice function. But this does not solve the same issue when using copy.

@apdavison apdavison added the bug label Jan 25, 2017
@apdavison apdavison added this to the 0.5 milestone Jan 25, 2017
@apdavison apdavison modified the milestones: 0.5, 0.5.1 Mar 24, 2017
@mczerwinski
Copy link

I was using deepcopy in my code.
When copying analogsignals it worked ok.
On the segment it had problems, probably with recursive implementation of copy/deepcopy - the returned copies were simplified/derived of some parameters (annotations, quantities)

@apdavison apdavison modified the milestones: 0.5.1, 0.5.2, future Jun 15, 2017
@apdavison apdavison modified the milestones: future, 0.5.2 Sep 26, 2017
HFragnaud added a commit to HFragnaud/python-neo that referenced this issue Sep 27, 2017
apdavison added a commit that referenced this issue Sep 27, 2017
@samuelgarcia
Copy link
Contributor

Fixed by #399.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants