#NEWLINE# def test_stack_memory( ) : #NEWLINE# #INDENT# def __test( data , n_steps , delay ) : #NEWLINE# #INDENT# data_stack = librosa . feature . stack_memory ( data , n_steps = n_steps , delay = delay ) #NEWLINE# if ( data . ndim == 1 ) : #NEWLINE# #INDENT# data = data . reshape ( ( 1 , ( - 1 ) ) ) #NEWLINE# #UNINDENT# ( d , t ) = data . shape #NEWLINE# eq_ ( data_stack . shape [ 0 ] , ( n_steps * d ) ) #NEWLINE# eq_ ( data_stack . shape [ 1 ] , t ) #NEWLINE# for i in range ( d ) : #NEWLINE# #INDENT# for step in range ( 1 , n_steps ) : #NEWLINE# #INDENT# assert np . allclose ( data [ i , : ( ( - step ) * delay ) ] , data_stack [ ( ( step * d ) + i ) , ( step * delay ) : ] ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# for ndim in [ 1 , 2 ] : #NEWLINE# #INDENT# data = np . random . randn ( * ( [ 5 ] * ndim ) ) #NEWLINE# for n_steps in [ ( - 1 ) , 0 , 1 , 2 , 3 , 4 ] : #NEWLINE# #INDENT# for delay in [ ( - 1 ) , 0 , 1 , 2 , 4 ] : #NEWLINE# #INDENT# tf = __test #NEWLINE# if ( n_steps < 1 ) : #NEWLINE# #INDENT# tf = raises ( librosa . ParameterError ) ( __test ) #NEWLINE# #UNINDENT# if ( delay < 1 ) : #NEWLINE# #INDENT# tf = raises ( librosa . ParameterError ) ( __test ) #NEWLINE# #UNINDENT# ( yield ( tf , data , __test , delay ) )