#NEWLINE# @ requires_sklearn #NEWLINE# def test_spatio_temporal_tris_connectivity( ) : #NEWLINE# #INDENT# 'Test spatio-temporal connectivity from triangles' #NEWLINE# tris = np . array ( [ [ 0 , 1 , 2 ] , [ 3 , 4 , 5 ] ] ) #NEWLINE# connectivity = spatio_temporal_tris_connectivity ( tris , 2 ) #NEWLINE# x = [ 1 , 1 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 1 ] #NEWLINE# components = stats . cluster_level . _get_components ( np . array ( x ) , connectivity ) #NEWLINE# old_fmt = [ 0 , 0 , ( - 2 ) , ( - 2 ) , ( - 2 ) , ( - 2 ) , 0 , ( - 2 ) , ( - 2 ) , ( - 2 ) , ( - 2 ) , 1 ] #NEWLINE# new_fmt = np . array ( old_fmt ) #NEWLINE# new_fmt = [ np . nonzero ( ( new_fmt == v ) ) [ 0 ] for v in np . unique ( new_fmt [ ( new_fmt >= 0 ) ] ) ] #NEWLINE# assert_true ( len ( new_fmt ) , len ( components ) ) #NEWLINE# for ( c , n ) in zip ( components , new_fmt ) : #NEWLINE# #INDENT# assert_array_equal ( c , n )