<s> """<STR_LIT>""" <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 . eventarray import EventArray <EOL> from neo . core import Segment <EOL> from neo . test . tools import ( assert_neo_object_is_compliant , <EOL> assert_arrays_equal , assert_same_sub_schema ) <EOL> from neo . test . generate_datasets import ( get_fake_value , get_fake_values , <EOL> fake_neo , 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> times = get_fake_value ( '<STR_LIT>' , pq . Quantity , seed = <NUM_LIT:0> , dim = <NUM_LIT:1> ) <EOL> labels = get_fake_value ( '<STR_LIT>' , np . ndarray , seed = <NUM_LIT:1> , dim = <NUM_LIT:1> , dtype = '<STR_LIT:S>' ) <EOL> name = get_fake_value ( '<STR_LIT:name>' , str , seed = <NUM_LIT:2> , obj = EventArray ) <EOL> description = get_fake_value ( '<STR_LIT:description>' , str , <EOL> seed = <NUM_LIT:3> , obj = '<STR_LIT>' ) <EOL> file_origin = get_fake_value ( '<STR_LIT>' , str ) <EOL> attrs1 = { '<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 ( EventArray , annotate = False , seed = <NUM_LIT:0> ) <EOL> res12 = get_fake_values ( '<STR_LIT>' , annotate = False , seed = <NUM_LIT:0> ) <EOL> res21 = get_fake_values ( EventArray , annotate = True , seed = <NUM_LIT:0> ) <EOL> res22 = get_fake_values ( '<STR_LIT>' , annotate = True , seed = <NUM_LIT:0> ) <EOL> assert_arrays_equal ( res11 . pop ( '<STR_LIT>' ) , times ) <EOL> assert_arrays_equal ( res12 . pop ( '<STR_LIT>' ) , times ) <EOL> assert_arrays_equal ( res21 . pop ( '<STR_LIT>' ) , times ) <EOL> assert_arrays_equal ( res22 . pop ( '<STR_LIT>' ) , times ) <EOL> assert_arrays_equal ( res11 . pop ( '<STR_LIT>' ) , labels ) <EOL> assert_arrays_equal ( res12 . pop ( '<STR_LIT>' ) , labels ) <EOL> assert_arrays_equal ( res21 . pop ( '<STR_LIT>' ) , labels ) <EOL> assert_arrays_equal ( res22 . pop ( '<STR_LIT>' ) , labels ) <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 = EventArray <EOL> cascade = True <EOL> res = fake_neo ( obj_type = obj_type , cascade = cascade ) <EOL> self . assertTrue ( isinstance ( res , EventArray ) ) <EOL> assert_neo_object_is_compliant ( res ) <EOL> self . assertEqual ( res . annotations , 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 , EventArray ) ) <EOL> assert_neo_object_is_compliant ( res ) <EOL> self . assertEqual ( res . annotations , self . annotations ) <EOL> class TestEventArray ( unittest . TestCase ) : <EOL> def test_EventArray_creation ( self ) : <EOL> params = { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : True } <EOL> evta = EventArray ( [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] * pq . ms , <EOL> labels = np . array ( [ '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ] , dtype = '<STR_LIT:S>' ) , <EOL> name = '<STR_LIT:test>' , description = '<STR_LIT>' , <EOL> file_origin = '<STR_LIT>' , <EOL> test1 = <NUM_LIT:1> , ** params ) <EOL> evta . annotate ( test1 = <NUM_LIT> , test0 = [ <NUM_LIT:1> , <NUM_LIT:2> ] ) <EOL> assert_neo_object_is_compliant ( evta ) <EOL> assert_arrays_equal ( evta . times , [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] * pq . ms ) <EOL> assert_arrays_equal ( evta . labels , np . array ( [ '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ] , dtype = '<STR_LIT:S>' ) ) <EOL> self . assertEqual ( evta . name , '<STR_LIT:test>' ) <EOL> self . assertEqual ( evta . description , '<STR_LIT>' ) <EOL> self . assertEqual ( evta . file_origin , '<STR_LIT>' ) <EOL> self . assertEqual ( evta . annotations [ '<STR_LIT>' ] , [ <NUM_LIT:1> , <NUM_LIT:2> ] ) <EOL> self . assertEqual ( evta . annotations [ '<STR_LIT>' ] , <NUM_LIT> ) <EOL> self . assertEqual ( evta . annotations [ '<STR_LIT>' ] , '<STR_LIT>' ) <EOL> self . assertTrue ( evta . annotations [ '<STR_LIT>' ] ) <EOL> def test_EventArray_repr ( self ) : <EOL> params = { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : True } <EOL> evta = EventArray ( [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] * pq . ms , <EOL> labels = np . array ( [ '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ] , dtype = '<STR_LIT:S>' ) , <EOL> name = '<STR_LIT:test>' , description = '<STR_LIT>' , <EOL> file_origin = '<STR_LIT>' , <EOL> test1 = <NUM_LIT:1> , ** params ) <EOL> evta . annotate ( test1 = <NUM_LIT> , test0 = [ <NUM_LIT:1> , <NUM_LIT:2> ] ) <EOL> assert_neo_object_is_compliant ( evta ) <EOL> targ = ( '<STR_LIT>' + <EOL> '<STR_LIT>' ) <EOL> res = repr ( evta ) <EOL> self . assertEqual ( targ , res ) <EOL> def test_EventArray_merge ( self ) : <EOL> params1 = { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : True } <EOL> params2 = { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : False } <EOL> paramstarg = { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : True , <EOL> '<STR_LIT>' : False } <EOL> epca1 = EventArray ( [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] * pq . ms , <EOL> labels = np . array ( [ '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ] , dtype = '<STR_LIT:S>' ) , <EOL> name = '<STR_LIT:test>' , description = '<STR_LIT>' , <EOL> file_origin = '<STR_LIT>' , <EOL> test1 = <NUM_LIT:1> , ** params1 ) <EOL> epca2 = EventArray ( [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] * pq . us , <EOL> labels = np . array ( [ '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ] , dtype = '<STR_LIT:S>' ) , <EOL> name = '<STR_LIT:test>' , description = '<STR_LIT>' , <EOL> file_origin = '<STR_LIT>' , <EOL> test1 = <NUM_LIT:1> , ** params2 ) <EOL> epcatarg = EventArray ( [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] * pq . ms , <EOL> labels = np . array ( [ '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ] , dtype = '<STR_LIT:S>' ) , <EOL> name = '<STR_LIT:test>' , <EOL> description = '<STR_LIT>' , <EOL> file_origin = '<STR_LIT>' , <EOL> test1 = <NUM_LIT:1> , ** paramstarg ) <EOL> assert_neo_object_is_compliant ( epca1 ) <EOL> assert_neo_object_is_compliant ( epca2 ) <EOL> assert_neo_object_is_compliant ( epcatarg ) <EOL> epcares = epca1 . merge ( epca2 ) <EOL> assert_neo_object_is_compliant ( epcares ) <EOL> assert_same_sub_schema ( epcatarg , epcares ) <EOL> def test__children ( self ) : <EOL> params = { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : True } <EOL> evta = EventArray ( [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] * pq . ms , <EOL> labels = np . array ( [ '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ] , dtype = '<STR_LIT:S>' ) , <EOL> name = '<STR_LIT:test>' , description = '<STR_LIT>' , <EOL> file_origin = '<STR_LIT>' , <EOL> test1 = <NUM_LIT:1> , ** params ) <EOL> evta . annotate ( test1 = <NUM_LIT> , test0 = [ <NUM_LIT:1> , <NUM_LIT:2> ] ) <EOL> assert_neo_object_is_compliant ( evta ) <EOL> segment = Segment ( name = '<STR_LIT>' ) <EOL> segment . eventarrays = [ evta ] <EOL> segment . create_many_to_one_relationship ( ) <EOL> self . assertEqual ( evta . _single_parent_objects , ( '<STR_LIT>' , ) ) <EOL> self . assertEqual ( evta . _multi_parent_objects , ( ) ) <EOL> self . assertEqual ( evta . _single_parent_containers , ( '<STR_LIT>' , ) ) <EOL> self . assertEqual ( evta . _multi_parent_containers , ( ) ) <EOL> self . assertEqual ( evta . _parent_objects , ( '<STR_LIT>' , ) ) <EOL> self . assertEqual ( evta . _parent_containers , ( '<STR_LIT>' , ) ) <EOL> self . assertEqual ( len ( evta . parents ) , <NUM_LIT:1> ) <EOL> self . assertEqual ( evta . parents [ <NUM_LIT:0> ] . name , '<STR_LIT>' ) <EOL> assert_neo_object_is_compliant ( evta ) <EOL> @ unittest . skipUnless ( HAVE_IPYTHON , "<STR_LIT>" ) <EOL> def test__pretty ( self ) : <EOL> evta = EventArray ( [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] * pq . ms , <EOL> labels = np . array ( [ '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ] , dtype = '<STR_LIT:S>' ) , <EOL> name = '<STR_LIT:test>' , description = '<STR_LIT>' , <EOL> file_origin = '<STR_LIT>' ) <EOL> evta . annotate ( test1 = <NUM_LIT> , test0 = [ <NUM_LIT:1> , <NUM_LIT:2> ] ) <EOL> assert_neo_object_is_compliant ( evta ) <EOL> prepr = pretty ( evta ) <EOL> targ = ( "<STR_LIT>" % <EOL> ( evta . name , evta . description , pretty ( evta . annotations ) ) ) <EOL> self . assertEqual ( prepr , targ ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> unittest . main ( ) </s>
