<s> """<STR_LIT>""" <EOL> from __future__ import absolute_import , division , print_function <EOL> from datetime import datetime <EOL> try : <EOL> import unittest2 as unittest <EOL> except ImportError : <EOL> import unittest <EOL> import numpy as np <EOL> import quantities as pq <EOL> try : <EOL> from IPython . lib . pretty import pretty <EOL> except ImportError as err : <EOL> HAVE_IPYTHON = False <EOL> else : <EOL> HAVE_IPYTHON = True <EOL> from neo . core . segment import Segment <EOL> from neo . core import ( AnalogSignalArray , Block , <EOL> Epoch , EpochArray , <EOL> RecordingChannelGroup , SpikeTrain , Unit ) <EOL> from neo . core . container import filterdata <EOL> from neo . test . tools import ( assert_neo_object_is_compliant , <EOL> assert_same_sub_schema ) <EOL> from neo . test . generate_datasets import ( fake_neo , get_fake_value , <EOL> get_fake_values , get_annotations , <EOL> clone_object , TEST_ANNOTATIONS ) <EOL> class Test__generate_datasets ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> np . random . seed ( <NUM_LIT:0> ) <EOL> self . annotations = dict ( [ ( str ( x ) , TEST_ANNOTATIONS [ x ] ) for x in <EOL> range ( len ( TEST_ANNOTATIONS ) ) ] ) <EOL> def test__get_fake_values ( self ) : <EOL> self . annotations [ '<STR_LIT>' ] = <NUM_LIT:0> <EOL> file_datetime = get_fake_value ( '<STR_LIT>' , datetime , seed = <NUM_LIT:0> ) <EOL> rec_datetime = get_fake_value ( '<STR_LIT>' , datetime , seed = <NUM_LIT:1> ) <EOL> index = get_fake_value ( '<STR_LIT:index>' , int , seed = <NUM_LIT:2> ) <EOL> name = get_fake_value ( '<STR_LIT:name>' , str , seed = <NUM_LIT:3> , obj = Segment ) <EOL> description = get_fake_value ( '<STR_LIT:description>' , str , seed = <NUM_LIT:4> , obj = '<STR_LIT>' ) <EOL> file_origin = get_fake_value ( '<STR_LIT>' , str ) <EOL> attrs1 = { '<STR_LIT>' : file_datetime , <EOL> '<STR_LIT>' : rec_datetime , <EOL> '<STR_LIT:index>' : index , <EOL> '<STR_LIT:name>' : name , <EOL> '<STR_LIT:description>' : description , <EOL> '<STR_LIT>' : file_origin } <EOL> attrs2 = attrs1 . copy ( ) <EOL> attrs2 . update ( self . annotations ) <EOL> res11 = get_fake_values ( Segment , annotate = False , seed = <NUM_LIT:0> ) <EOL> res12 = get_fake_values ( '<STR_LIT>' , annotate = False , seed = <NUM_LIT:0> ) <EOL> res21 = get_fake_values ( Segment , annotate = True , seed = <NUM_LIT:0> ) <EOL> res22 = get_fake_values ( '<STR_LIT>' , annotate = True , seed = <NUM_LIT:0> ) <EOL> self . assertEqual ( res11 , attrs1 ) <EOL> self . assertEqual ( res12 , attrs1 ) <EOL> self . assertEqual ( res21 , attrs2 ) <EOL> self . assertEqual ( res22 , attrs2 ) <EOL> def test__fake_neo__cascade ( self ) : <EOL> self . annotations [ '<STR_LIT>' ] = None <EOL> obj_type = Segment <EOL> cascade = True <EOL> res = fake_neo ( obj_type = obj_type , cascade = cascade ) <EOL> self . assertTrue ( isinstance ( res , Segment ) ) <EOL> assert_neo_object_is_compliant ( res ) <EOL> self . assertEqual ( res . annotations , self . annotations ) <EOL> self . assertEqual ( len ( res . analogsignalarrays ) , <NUM_LIT:1> ) <EOL> self . assertEqual ( len ( res . analogsignals ) , <NUM_LIT:1> ) <EOL> self . assertEqual ( len ( res . irregularlysampledsignals ) , <NUM_LIT:1> ) <EOL> self . assertEqual ( len ( res . spiketrains ) , <NUM_LIT:1> ) <EOL> self . assertEqual ( len ( res . spikes ) , <NUM_LIT:1> ) <EOL> self . assertEqual ( len ( res . events ) , <NUM_LIT:1> ) <EOL> self . assertEqual ( len ( res . epochs ) , <NUM_LIT:1> ) <EOL> self . assertEqual ( len ( res . eventarrays ) , <NUM_LIT:1> ) <EOL> self . assertEqual ( len ( res . epocharrays ) , <NUM_LIT:1> ) <EOL> for child in res . children : <EOL> del child . annotations [ '<STR_LIT:i>' ] <EOL> del child . annotations [ '<STR_LIT>' ] <EOL> self . assertEqual ( res . analogsignalarrays [ <NUM_LIT:0> ] . annotations , <EOL> self . annotations ) <EOL> self . assertEqual ( res . analogsignals [ <NUM_LIT:0> ] . annotations , <EOL> self . annotations ) <EOL> self . assertEqual ( res . irregularlysampledsignals [ <NUM_LIT:0> ] . annotations , <EOL> self . annotations ) <EOL> self . assertEqual ( res . spiketrains [ <NUM_LIT:0> ] . annotations , <EOL> self . annotations ) <EOL> self . assertEqual ( res . spikes [ <NUM_LIT:0> ] . annotations , <EOL> self . annotations ) <EOL> self . assertEqual ( res . events [ <NUM_LIT:0> ] . annotations , <EOL> self . annotations ) <EOL> self . assertEqual ( res . epochs [ <NUM_LIT:0> ] . annotations , <EOL> self . annotations ) <EOL> self . assertEqual ( res . eventarrays [ <NUM_LIT:0> ] . annotations , <EOL> self . annotations ) <EOL> self . assertEqual ( res . epocharrays [ <NUM_LIT:0> ] . annotations , <EOL> self . annotations ) <EOL> def test__fake_neo__nocascade ( self ) : <EOL> self . annotations [ '<STR_LIT>' ] = None <EOL> obj_type = '<STR_LIT>' <EOL> cascade = False <EOL> res = fake_neo ( obj_type = obj_type , cascade = cascade ) <EOL> self . assertTrue ( isinstance ( res , Segment ) ) <EOL> assert_neo_object_is_compliant ( res ) <EOL> self . assertEqual ( res . annotations , self . annotations ) <EOL> self . assertEqual ( len ( res . analogsignalarrays ) , <NUM_LIT:0> ) <EOL> self . assertEqual ( len ( res . analogsignals ) , <NUM_LIT:0> ) <EOL> self . assertEqual ( len ( res . irregularlysampledsignals ) , <NUM_LIT:0> ) <EOL> self . assertEqual ( len ( res . spiketrains ) , <NUM_LIT:0> ) <EOL> self . assertEqual ( len ( res . spikes ) , <NUM_LIT:0> ) <EOL> self . assertEqual ( len ( res . events ) , <NUM_LIT:0> ) <EOL> self . assertEqual ( len ( res . epochs ) , <NUM_LIT:0> ) <EOL> self . assertEqual ( len ( res . eventarrays ) , <NUM_LIT:0> ) <EOL> self . assertEqual ( len ( res . epocharrays ) , <NUM_LIT:0> ) <EOL> class TestSegment ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . nchildren = <NUM_LIT:2> <EOL> blk = fake_neo ( Block , seed = <NUM_LIT:0> , n = self . nchildren ) <EOL> self . unit1 , self . unit2 , self . unit3 , self . unit4 = blk . list_units <EOL> self . seg1 , self . seg2 = blk . segments <EOL> self . targobj = self . seg1 <EOL> self . seed1 = self . seg1 . annotations [ '<STR_LIT>' ] <EOL> self . seed2 = self . seg2 . annotations [ '<STR_LIT>' ] <EOL> del self . seg1 . annotations [ '<STR_LIT:i>' ] <EOL> del self . seg2 . annotations [ '<STR_LIT:i>' ] <EOL> del self . seg1 . annotations [ '<STR_LIT>' ] <EOL> del self . seg2 . annotations [ '<STR_LIT>' ] <EOL> self . sigs1 = self . seg1 . analogsignals <EOL> self . sigs2 = self . seg2 . analogsignals <EOL> self . sigarrs1 = self . seg1 . analogsignalarrays <EOL> self . sigarrs2 = self . seg2 . analogsignalarrays <EOL> self . irsigs1 = self . seg1 . irregularlysampledsignals <EOL> self . irsigs2 = self . seg2 . irregularlysampledsignals <EOL> self . spikes1 = self . seg1 . spikes <EOL> self . spikes2 = self . seg2 . spikes <EOL> self . trains1 = self . seg1 . spiketrains <EOL> self . trains2 = self . seg2 . spiketrains <EOL> self . epcs1 = self . seg1 . epochs <EOL> self . epcs2 = self . seg2 . epochs <EOL> self . epcas1 = self . seg1 . epocharrays <EOL> self . epcas2 = self . seg2 . epocharrays <EOL> self . evts1 = self . seg1 . events <EOL> self . evts2 = self . seg2 . events <EOL> self . evtas1 = self . seg1 . eventarrays <EOL> self . evtas2 = self . seg2 . eventarrays <EOL> self . sigs1a = clone_object ( self . sigs1 ) <EOL> self . sigarrs1a = clone_object ( self . sigarrs1 , n = <NUM_LIT:2> ) <EOL> self . irsigs1a = clone_object ( self . irsigs1 ) <EOL> self . spikes1a = clone_object ( self . spikes1 ) <EOL> self . trains1a = clone_object ( self . trains1 ) <EOL> self . epcs1a = clone_object ( self . epcs1 ) <EOL> self . epcas1a = clone_object ( self . epcas1 ) <EOL> self . evts1a = clone_object ( self . evts1 ) <EOL> self . evtas1a = clone_object ( self . evtas1 ) <EOL> for obj , obja in zip ( self . sigs1 + self . sigarrs1 , <EOL> self . sigs1a + self . sigarrs1a ) : <EOL> obja . channel_index = obj . channel_index <EOL> def test_init ( self ) : <EOL> seg = Segment ( name = '<STR_LIT>' , index = <NUM_LIT:3> ) <EOL> assert_neo_object_is_compliant ( seg ) <EOL> self . assertEqual ( seg . name , '<STR_LIT>' ) <EOL> self . assertEqual ( seg . file_origin , None ) <EOL> self . assertEqual ( seg . index , <NUM_LIT:3> ) <EOL> def check_creation ( self , seg ) : <EOL> assert_neo_object_is_compliant ( seg ) <EOL> seed = seg . annotations [ '<STR_LIT>' ] <EOL> targ0 = get_fake_value ( '<STR_LIT>' , datetime , seed = seed + <NUM_LIT:0> ) <EOL> self . assertEqual ( seg . file_datetime , targ0 ) <EOL> targ1 = get_fake_value ( '<STR_LIT>' , datetime , seed = seed + <NUM_LIT:1> ) <EOL> self . assertEqual ( seg . rec_datetime , targ1 ) <EOL> targ2 = get_fake_value ( '<STR_LIT:index>' , int , seed = seed + <NUM_LIT:2> ) <EOL> self . assertEqual ( seg . index , targ2 ) <EOL> targ3 = get_fake_value ( '<STR_LIT:name>' , str , seed = seed + <NUM_LIT:3> , obj = Segment ) <EOL> self . assertEqual ( seg . name , targ3 ) <EOL> targ4 = get_fake_value ( '<STR_LIT:description>' , str , <EOL> seed = seed + <NUM_LIT:4> , obj = Segment ) <EOL> self . assertEqual ( seg . description , targ4 ) <EOL> targ5 = get_fake_value ( '<STR_LIT>' , str ) <EOL> self . assertEqual ( seg . file_origin , targ5 ) <EOL> targ6 = get_annotations ( ) <EOL> targ6 [ '<STR_LIT>' ] = seed <EOL> self . assertEqual ( seg . annotations , targ6 ) <EOL> self . assertTrue ( hasattr ( seg , '<STR_LIT>' ) ) <EOL> self . assertTrue ( hasattr ( seg , '<STR_LIT>' ) ) <EOL> self . assertTrue ( hasattr ( seg , '<STR_LIT>' ) ) <EOL> self . assertTrue ( hasattr ( seg , '<STR_LIT>' ) ) <EOL> self . assertTrue ( hasattr ( seg , '<STR_LIT>' ) ) <EOL> self . assertTrue ( hasattr ( seg , '<STR_LIT>' ) ) <EOL> self . assertTrue ( hasattr ( seg , '<STR_LIT>' ) ) <EOL> self . assertTrue ( hasattr ( seg , '<STR_LIT>' ) ) <EOL> self . assertTrue ( hasattr ( seg , '<STR_LIT>' ) ) <EOL> self . assertEqual ( len ( seg . analogsignals ) , self . nchildren ** <NUM_LIT:2> ) <EOL> self . assertEqual ( len ( seg . analogsignalarrays ) , self . nchildren ) <EOL> self . assertEqual ( len ( seg . irregularlysampledsignals ) , self . nchildren ** <NUM_LIT:2> ) <EOL> self . assertEqual ( len ( seg . epochs ) , self . nchildren ) <EOL> self . assertEqual ( len ( seg . epocharrays ) , self . nchildren ) <EOL> self . assertEqual ( len ( seg . events ) , self . nchildren ) <EOL> self . assertEqual ( len ( seg . eventarrays ) , self . nchildren ) <EOL> self . assertEqual ( len ( seg . spikes ) , self . nchildren ** <NUM_LIT:2> ) <EOL> self . assertEqual ( len ( seg . spiketrains ) , self . nchildren ** <NUM_LIT:2> ) <EOL> def test__creation ( self ) : <EOL> self . check_creation ( self . seg1 ) <EOL> self . check_creation ( self . seg2 ) <EOL> def test__merge ( self ) : <EOL> seg1a = fake_neo ( Block , seed = self . seed1 , n = self . nchildren ) . segments [ <NUM_LIT:0> ] <EOL> assert_same_sub_schema ( self . seg1 , seg1a ) <EOL> seg1a . spikes . append ( self . spikes2 [ <NUM_LIT:0> ] ) <EOL> seg1a . epocharrays . append ( self . epcas2 [ <NUM_LIT:0> ] ) <EOL> seg1a . annotate ( seed = self . seed2 ) <EOL> seg1a . merge ( self . seg2 ) <EOL> self . check_creation ( self . seg2 ) <EOL> assert_same_sub_schema ( self . sigs1a + self . sigs2 , seg1a . analogsignals ) <EOL> assert_same_sub_schema ( self . sigarrs1a + self . sigarrs2 , <EOL> seg1a . analogsignalarrays ) <EOL> assert_same_sub_schema ( self . irsigs1a + self . irsigs2 , <EOL> seg1a . irregularlysampledsignals ) <EOL> assert_same_sub_schema ( self . epcs1 + self . epcs2 , seg1a . epochs ) <EOL> assert_same_sub_schema ( self . epcas1 + self . epcas2 , seg1a . epocharrays ) <EOL> assert_same_sub_schema ( self . evts1 + self . evts2 , seg1a . events ) <EOL> assert_same_sub_schema ( self . evtas1 + self . evtas2 , seg1a . eventarrays ) <EOL> assert_same_sub_schema ( self . spikes1 + self . spikes2 , seg1a . spikes ) <EOL> assert_same_sub_schema ( self . trains1 + self . trains2 , seg1a . spiketrains ) <EOL> def test__children ( self ) : <EOL> blk = Block ( name = '<STR_LIT>' ) <EOL> blk . segments = [ self . seg1 ] <EOL> blk . create_many_to_one_relationship ( force = True ) <EOL> assert_neo_object_is_compliant ( self . seg1 ) <EOL> assert_neo_object_is_compliant ( blk ) <EOL> childobjs = ( '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' ) <EOL> childconts = ( '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . assertEqual ( self . seg1 . _container_child_objects , ( ) ) <EOL> self . assertEqual ( self . seg1 . _data_child_objects , childobjs ) <EOL> self . assertEqual ( self . seg1 . _single_parent_objects , ( '<STR_LIT>' , ) ) <EOL> self . assertEqual ( self . seg1 . _multi_child_objects , ( ) ) <EOL> self . assertEqual ( self . seg1 . _multi_parent_objects , ( ) ) <EOL> self . assertEqual ( self . seg1 . _child_properties , ( ) ) <EOL> self . assertEqual ( self . seg1 . _single_child_objects , childobjs ) <EOL> self . assertEqual ( self . seg1 . _container_child_containers , ( ) ) <EOL> self . assertEqual ( self . seg1 . _data_child_containers , childconts ) <EOL> self . assertEqual ( self . seg1 . _single_child_containers , childconts ) <EOL> self . assertEqual ( self . seg1 . _single_parent_containers , ( '<STR_LIT>' , ) ) <EOL> self . assertEqual ( self . seg1 . _multi_child_containers , ( ) ) <EOL> self . assertEqual ( self . seg1 . _multi_parent_containers , ( ) ) <EOL> self . assertEqual ( self . seg1 . _child_objects , childobjs ) <EOL> self . assertEqual ( self . seg1 . _child_containers , childconts ) <EOL> self . assertEqual ( self . seg1 . _parent_objects , ( '<STR_LIT>' , ) ) <EOL> self . assertEqual ( self . seg1 . _parent_containers , ( '<STR_LIT>' , ) ) <EOL> totchildren = ( self . nchildren * <NUM_LIT:2> * <NUM_LIT:2> + <EOL> self . nchildren + <EOL> <NUM_LIT:2> * ( self . nchildren ** <NUM_LIT:2> ) + <EOL> <NUM_LIT:2> * ( self . nchildren ** <NUM_LIT:2> ) ) <EOL> self . assertEqual ( len ( self . seg1 . _single_children ) , totchildren ) <EOL> self . assertEqual ( len ( self . seg1 . data_children ) , totchildren ) <EOL> self . assertEqual ( len ( self . seg1 . children ) , totchildren ) <EOL> self . assertEqual ( len ( self . seg1 . data_children_recur ) , totchildren ) <EOL> self . assertEqual ( len ( self . seg1 . children_recur ) , totchildren ) <EOL> self . assertEqual ( len ( self . seg1 . _multi_children ) , <NUM_LIT:0> ) <EOL> self . assertEqual ( len ( self . seg1 . container_children ) , <NUM_LIT:0> ) <EOL> self . assertEqual ( len ( self . seg1 . container_children_recur ) , <NUM_LIT:0> ) <EOL> children = ( self . sigs1a + self . sigarrs1a + <EOL> self . epcs1a + self . epcas1a + <EOL> self . evts1a + self . evtas1a + <EOL> self . irsigs1a + <EOL> self . spikes1a + self . trains1a ) <EOL> assert_same_sub_schema ( list ( self . seg1 . _single_children ) , children ) <EOL> assert_same_sub_schema ( list ( self . seg1 . data_children ) , children ) <EOL> assert_same_sub_schema ( list ( self . seg1 . data_children_recur ) , children ) <EOL> assert_same_sub_schema ( list ( self . seg1 . children ) , children ) <EOL> assert_same_sub_schema ( list ( self . seg1 . children_recur ) , children ) <EOL> self . assertEqual ( len ( self . seg1 . parents ) , <NUM_LIT:1> ) <EOL> self . assertEqual ( self . seg1 . parents [ <NUM_LIT:0> ] . name , '<STR_LIT>' ) <EOL> def test__size ( self ) : <EOL> targ1 = { "<STR_LIT>" : self . nchildren , "<STR_LIT>" : self . nchildren , <EOL> "<STR_LIT>" : self . nchildren ** <NUM_LIT:2> , <EOL> "<STR_LIT>" : self . nchildren ** <NUM_LIT:2> , <EOL> "<STR_LIT>" : self . nchildren ** <NUM_LIT:2> , <EOL> "<STR_LIT>" : self . nchildren ** <NUM_LIT:2> , <EOL> "<STR_LIT>" : self . nchildren , "<STR_LIT>" : self . nchildren , <EOL> "<STR_LIT>" : self . nchildren } <EOL> self . assertEqual ( self . targobj . size , targ1 ) <EOL> def test__filter_none ( self ) : <EOL> targ = [ ] <EOL> res0 = self . targobj . filter ( ) <EOL> res1 = self . targobj . filter ( { } ) <EOL> res2 = self . targobj . filter ( [ ] ) <EOL> res3 = self . targobj . filter ( [ { } ] ) <EOL> res4 = self . targobj . filter ( [ { } , { } ] ) <EOL> res5 = self . targobj . filter ( [ { } , { } ] ) <EOL> res6 = self . targobj . filter ( targdict = { } ) <EOL> res7 = self . targobj . filter ( targdict = [ ] ) <EOL> res8 = self . targobj . filter ( targdict = [ { } ] ) <EOL> res9 = self . targobj . filter ( targdict = [ { } , { } ] ) <EOL> assert_same_sub_schema ( res0 , targ ) <EOL> assert_same_sub_schema ( res1 , targ ) <EOL> assert_same_sub_schema ( res2 , targ ) <EOL> assert_same_sub_schema ( res3 , targ ) <EOL> assert_same_sub_schema ( res4 , targ ) <EOL> assert_same_sub_schema ( res5 , targ ) <EOL> assert_same_sub_schema ( res6 , targ ) <EOL> assert_same_sub_schema ( res7 , targ ) <EOL> assert_same_sub_schema ( res8 , targ ) <EOL> assert_same_sub_schema ( res9 , targ ) <EOL> def test__filter_annotation_single ( self ) : <EOL> targ = ( self . sigs1a + self . sigarrs1a + <EOL> [ self . epcs1a [ <NUM_LIT:0> ] , self . epcas1a [ <NUM_LIT:0> ] ] + <EOL> [ self . evts1a [ <NUM_LIT:0> ] , self . evtas1a [ <NUM_LIT:0> ] ] + <EOL> self . irsigs1a + <EOL> self . spikes1a + self . trains1a ) <EOL> res0 = self . targobj . filter ( j = <NUM_LIT:0> ) <EOL> res1 = self . targobj . filter ( { '<STR_LIT>' : <NUM_LIT:0> } ) <EOL> res2 = self . targobj . filter ( targdict = { '<STR_LIT>' : <NUM_LIT:0> } ) <EOL> res3 = self . targobj . filter ( [ { '<STR_LIT>' : <NUM_LIT:0> } ] ) <EOL> res4 = self . targobj . filter ( targdict = [ { '<STR_LIT>' : <NUM_LIT:0> } ] ) <EOL> assert_same_sub_schema ( res0 , targ ) <EOL> assert_same_sub_schema ( res1 , targ ) <EOL> assert_same_sub_schema ( res2 , targ ) <EOL> assert_same_sub_schema ( res3 , targ ) <EOL> assert_same_sub_schema ( res4 , targ ) <EOL> def test__filter_single_annotation_nores ( self ) : <EOL> targ = [ ] <EOL> res0 = self . targobj . filter ( j = <NUM_LIT:5> ) <EOL> res1 = self . targobj . filter ( { '<STR_LIT>' : <NUM_LIT:5> } ) <EOL> res2 = self . targobj . filter ( targdict = { '<STR_LIT>' : <NUM_LIT:5> } ) <EOL> res3 = self . targobj . filter ( [ { '<STR_LIT>' : <NUM_LIT:5> } ] ) <EOL> res4 = self . targobj . filter ( targdict = [ { '<STR_LIT>' : <NUM_LIT:5> } ] ) <EOL> assert_same_sub_schema ( res0 , targ ) <EOL> assert_same_sub_schema ( res1 , targ ) <EOL> assert_same_sub_schema ( res2 , targ ) <EOL> assert_same_sub_schema ( res3 , targ ) <EOL> assert_same_sub_schema ( res4 , targ ) <EOL> def test__filter_attribute_single ( self ) : <EOL> targ = [ self . epcs1a [ <NUM_LIT:1> ] ] <EOL> res0 = self . targobj . filter ( name = self . epcs1a [ <NUM_LIT:1> ] . name ) <EOL> res1 = self . targobj . filter ( { '<STR_LIT:name>' : self . epcs1a [ <NUM_LIT:1> ] . name } ) <EOL> res2 = self . targobj . filter ( targdict = { '<STR_LIT:name>' : self . epcs1a [ <NUM_LIT:1> ] . name } ) <EOL> assert_same_sub_schema ( res0 , targ ) <EOL> assert_same_sub_schema ( res1 , targ ) <EOL> assert_same_sub_schema ( res2 , targ ) <EOL> def test__filter_attribute_single_nores ( self ) : <EOL> targ = [ ] <EOL> res0 = self . targobj . filter ( name = self . epcs2 [ <NUM_LIT:0> ] . name ) <EOL> res1 = self . targobj . filter ( { '<STR_LIT:name>' : self . epcs2 [ <NUM_LIT:0> ] . name } ) <EOL> res2 = self . targobj . filter ( targdict = { '<STR_LIT:name>' : self . epcs2 [ <NUM_LIT:0> ] . name } ) <EOL> assert_same_sub_schema ( res0 , targ ) <EOL> assert_same_sub_schema ( res1 , targ ) <EOL> assert_same_sub_schema ( res2 , targ ) <EOL> def test__filter_multi ( self ) : <EOL> targ = ( self . sigs1a + self . sigarrs1a + <EOL> [ self . epcs1a [ <NUM_LIT:0> ] , self . epcas1a [ <NUM_LIT:0> ] ] + <EOL> [ self . evts1a [ <NUM_LIT:0> ] , self . evtas1a [ <NUM_LIT:0> ] ] + <EOL> self . irsigs1a + <EOL> self . spikes1a + self . trains1a + <EOL> [ self . epcs1a [ <NUM_LIT:1> ] ] ) <EOL> res0 = self . targobj . filter ( name = self . epcs1a [ <NUM_LIT:1> ] . name , j = <NUM_LIT:0> ) <EOL> res1 = self . targobj . filter ( { '<STR_LIT:name>' : self . epcs1a [ <NUM_LIT:1> ] . name , '<STR_LIT>' : <NUM_LIT:0> } ) <EOL> res2 = self . targobj . filter ( targdict = { '<STR_LIT:name>' : self . epcs1a [ <NUM_LIT:1> ] . name , <EOL> '<STR_LIT>' : <NUM_LIT:0> } ) <EOL> assert_same_sub_schema ( res0 , targ ) <EOL> assert_same_sub_schema ( res1 , targ ) <EOL> assert_same_sub_schema ( res2 , targ ) <EOL> def test__filter_multi_nores ( self ) : <EOL> targ = [ ] <EOL> res0 = self . targobj . filter ( [ { '<STR_LIT>' : <NUM_LIT:0> } , { } ] ) <EOL> res1 = self . targobj . filter ( { } , ttype = <NUM_LIT:0> ) <EOL> res2 = self . targobj . filter ( [ { } ] , ttype = <NUM_LIT:0> ) <EOL> res3 = self . targobj . filter ( { '<STR_LIT:name>' : self . epcs1a [ <NUM_LIT:1> ] . name } , j = <NUM_LIT:0> ) <EOL> res4 = self . targobj . filter ( targdict = { '<STR_LIT:name>' : self . epcs1a [ <NUM_LIT:1> ] . name } , <EOL> j = <NUM_LIT:0> ) <EOL> res5 = self . targobj . filter ( name = self . epcs1a [ <NUM_LIT:1> ] . name , <EOL> targdict = { '<STR_LIT>' : <NUM_LIT:0> } ) <EOL> res6 = self . targobj . filter ( name = self . epcs2 [ <NUM_LIT:0> ] . name , j = <NUM_LIT:5> ) <EOL> res7 = self . targobj . filter ( { '<STR_LIT:name>' : self . epcs2 [ <NUM_LIT:1> ] . name , '<STR_LIT>' : <NUM_LIT:5> } ) <EOL> res8 = self . targobj . filter ( targdict = { '<STR_LIT:name>' : self . epcs2 [ <NUM_LIT:1> ] . name , <EOL> '<STR_LIT>' : <NUM_LIT:5> } ) <EOL> res9 = self . targobj . filter ( { '<STR_LIT:name>' : self . epcs2 [ <NUM_LIT:1> ] . name } , j = <NUM_LIT:5> ) <EOL> res10 = self . targobj . filter ( targdict = { '<STR_LIT:name>' : self . epcs2 [ <NUM_LIT:1> ] . name } , <EOL> j = <NUM_LIT:5> ) <EOL> res11 = self . targobj . filter ( name = self . epcs2 [ <NUM_LIT:1> ] . name , <EOL> targdict = { '<STR_LIT>' : <NUM_LIT:5> } ) <EOL> res12 = self . targobj . filter ( { '<STR_LIT:name>' : self . epcs1a [ <NUM_LIT:1> ] . name } , j = <NUM_LIT:5> ) <EOL> res13 = self . targobj . filter ( targdict = { '<STR_LIT:name>' : self . epcs1a [ <NUM_LIT:1> ] . name } , <EOL> j = <NUM_LIT:5> ) <EOL> res14 = self . targobj . filter ( name = self . epcs1a [ <NUM_LIT:1> ] . name , <EOL> targdict = { '<STR_LIT>' : <NUM_LIT:5> } ) <EOL> assert_same_sub_schema ( res0 , targ ) <EOL> assert_same_sub_schema ( res1 , targ ) <EOL> assert_same_sub_schema ( res2 , targ ) <EOL> assert_same_sub_schema ( res3 , targ ) <EOL> assert_same_sub_schema ( res4 , targ ) <EOL> assert_same_sub_schema ( res5 , targ ) <EOL> assert_same_sub_schema ( res6 , targ ) <EOL> assert_same_sub_schema ( res7 , targ ) <EOL> assert_same_sub_schema ( res8 , targ ) <EOL> assert_same_sub_schema ( res9 , targ ) <EOL> assert_same_sub_schema ( res10 , targ ) <EOL> assert_same_sub_schema ( res11 , targ ) <EOL> assert_same_sub_schema ( res12 , targ ) <EOL> assert_same_sub_schema ( res13 , targ ) <EOL> assert_same_sub_schema ( res14 , targ ) <EOL> def test__filter_multi_partres ( self ) : <EOL> targ = [ self . epcs1a [ <NUM_LIT:1> ] ] <EOL> res0 = self . targobj . filter ( name = self . epcs1a [ <NUM_LIT:1> ] . name , j = <NUM_LIT:5> ) <EOL> res1 = self . targobj . filter ( { '<STR_LIT:name>' : self . epcs1a [ <NUM_LIT:1> ] . name , '<STR_LIT>' : <NUM_LIT:5> } ) <EOL> res2 = self . targobj . filter ( targdict = { '<STR_LIT:name>' : self . epcs1a [ <NUM_LIT:1> ] . name , <EOL> '<STR_LIT>' : <NUM_LIT:5> } ) <EOL> res3 = self . targobj . filter ( [ { '<STR_LIT>' : <NUM_LIT:1> } , { '<STR_LIT:i>' : <NUM_LIT:2> } ] ) <EOL> res4 = self . targobj . filter ( { '<STR_LIT>' : <NUM_LIT:1> } , i = <NUM_LIT:2> ) <EOL> res5 = self . targobj . filter ( [ { '<STR_LIT>' : <NUM_LIT:1> } ] , i = <NUM_LIT:2> ) <EOL> assert_same_sub_schema ( res0 , targ ) <EOL> assert_same_sub_schema ( res1 , targ ) <EOL> assert_same_sub_schema ( res2 , targ ) <EOL> assert_same_sub_schema ( res3 , targ ) <EOL> assert_same_sub_schema ( res4 , targ ) <EOL> assert_same_sub_schema ( res5 , targ ) <EOL> def test__filter_single_annotation_obj_single ( self ) : <EOL> targ = [ self . epcs1a [ <NUM_LIT:1> ] ] <EOL> res0 = self . targobj . filter ( j = <NUM_LIT:1> , objects = '<STR_LIT>' ) <EOL> res1 = self . targobj . filter ( j = <NUM_LIT:1> , objects = Epoch ) <EOL> res2 = self . targobj . filter ( j = <NUM_LIT:1> , objects = [ '<STR_LIT>' ] ) <EOL> res3 = self . targobj . filter ( j = <NUM_LIT:1> , objects = [ Epoch ] ) <EOL> res4 = self . targobj . filter ( j = <NUM_LIT:1> , objects = [ Epoch , <EOL> RecordingChannelGroup ] ) <EOL> assert_same_sub_schema ( res0 , targ ) <EOL> assert_same_sub_schema ( res1 , targ ) <EOL> assert_same_sub_schema ( res2 , targ ) <EOL> assert_same_sub_schema ( res3 , targ ) <EOL> assert_same_sub_schema ( res4 , targ ) <EOL> def test__filter_single_annotation_obj_multi ( self ) : <EOL> targ = [ self . epcs1a [ <NUM_LIT:1> ] , self . epcas1a [ <NUM_LIT:1> ] ] <EOL> res0 = self . targobj . filter ( j = <NUM_LIT:1> , objects = [ '<STR_LIT>' , EpochArray ] ) <EOL> assert_same_sub_schema ( res0 , targ ) <EOL> def test__filter_single_annotation_obj_none ( self ) : <EOL> targ = [ ] <EOL> res0 = self . targobj . filter ( j = <NUM_LIT:1> , objects = RecordingChannelGroup ) <EOL> res1 = self . targobj . filter ( j = <NUM_LIT:1> , objects = '<STR_LIT>' ) <EOL> res2 = self . targobj . filter ( j = <NUM_LIT:1> , objects = [ ] ) <EOL> assert_same_sub_schema ( res0 , targ ) <EOL> assert_same_sub_schema ( res1 , targ ) <EOL> assert_same_sub_schema ( res2 , targ ) <EOL> def test__filter_single_annotation_norecur ( self ) : <EOL> targ = [ self . epcs1a [ <NUM_LIT:1> ] , self . epcas1a [ <NUM_LIT:1> ] , <EOL> self . evts1a [ <NUM_LIT:1> ] , self . evtas1a [ <NUM_LIT:1> ] ] <EOL> res0 = self . targobj . filter ( j = <NUM_LIT:1> , <EOL> recursive = False ) <EOL> assert_same_sub_schema ( res0 , targ ) <EOL> def test__filter_single_attribute_norecur ( self ) : <EOL> targ = [ self . epcs1a [ <NUM_LIT:1> ] ] <EOL> res0 = self . targobj . filter ( name = self . epcs1a [ <NUM_LIT:1> ] . name , <EOL> recursive = False ) <EOL> assert_same_sub_schema ( res0 , targ ) <EOL> def test__filter_single_annotation_nodata ( self ) : <EOL> targ = [ ] <EOL> res0 = self . targobj . filter ( j = <NUM_LIT:0> , <EOL> data = False ) <EOL> assert_same_sub_schema ( res0 , targ ) <EOL> def test__filter_single_attribute_nodata ( self ) : <EOL> targ = [ ] <EOL> res0 = self . targobj . filter ( name = self . epcs1a [ <NUM_LIT:1> ] . name , <EOL> data = False ) <EOL> assert_same_sub_schema ( res0 , targ ) <EOL> def test__filter_single_annotation_nodata_norecur ( self ) : <EOL> targ = [ ] <EOL> res0 = self . targobj . filter ( j = <NUM_LIT:0> , <EOL> data = False , recursive = False ) <EOL> assert_same_sub_schema ( res0 , targ ) <EOL> def test__filter_single_attribute_nodata_norecur ( self ) : <EOL> targ = [ ] <EOL> res0 = self . targobj . filter ( name = self . epcs1a [ <NUM_LIT:1> ] . name , <EOL> data = False , recursive = False ) <EOL> assert_same_sub_schema ( res0 , targ ) <EOL> def test__filter_single_annotation_container ( self ) : <EOL> targ = [ self . epcs1a [ <NUM_LIT:1> ] , self . epcas1a [ <NUM_LIT:1> ] , <EOL> self . evts1a [ <NUM_LIT:1> ] , self . evtas1a [ <NUM_LIT:1> ] ] <EOL> res0 = self . targobj . filter ( j = <NUM_LIT:1> , <EOL> container = True ) <EOL> assert_same_sub_schema ( res0 , targ ) <EOL> def test__filter_single_attribute_container ( self ) : <EOL> targ = [ self . epcs1a [ <NUM_LIT:1> ] ] <EOL> res0 = self . targobj . filter ( name = self . epcs1a [ <NUM_LIT:1> ] . name , <EOL> container = True ) <EOL> assert_same_sub_schema ( res0 , targ ) <EOL> def test__filter_single_annotation_container_norecur ( self ) : <EOL> targ = [ self . epcs1a [ <NUM_LIT:1> ] , self . epcas1a [ <NUM_LIT:1> ] , <EOL> self . evts1a [ <NUM_LIT:1> ] , self . evtas1a [ <NUM_LIT:1> ] ] <EOL> res0 = self . targobj . filter ( j = <NUM_LIT:1> , <EOL> container = True , recursive = False ) <EOL> assert_same_sub_schema ( res0 , targ ) <EOL> def test__filter_single_attribute_container_norecur ( self ) : <EOL> targ = [ self . epcs1a [ <NUM_LIT:1> ] ] <EOL> res0 = self . targobj . filter ( name = self . epcs1a [ <NUM_LIT:1> ] . name , <EOL> container = True , recursive = False ) <EOL> assert_same_sub_schema ( res0 , targ ) <EOL> def test__filter_single_annotation_nodata_container ( self ) : <EOL> targ = [ ] <EOL> res0 = self . targobj . filter ( j = <NUM_LIT:0> , <EOL> data = False , container = True ) <EOL> assert_same_sub_schema ( res0 , targ ) <EOL> def test__filter_single_attribute_nodata_container ( self ) : <EOL> targ = [ ] <EOL> res0 = self . targobj . filter ( name = self . epcs1a [ <NUM_LIT:1> ] . name , <EOL> data = False , container = True ) <EOL> assert_same_sub_schema ( res0 , targ ) <EOL> def test__filter_single_annotation_nodata_container_norecur ( self ) : <EOL> targ = [ ] <EOL> res0 = self . targobj . filter ( j = <NUM_LIT:0> , <EOL> data = False , container = True , <EOL> recursive = False ) <EOL> assert_same_sub_schema ( res0 , targ ) <EOL> def test__filter_single_attribute_nodata_container_norecur ( self ) : <EOL> targ = [ ] <EOL> res0 = self . targobj . filter ( name = self . epcs1a [ <NUM_LIT:1> ] . name , <EOL> data = False , container = True , <EOL> recursive = False ) <EOL> assert_same_sub_schema ( res0 , targ ) <EOL> data = self . targobj . children_recur <EOL> targ = ( self . sigs1a + self . sigarrs1a + <EOL> [ self . epcs1a [ <NUM_LIT:0> ] , self . epcas1a [ <NUM_LIT:0> ] ] + <EOL> [ self . evts1a [ <NUM_LIT:0> ] , self . evtas1a [ <NUM_LIT:0> ] ] + <EOL> self . irsigs1a + <EOL> self . spikes1a + self . trains1a + <EOL> [ self . epcs1a [ <NUM_LIT:1> ] ] ) <EOL> res0 = filterdata ( data , name = self . epcs1a [ <NUM_LIT:1> ] . name , j = <NUM_LIT:0> ) <EOL> res1 = filterdata ( data , { '<STR_LIT:name>' : self . epcs1a [ <NUM_LIT:1> ] . name , '<STR_LIT>' : <NUM_LIT:0> } ) <EOL> res2 = filterdata ( data , targdict = { '<STR_LIT:name>' : self . epcs1a [ <NUM_LIT:1> ] . name , '<STR_LIT>' : <NUM_LIT:0> } ) <EOL> assert_same_sub_schema ( res0 , targ ) <EOL> assert_same_sub_schema ( res1 , targ ) <EOL> assert_same_sub_schema ( res2 , targ ) <EOL> def test__filterdata_multi_nores ( self ) : <EOL> data = self . targobj . children_recur <EOL> targ = [ ] <EOL> res0 = filterdata ( data , [ { '<STR_LIT>' : <NUM_LIT:0> } , { } ] ) <EOL> res1 = filterdata ( data , { } , ttype = <NUM_LIT:0> ) <EOL> res2 = filterdata ( data , [ { } ] , ttype = <NUM_LIT:0> ) <EOL> res3 = filterdata ( data , { '<STR_LIT:name>' : self . epcs1a [ <NUM_LIT:1> ] . name } , j = <NUM_LIT:0> ) <EOL> res4 = filterdata ( data , targdict = { '<STR_LIT:name>' : self . epcs1a [ <NUM_LIT:1> ] . name } , j = <NUM_LIT:0> ) <EOL> res5 = filterdata ( data , name = self . epcs1a [ <NUM_LIT:1> ] . name , targdict = { '<STR_LIT>' : <NUM_LIT:0> } ) <EOL> res6 = filterdata ( data , name = self . epcs2 [ <NUM_LIT:0> ] . name , j = <NUM_LIT:5> ) <EOL> res7 = filterdata ( data , { '<STR_LIT:name>' : self . epcs2 [ <NUM_LIT:1> ] . name , '<STR_LIT>' : <NUM_LIT:5> } ) <EOL> res8 = filterdata ( data , targdict = { '<STR_LIT:name>' : self . epcs2 [ <NUM_LIT:1> ] . name , '<STR_LIT>' : <NUM_LIT:5> } ) <EOL> res9 = filterdata ( data , { '<STR_LIT:name>' : self . epcs2 [ <NUM_LIT:1> ] . name } , j = <NUM_LIT:5> ) <EOL> res10 = filterdata ( data , targdict = { '<STR_LIT:name>' : self . epcs2 [ <NUM_LIT:1> ] . name } , j = <NUM_LIT:5> ) <EOL> res11 = filterdata ( data , name = self . epcs2 [ <NUM_LIT:1> ] . name , targdict = { '<STR_LIT>' : <NUM_LIT:5> } ) <EOL> res12 = filterdata ( data , { '<STR_LIT:name>' : self . epcs1a [ <NUM_LIT:1> ] . name } , j = <NUM_LIT:5> ) <EOL> res13 = filterdata ( data , targdict = { '<STR_LIT:name>' : self . epcs1a [ <NUM_LIT:1> ] . name } , j = <NUM_LIT:5> ) <EOL> res14 = filterdata ( data , name = self . epcs1a [ <NUM_LIT:1> ] . name , targdict = { '<STR_LIT>' : <NUM_LIT:5> } ) <EOL> assert_same_sub_schema ( res0 , targ ) <EOL> assert_same_sub_schema ( res1 , targ ) <EOL> assert_same_sub_schema ( res2 , targ ) <EOL> assert_same_sub_schema ( res3 , targ ) <EOL> assert_same_sub_schema ( res4 , targ ) <EOL> assert_same_sub_schema ( res5 , targ ) <EOL> assert_same_sub_schema ( res6 , targ ) <EOL> assert_same_sub_schema ( res7 , targ ) <EOL> assert_same_sub_schema ( res8 , targ ) <EOL> assert_same_sub_schema ( res9 , targ ) <EOL> assert_same_sub_schema ( res10 , targ ) <EOL> assert_same_sub_schema ( res11 , targ ) <EOL> assert_same_sub_schema ( res12 , targ ) <EOL> assert_same_sub_schema ( res13 , targ ) <EOL> assert_same_sub_schema ( res14 , targ ) <EOL> def test__filterdata_multi_partres ( self ) : <EOL> data = self . targobj . children_recur <EOL> targ = [ self . epcs1a [ <NUM_LIT:1> ] ] <EOL> res0 = filterdata ( data , name = self . epcs1a [ <NUM_LIT:1> ] . name , j = <NUM_LIT:5> ) <EOL> res1 = filterdata ( data , { '<STR_LIT:name>' : self . epcs1a [ <NUM_LIT:1> ] . name , '<STR_LIT>' : <NUM_LIT:5> } ) <EOL> res2 = filterdata ( data , targdict = { '<STR_LIT:name>' : self . epcs1a [ <NUM_LIT:1> ] . name , '<STR_LIT>' : <NUM_LIT:5> } ) <EOL> res3 = filterdata ( data , [ { '<STR_LIT>' : <NUM_LIT:1> } , { '<STR_LIT:i>' : <NUM_LIT:2> } ] ) <EOL> res4 = filterdata ( data , { '<STR_LIT>' : <NUM_LIT:1> } , i = <NUM_LIT:2> ) <EOL> res5 = filterdata ( data , [ { '<STR_LIT>' : <NUM_LIT:1> } ] , i = <NUM_LIT:2> ) <EOL> assert_same_sub_schema ( res0 , targ ) <EOL> assert_same_sub_schema ( res1 , targ ) <EOL> assert_same_sub_schema ( res2 , targ ) <EOL> assert_same_sub_schema ( res3 , targ ) <EOL> assert_same_sub_schema ( res4 , targ ) <EOL> assert_same_sub_schema ( res5 , targ ) <EOL> @ unittest . skipUnless ( HAVE_IPYTHON , "<STR_LIT>" ) <EOL> def test__pretty ( self ) : <EOL> ann = get_annotations ( ) <EOL> ann [ '<STR_LIT>' ] = self . seed1 <EOL> ann = pretty ( ann ) . replace ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> res = pretty ( self . seg1 ) <EOL> sig0 = pretty ( self . sigs1 [ <NUM_LIT:0> ] ) <EOL> sig1 = pretty ( self . sigs1 [ <NUM_LIT:1> ] ) <EOL> sig2 = pretty ( self . sigs1 [ <NUM_LIT:2> ] ) <EOL> sig3 = pretty ( self . sigs1 [ <NUM_LIT:3> ] ) <EOL> sig0 = sig0 . replace ( '<STR_LIT:\n>' , '<STR_LIT>' ) <EOL> sig1 = sig1 . replace ( '<STR_LIT:\n>' , '<STR_LIT>' ) <EOL> sig2 = sig2 . replace ( '<STR_LIT:\n>' , '<STR_LIT>' ) <EOL> sig3 = sig3 . replace ( '<STR_LIT:\n>' , '<STR_LIT>' ) <EOL> sigarr0 = pretty ( self . sigarrs1 [ <NUM_LIT:0> ] ) <EOL> sigarr1 = pretty ( self . sigarrs1 [ <NUM_LIT:1> ] ) <EOL> sigarr0 = sigarr0 . replace ( '<STR_LIT:\n>' , '<STR_LIT>' ) <EOL> sigarr1 = sigarr1 . replace ( '<STR_LIT:\n>' , '<STR_LIT>' ) <EOL> targ = ( "<STR_LIT>" + <EOL> ( "<STR_LIT>" % <EOL> ( len ( self . sigs1a ) , len ( self . sigarrs1a ) ) ) + <EOL> ( "<STR_LIT>" % <EOL> ( len ( self . epcs1a ) , len ( self . epcas1a ) ) ) + <EOL> ( "<STR_LIT>" % <EOL> ( len ( self . evts1a ) , len ( self . evtas1a ) ) ) + <EOL> ( "<STR_LIT>" % <EOL> len ( self . irsigs1a ) ) + <EOL> ( "<STR_LIT>" % <EOL> ( len ( self . spikes1a ) , len ( self . trains1a ) ) ) + <EOL> ( "<STR_LIT>" % <EOL> ( self . seg1 . name , self . seg1 . description ) <EOL> ) + <EOL> ( "<STR_LIT>" % ann ) + <EOL> ( "<STR_LIT>" % len ( self . sigs1a ) ) + <EOL> ( '<STR_LIT>' % ( <NUM_LIT:0> , sig0 ) ) + <EOL> ( '<STR_LIT>' % ( <NUM_LIT:1> , sig1 ) ) + <EOL> ( '<STR_LIT>' % ( <NUM_LIT:2> , sig2 ) ) + <EOL> ( '<STR_LIT>' % ( <NUM_LIT:3> , sig3 ) ) + <EOL> ( "<STR_LIT>" % len ( self . sigarrs1a ) ) + <EOL> ( '<STR_LIT>' % ( <NUM_LIT:0> , sigarr0 ) ) + <EOL> ( '<STR_LIT>' % ( <NUM_LIT:1> , sigarr1 ) ) ) <EOL> self . assertEqual ( res , targ ) <EOL> def test__construct_subsegment_by_unit ( self ) : <EOL> nb_seg = <NUM_LIT:3> <EOL> nb_unit = <NUM_LIT:7> <EOL> unit_with_sig = np . array ( [ <NUM_LIT:0> , <NUM_LIT:2> , <NUM_LIT:5> ] ) <EOL> signal_types = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> sig_len = <NUM_LIT:100> <EOL> rcgs = [ RecordingChannelGroup ( name = '<STR_LIT>' , <EOL> channel_indexes = unit_with_sig ) , <EOL> RecordingChannelGroup ( name = '<STR_LIT>' , <EOL> channel_indexes = unit_with_sig ) ] <EOL> all_unit = [ ] <EOL> for u in range ( nb_unit ) : <EOL> un = Unit ( name = '<STR_LIT>' % u , channel_indexes = np . array ( [ u ] ) ) <EOL> assert_neo_object_is_compliant ( un ) <EOL> all_unit . append ( un ) <EOL> blk = Block ( ) <EOL> blk . recordingchannelgroups = rcgs <EOL> for s in range ( nb_seg ) : <EOL> seg = Segment ( name = '<STR_LIT>' % s ) <EOL> for j in range ( nb_unit ) : <EOL> st = SpikeTrain ( [ <NUM_LIT:1> , <NUM_LIT:2> ] , units = '<STR_LIT>' , <EOL> t_start = <NUM_LIT:0.> , t_stop = <NUM_LIT:10> ) <EOL> st . unit = all_unit [ j ] <EOL> for t in signal_types : <EOL> anasigarr = AnalogSignalArray ( np . zeros ( ( sig_len , <EOL> len ( unit_with_sig ) ) ) , <EOL> units = '<STR_LIT>' , <EOL> sampling_rate = <NUM_LIT> * pq . Hz , <EOL> channel_indexes = unit_with_sig ) <EOL> seg . analogsignalarrays . append ( anasigarr ) <EOL> blk . create_many_to_one_relationship ( ) <EOL> for unit in all_unit : <EOL> assert_neo_object_is_compliant ( unit ) <EOL> for rcg in rcgs : <EOL> assert_neo_object_is_compliant ( rcg ) <EOL> assert_neo_object_is_compliant ( blk ) <EOL> newseg = seg . construct_subsegment_by_unit ( all_unit [ : <NUM_LIT:4> ] ) <EOL> assert_neo_object_is_compliant ( newseg ) <EOL> def test_segment_take_spikes_by_unit ( self ) : <EOL> result1 = self . seg1 . take_spikes_by_unit ( ) <EOL> result21 = self . seg1 . take_spikes_by_unit ( [ self . unit1 ] ) <EOL> result22 = self . seg1 . take_spikes_by_unit ( [ self . unit2 ] ) <EOL> self . assertEqual ( result1 , [ ] ) <EOL> assert_same_sub_schema ( result21 , [ self . spikes1a [ <NUM_LIT:0> ] ] ) <EOL> assert_same_sub_schema ( result22 , [ self . spikes1a [ <NUM_LIT:1> ] ] ) <EOL> def test_segment_take_spiketrains_by_unit ( self ) : <EOL> result1 = self . seg1 . take_spiketrains_by_unit ( ) <EOL> result21 = self . seg1 . take_spiketrains_by_unit ( [ self . unit1 ] ) <EOL> result22 = self . seg1 . take_spiketrains_by_unit ( [ self . unit2 ] ) <EOL> self . assertEqual ( result1 , [ ] ) <EOL> assert_same_sub_schema ( result21 , [ self . trains1a [ <NUM_LIT:0> ] ] ) <EOL> assert_same_sub_schema ( result22 , [ self . trains1a [ <NUM_LIT:1> ] ] ) <EOL> def test_segment_take_analogsignal_by_unit ( self ) : <EOL> result1 = self . seg1 . take_analogsignal_by_unit ( ) <EOL> result21 = self . seg1 . take_analogsignal_by_unit ( [ self . unit1 ] ) <EOL> result22 = self . seg1 . take_analogsignal_by_unit ( [ self . unit2 ] ) <EOL> self . assertEqual ( result1 , [ ] ) <EOL> assert_same_sub_schema ( result21 , [ self . sigs1a [ <NUM_LIT:0> ] ] ) <EOL> assert_same_sub_schema ( result22 , [ self . sigs1a [ <NUM_LIT:1> ] ] ) <EOL> def test_segment_take_analogsignal_by_channelindex ( self ) : <EOL> ind1 = self . unit1 . channel_indexes [ <NUM_LIT:0> ] <EOL> ind2 = self . unit2 . channel_indexes [ <NUM_LIT:0> ] <EOL> result1 = self . seg1 . take_analogsignal_by_channelindex ( ) <EOL> result21 = self . seg1 . take_analogsignal_by_channelindex ( [ ind1 ] ) <EOL> result22 = self . seg1 . take_analogsignal_by_channelindex ( [ ind2 ] ) <EOL> self . assertEqual ( result1 , [ ] ) <EOL> assert_same_sub_schema ( result21 , [ self . sigs1a [ <NUM_LIT:0> ] ] ) <EOL> assert_same_sub_schema ( result22 , [ self . sigs1a [ <NUM_LIT:1> ] ] ) <EOL> def test_seg_take_slice_of_analogsignalarray_by_unit ( self ) : <EOL> seg = self . seg1 <EOL> result1 = seg . take_slice_of_analogsignalarray_by_unit ( ) <EOL> result21 = seg . take_slice_of_analogsignalarray_by_unit ( [ self . unit1 ] ) <EOL> result23 = seg . take_slice_of_analogsignalarray_by_unit ( [ self . unit3 ] ) <EOL> self . assertEqual ( result1 , [ ] ) <EOL> targ1 = [ self . sigarrs1a [ <NUM_LIT:0> ] [ : , np . array ( [ True ] ) ] , <EOL> self . sigarrs1a [ <NUM_LIT:1> ] [ : , np . array ( [ False ] ) ] ] <EOL> targ3 = [ self . sigarrs1a [ <NUM_LIT:0> ] [ : , np . array ( [ False ] ) ] , <EOL> self . sigarrs1a [ <NUM_LIT:1> ] [ : , np . array ( [ True ] ) ] ] <EOL> assert_same_sub_schema ( result21 , targ1 ) <EOL> assert_same_sub_schema ( result23 , targ3 ) <EOL> def test_seg_take_slice_of_analogsignalarray_by_channelindex ( self ) : <EOL> seg = self . seg1 <EOL> ind1 = self . unit1 . channel_indexes [ <NUM_LIT:0> ] <EOL> ind3 = self . unit3 . channel_indexes [ <NUM_LIT:0> ] <EOL> result1 = seg . take_slice_of_analogsignalarray_by_channelindex ( ) <EOL> result21 = seg . take_slice_of_analogsignalarray_by_channelindex ( [ ind1 ] ) <EOL> result23 = seg . take_slice_of_analogsignalarray_by_channelindex ( [ ind3 ] ) <EOL> self . assertEqual ( result1 , [ ] ) <EOL> targ1 = [ self . sigarrs1a [ <NUM_LIT:0> ] [ : , np . array ( [ True ] ) ] , <EOL> self . sigarrs1a [ <NUM_LIT:1> ] [ : , np . array ( [ False ] ) ] ] <EOL> targ3 = [ self . sigarrs1a [ <NUM_LIT:0> ] [ : , np . array ( [ False ] ) ] , <EOL> self . sigarrs1a [ <NUM_LIT:1> ] [ : , np . array ( [ True ] ) ] ] <EOL> assert_same_sub_schema ( result21 , targ1 ) <EOL> assert_same_sub_schema ( result23 , targ3 ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> unittest . main ( ) </s>
