#NEWLINE# def test_dpss_properties( ) : #NEWLINE# #INDENT# ' Test conventions of Slepian eigenvectors ' #NEWLINE# N = 2000 #NEWLINE# NW = 200 #NEWLINE# ( d , lam ) = tsa . dpss_windows ( N , NW , ( ( 2 * NW ) - 2 ) ) #NEWLINE# nt . assert_true ( ( lam > 0.9 ) . all ( ) , 'Eigenvectors show poor spectral concentration' ) #NEWLINE# err = np . linalg . norm ( ( d . dot ( d . T ) - np . eye ( ( ( 2 * NW ) - 2 ) ) ) , ord = 'fro' ) #NEWLINE# nt . assert_true ( ( ( err ** 2 ) < 1e-16 ) , 'Eigenvectors not numerically orthonormal' ) #NEWLINE# nt . assert_true ( ( d [ : : 2 ] . sum ( axis = 1 ) > 0 ) . all ( ) , 'Even Slepian sequences should have positive DC' ) #NEWLINE# pk = np . argmax ( np . abs ( d [ 1 : : 2 , : ( N // 2 ) ] ) , axis = 1 ) #NEWLINE# t = True #NEWLINE# for ( p , f ) in zip ( pk , d [ 1 : : 2 ] ) : #NEWLINE# #INDENT# t = ( t and ( np . sum ( ( np . arange ( 1 , ( p + 1 ) ) * f [ : lam ] ) ) >= 0 ) ) #NEWLINE# #UNINDENT# nt . assert_true ( t , 'Odd Slepians should begin positive-going' )