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

do not allow Groups to contain Segments #1314

Merged
merged 1 commit into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion neo/core/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class Group(Container):
'AnalogSignal', 'IrregularlySampledSignal', 'SpikeTrain',
'Event', 'Epoch', 'ChannelView', 'ImageSequence'
)
_container_child_objects = ('Segment', 'Group')
_container_child_objects = ('Group',)
_parent_objects = ('Block',)

def __init__(self, objects=None, name=None, description=None, file_origin=None,
Expand Down
8 changes: 3 additions & 5 deletions neo/test/coretest/test_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def setUp(self):
self.test_segment.spiketrains.extend(self.test_spiketrains)

def test_create_group(self):
objects = [self.test_view, self.test_signal, self.test_segment]
objects = [self.test_view, self.test_signal]
objects.extend(self.test_spiketrains)
group = Group(objects)

Expand All @@ -50,21 +50,19 @@ def test_create_group(self):
assert group.spiketrains[1] is self.test_spiketrains[1]
assert group.channelviews[0] is self.test_view
assert len(group.irregularlysampledsignals) == 0
assert group.segments[0].analogsignals[0] is self.test_signal

def test_create_empty_group(self):
group = Group()

def test_children(self):
group = Group(self.test_spiketrains + [self.test_view]
+ [self.test_signal] + [self.test_segment])
+ [self.test_signal])

# note: ordering is by class name for data children (AnalogSignal, SpikeTrain),
# then container children (Segment)
assert group.children == (self.test_signal,
*self.test_spiketrains,
self.test_view,
self.test_segment)
self.test_view)

def test_with_allowed_types(self):
objects = [self.test_signal] + self.test_spiketrains
Expand Down