Skip to content

Commit

Permalink
Merge pull request NeuralEnsemble#1314 from apdavison/no-segments-in-…
Browse files Browse the repository at this point in the history
…group

do not allow Groups to contain Segments
  • Loading branch information
JuliaSprenger authored Dec 14, 2023
2 parents 275e70b + 6524d19 commit 4ef2801
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
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

0 comments on commit 4ef2801

Please sign in to comment.