<s> import unittest <EOL> import numpy as np <EOL> from scot . var import VAR <EOL> import scot . connectivity_statistics as cs <EOL> class TestFunctions ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> pass <EOL> def tearDown ( self ) : <EOL> pass <EOL> @ staticmethod <EOL> def generate_data ( ) : <EOL> var = VAR ( <NUM_LIT:2> ) <EOL> var . coef = np . array ( [ [ <NUM_LIT> , <NUM_LIT:0.1> , <NUM_LIT:0> , <NUM_LIT:0> ] , [ <NUM_LIT> , - <NUM_LIT> , <NUM_LIT:0.1> , <NUM_LIT:0> ] ] ) <EOL> l = ( <NUM_LIT:100> , <NUM_LIT:100> ) <EOL> x = var . simulate ( l ) <EOL> return x , var <EOL> def test_surrogate ( self ) : <EOL> np . random . seed ( <NUM_LIT> ) <EOL> x , var0 = self . generate_data ( ) <EOL> result = cs . surrogate_connectivity ( '<STR_LIT>' , x , VAR ( <NUM_LIT:2> ) , nfft = <NUM_LIT:4> , <EOL> repeats = <NUM_LIT:100> ) <EOL> self . assertEqual ( result . shape , ( <NUM_LIT:100> , <NUM_LIT:2> , <NUM_LIT:2> , <NUM_LIT:4> ) ) <EOL> structure = np . mean ( np . mean ( result , axis = <NUM_LIT:3> ) , axis = <NUM_LIT:0> ) <EOL> self . assertTrue ( np . all ( np . abs ( structure - np . eye ( <NUM_LIT:2> ) ) < <NUM_LIT> ) ) <EOL> def test_jackknife ( self ) : <EOL> np . random . seed ( <NUM_LIT> ) <EOL> x , var0 = self . generate_data ( ) <EOL> result = cs . jackknife_connectivity ( '<STR_LIT>' , x , VAR ( <NUM_LIT:2> ) , nfft = <NUM_LIT:4> , <EOL> leaveout = <NUM_LIT:1> ) <EOL> self . assertEqual ( result . shape , ( <NUM_LIT:100> , <NUM_LIT:2> , <NUM_LIT:2> , <NUM_LIT:4> ) ) <EOL> structure = np . mean ( np . mean ( result , axis = <NUM_LIT:3> ) , axis = <NUM_LIT:0> ) <EOL> self . assertTrue ( np . all ( np . abs ( structure - [ [ <NUM_LIT:1> , <NUM_LIT:0> ] , [ <NUM_LIT:0.5> , <NUM_LIT:1> ] ] ) < <NUM_LIT> ) ) <EOL> def test_bootstrap ( self ) : <EOL> np . random . seed ( <NUM_LIT> ) <EOL> x , var0 = self . generate_data ( ) <EOL> result = cs . bootstrap_connectivity ( '<STR_LIT>' , x , VAR ( <NUM_LIT:2> ) , nfft = <NUM_LIT:4> , <EOL> repeats = <NUM_LIT:100> ) <EOL> self . assertEqual ( result . shape , ( <NUM_LIT:100> , <NUM_LIT:2> , <NUM_LIT:2> , <NUM_LIT:4> ) ) <EOL> structure = np . mean ( np . mean ( result , axis = <NUM_LIT:3> ) , axis = <NUM_LIT:0> ) <EOL> self . assertTrue ( np . all ( np . abs ( structure - [ [ <NUM_LIT:1> , <NUM_LIT:0> ] , [ <NUM_LIT:0.5> , <NUM_LIT:1> ] ] ) < <NUM_LIT> ) ) <EOL> def test_bootstrap_difference_and_fdr ( self ) : <EOL> np . random . seed ( <NUM_LIT> ) <EOL> x , var0 = self . generate_data ( ) <EOL> a = cs . bootstrap_connectivity ( '<STR_LIT>' , x , VAR ( <NUM_LIT:2> ) , nfft = <NUM_LIT:4> , repeats = <NUM_LIT:100> ) <EOL> np . random . seed ( <NUM_LIT> ) <EOL> x , var0 = self . generate_data ( ) <EOL> b = cs . bootstrap_connectivity ( '<STR_LIT>' , x , VAR ( <NUM_LIT:2> ) , nfft = <NUM_LIT:4> , repeats = <NUM_LIT:100> ) <EOL> p = cs . test_bootstrap_difference ( a , b ) <EOL> self . assertFalse ( np . any ( p < <NUM_LIT> ) ) <EOL> self . assertFalse ( np . any ( cs . significance_fdr ( p , <NUM_LIT> ) ) ) <EOL> np . random . seed ( <NUM_LIT> ) <EOL> x , var0 = self . generate_data ( ) <EOL> b = cs . bootstrap_connectivity ( '<STR_LIT>' , x [ : : - <NUM_LIT:1> , : , : ] , VAR ( <NUM_LIT:2> ) , nfft = <NUM_LIT:4> , <EOL> repeats = <NUM_LIT:100> ) <EOL> p = cs . test_bootstrap_difference ( a , b ) <EOL> self . assertFalse ( np . any ( p < <NUM_LIT> ) ) <EOL> self . assertFalse ( np . any ( cs . significance_fdr ( p , <NUM_LIT> ) ) ) <EOL> np . random . seed ( <NUM_LIT> ) <EOL> x , var0 = self . generate_data ( ) <EOL> b = cs . bootstrap_connectivity ( '<STR_LIT>' , x [ <NUM_LIT:1> , : : - <NUM_LIT:1> , : ] , VAR ( <NUM_LIT:2> ) , nfft = <NUM_LIT:4> , <EOL> repeats = <NUM_LIT:100> ) <EOL> p = cs . test_bootstrap_difference ( a , b ) <EOL> self . assertTrue ( np . all ( p < <NUM_LIT> ) ) <EOL> self . assertTrue ( np . all ( cs . significance_fdr ( p , <NUM_LIT> ) ) ) <EOL> np . random . seed ( <NUM_LIT> ) <EOL> x , var0 = self . generate_data ( ) <EOL> b = cs . bootstrap_connectivity ( '<STR_LIT>' , x [ <NUM_LIT:1> , : , : : - <NUM_LIT:1> ] , VAR ( <NUM_LIT:2> ) , nfft = <NUM_LIT:4> , <EOL> repeats = <NUM_LIT:100> ) <EOL> p = cs . test_bootstrap_difference ( a , b ) <EOL> self . assertTrue ( np . all ( p < <NUM_LIT> ) ) <EOL> self . assertTrue ( np . all ( cs . significance_fdr ( p , <NUM_LIT> ) ) ) </s>
